tensorflow模型量化--实践

1、源码编译tensorflow,在文章:《VMware中ubuntu16 源码安装tensorfow,支持cpu》

2、编译量化

bazel build tensorflow/tools/quantization:quantize_graph

3、编译例子

bazel build tensorflow/examples/label_image:label_image

4、下载模型:

curl http://download.tensorflow.org/models/image/imagenet/inception-2015-12-05.tgz -o /sdb/build/data_model/inceptionv3.tgz

tar -xvf /sdb/build/data_model/inceptionv3.tgz -C /sdb/build/data_model/

5、执行量化

bazel-bin/tensorflow/tools/quantization/quantize_graph \

--input= /sdb/build/data_model/classify_image_graph_def.pb \

--output_node_names="softmax" \

--output= /sdb/build/data_model/quantized_graph.pb \

--mode=eightbit


6、测试量化后的模型

bazel-bin/tensorflow/examples/label_image/label_image \

--input_graph=/sdb/build/data_model/quantized_graph.pb \

--input_width=299 \

--input_height=299 \

--mean_value=128 \

--std_value=128 \

--input_layer_name="Mul:0" \

--output_layer_name="softmax:0"


参考资料:

https://blog.csdn.net/u011961856/article/details/76736103

http://fjdu.github.io/machine/learning/2016/07/07/quantize-neural-networks-with-tensorflow.html

https://blog.csdn.net/u011961856/article/details/76736103

你可能感兴趣的:(tensorflow模型量化--实践)