Error with 8-bit Quantization in Tensorflow

放肆的年华 提交于 2019-12-02 02:22:20

问题


I have been experimenting with the new 8-bit quantization feature available in TensorFlow. I could run the example given in the blog post (quantization of googlenet) without any issue and it works fine for me !!!

Now, I would like to apply the same for a simpler network. So I used a pre-trained network for CIFAR-10 (which is trained on Caffe), extracted its parameters, created corresponding graph in tensorflow, initialized the weights with this pre-trained weights and finally saved it as a GraphDef object. See this IPython Notebook for full procedure.

Now I applied the 8-bit quantization with the tensorflow script as mentioned in the Pete Warden's blog:

bazel-bin/tensorflow/contrib/quantization/tools/quantize_graph --input=cifar.pb  --output=qcifar.pb --mode=eightbit --bitdepth=8 --output_node_names="ArgMax"

Now I wanted to run the classification on this quantized network. So I loaded the new qcifar.pb to a tensorflow session and passed the image (the same way I passed it to original version). Full code can be found in this IPython Notebook.

But as you can see at the end, I am getting following error:

NotFoundError: Op type not registered 'QuantizeV2'

Can anybody suggest what am I missing here?


回答1:


Because the quantized ops and kernels are in contrib, you'll need to explicitly load them in your python script. There's an example of that in the quantize_graph.py script itself:

from tensorflow.contrib.quantization import load_quantized_ops_so from tensorflow.contrib.quantization.kernels import load_quantized_kernels_so

This is something that we should update the documentation to mention!



来源:https://stackoverflow.com/questions/38366876/error-with-8-bit-quantization-in-tensorflow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!