tensorflow / tensorflow/models

quantize_graph function in slim does not add FakeQuantWithMinMaxVars around conv2d_transpose.

Open
#9,351 0 comments 0 reactions 2 assignees View on GitHub

Nobody has claimed this yet.

models:research type:bug
Dominant language
Python
Stars
77.7k
Forks
44.8k
PR merge metrics
No merged PRs in 30d

Description

1. The entire URL of the file you are using

https://github.com/tensorflow/models/blob/master/research/slim/train_image_classifier.py

2. Describe the bug

The contrib_quantize.create_training_graph(quant_delay=FLAGS.quantize_delay) in the train_image_classifier.py does not add FakeQuantWithMinMaxVars around tf.layers.conv2d_tranpose, slim.layers.conv2d_tranpose or even tf.nn.conv2d_tranpose. Because of this, the model can not be quantized using TOCO

3. Steps to reproduce

Train any model with conv2d_transpose layer in it using the train_image_classifier.py. Then switch on the quantization and try to convert it into a TFLITE model using TOCO. For example, in the pix2pix net, there is conv2d_tranpose and it can not be quantized.

4. Expected behavior

It should add the FakeQuantWithMinMaxVars since it does not state anywhere that it only works on some operations.

5. Additional context

The error from TOCO:
...conv2d_transpose, which is an input to the Relu operator producing the output array MobilenetV1/MobilenetV1/first_transpose_conv/Relu, is lacking min/max data, which is necessary for quantization. If accuracy matters, either target a non-quantized output format, or run quantized training with your model from a floating point checkpoint to change the input graph to contain min/max information. If you don't care about accuracy, you can pass --default_ranges_min= and --default_ranges_max= for easy experimentation.
Fatal Python error: Aborted

6. System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): 18.04
  • Mobile device name if the issue happens on a mobile device:
  • TensorFlow installed from (source or binary): binary
  • TensorFlow version (use command below): 1.15.0, 1.15.2, 1.15.3, 1.15.4
  • Python version: 3.6.8
  • Bazel version (if compiling from source):
  • GCC/Compiler version (if compiling from source):
  • CUDA/cuDNN version: 10.0 and 7.6.5
  • GPU model and memory: NVIDIA GTX1080 Ti 11Gb and NVIDIA RTX2080 Ti 11Gb

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.