<h3 dir="auto">System information</h3>
<ul dir="auto">
<li><strong>Have I written custom code (as opposed to using a stock example script provided in TensorFlow)</strong>: No</li>
<li><strong>OS Platform and Distribution (e.g., Linux Ubuntu 16.04)</strong>: macOS High Sierra 10.13.5</li>
<li><strong>TensorFlow installed from (source or binary)</strong>: binary</li>
<li><strong>TensorFlow version (use command below)</strong>: 1.7.1</li>
<li><strong>Python version</strong>: 2.7.10</li>
<li><strong>Bazel version (if compiling from source)</strong>: N/A</li>
<li><strong>GCC/Compiler version (if compiling from source)</strong>: N/A</li>
<li><strong>CUDA/cuDNN version</strong>: N/A</li>
<li><strong>GPU model and memory</strong>: N/A</li>
<li><strong>Exact command to reproduce</strong>:</li>
</ul>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="toco \
--input_file=tmp/killfie_detector.pb \
--output_file=tmp/quantized_killfie_detector.lite \
--input_format=TENSORFLOW_GRAPHDEF \
--output_format=TFLITE \
--input_shape=1,${IMAGE_SIZE},${IMAGE_SIZE},3 \
--input_array=input1 \
--output_array=output_node0 \
--inference_type=FLOAT \
--input_data_type=FLOAT \
--inference_type=QUANTIZED_UINT8 \
--quantize_weights=true \
--mean_value=127.5 \
--std_value=127.5"><pre class="notranslate"><code class="notranslate">toco \
--input_file=tmp/killfie_detector.pb \
--output_file=tmp/quantized_killfie_detector.lite \
--input_format=TENSORFLOW_GRAPHDEF \
--output_format=TFLITE \
--input_shape=1,${IMAGE_SIZE},${IMAGE_SIZE},3 \
--input_array=input1 \
--output_array=output_node0 \
--inference_type=FLOAT \
--input_data_type=FLOAT \
--inference_type=QUANTIZED_UINT8 \
--quantize_weights=true \
--mean_value=127.5 \
--std_value=127.5
</code></pre></div>
<h3 dir="auto">Describe the problem</h3>
<p dir="auto">I am trying to convert a ResNet-50 model to TFLite after quantization. The quantized graph was obtained using <code class="notranslate">transform_graph</code> and <code class="notranslate">--transforms='quantize_weights'</code> on a .pb file. However, on running <code class="notranslate">toco</code> on the quantized graph using the command above, I am first asked to enter the max/min values and the following error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Array input_1, which is an input to the Conv operator producing the output array conv1/convolution, is lacking min/max data, which is necessary for quantization. Either target a non-quantized output format, or change the input graph to contain min/max information, or pass --default_ranges_min= and --default_ranges_max= if you do not care about the accuracy of results."><pre class="notranslate"><code class="notranslate">Array input_1, which is an input to the Conv operator producing the output array conv1/convolution, is lacking min/max data, which is necessary for quantization. Either target a non-quantized output format, or change the input graph to contain min/max information, or pass --default_ranges_min= and --default_ranges_max= if you do not care about the accuracy of results.
</code></pre></div>
<p dir="auto">On adding <code class="notranslate">--default_ranges_min=0</code> and <code class="notranslate">--default_ranges_max=6</code> based on the suggestions <a href="https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/lite/toco/g3doc/cmdline_examples.md#use-dummy-quantization-to-try-out-quantized-inference-on-a-float-graph-">here</a>.</p>
<p dir="auto">When I ran that script, I got this error message:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="F tensorflow/contrib/lite/toco/graph_transformations/quantize.cc:519] Unimplemented: this graph contains an operator of type (Unsupported TensorFlow op: Dequantize) for which the quantized form is not yet implemented. Sorry, and patches welcome (that's a relatively fun patch to write, mostly providing the actual quantized arithmetic code for this op)."><pre class="notranslate"><code class="notranslate">F tensorflow/contrib/lite/toco/graph_transformations/quantize.cc:519] Unimplemented: this graph contains an operator of type (Unsupported TensorFlow op: Dequantize) for which the quantized form is not yet implemented. Sorry, and patches welcome (that's a relatively fun patch to write, mostly providing the actual quantized arithmetic code for this op).
</code></pre></div>
<p dir="auto">Is there any way around this to get a quantized TFLite model?</p>
<h2 dir="auto">System information</h2>
<p dir="auto">Have I written custom code (as opposed to using a stock example script provided in TensorFlow):no<br>
OS Platform and Distribution (e.g., Linux Ubuntu 16.04):CentOS Linux release 7.2<br>
TensorFlow installed from (source or binary):Anaconda python 3.6.5(conda install)<br>
TensorFlow version (use command below):1.8.0<br>
Python version: 3.6.5<br>
Bazel version (if compiling from source): 0.7.0<br>
GCC/Compiler version (if compiling from source): 4.8.5<br>
CUDA/cuDNN version:cuda-9.0<br>
GPU model and memory: P40<br>
Phone: N/A</p>
<p dir="auto">Hi~<br>
When I use 'tf.contrib.quantize.experimental_create_training_graph'  it will add fake quantization in the graph.  reference this picture(find positions to insert fake quantization nodes).<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/9084403/41646572-c5a48d8a-74a6-11e8-81bf-d1fee67d5c4a.png"><img src="https://user-images.githubusercontent.com/9084403/41646572-c5a48d8a-74a6-11e8-81bf-d1fee67d5c4a.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto">I think it will add a fake quantization node in the bypass, but I can not find it in the tensorboard graph(in the red box, it is the bypass). In other convs, I can find the quantization node.<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/9084403/41649732-d6f538d4-74ae-11e8-87b5-66b2b49904a7.png"><img src="https://user-images.githubusercontent.com/9084403/41649732-d6f538d4-74ae-11e8-87b5-66b2b49904a7.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto">My network architecture is ResNet20,  tensorflow version is 1.8.0</p>
<p dir="auto">pls help me. thank you.</p>