tensorflow模型量化压缩

参考 

https://blog.csdn.net/xygl2009/article/details/80596392

https://blog.csdn.net/xsfl1234/article/details/67669707

https://www.jianshu.com/p/d2637646cda1

 

1 安装bazel

https://docs.bazel.build/versions/master/install-ubuntu.html#install-with-installer-ubuntu

2 下载tensorflow源码

git clone https://github.com/tensorflow/tensorflow.git

bazel编译tensoflow源码

cd tensorflow # cd to the top-level directory created

./configure

bazel build --config=opt --config=cuda //tensorflow/tools/pip_package:build_pip_package

 

4 利用transform_graph转换模型

/DATA/share/DeepLearning/code/tensorflow/bazel-bin/tensorflow/tools/graph_transforms/transform_graph \
--in_graph=./model_resnet100.pb \
--out_graph=./model_resnet100modified.pb \
--inputs=input0 \
--outputs=fcblock/fc1/add_1 \
--transforms='add_default_attributes strip_unused_nodes(type=float, shape="1,112,112,3") remove_nodes(op=Identity, op=CheckNumerics) fold_constants(ignore_errors=true) fold_batch_norms fold_old_batch_norms strip_unused_nodes sort_by_execution_order'

 

posted on 2018-08-23 13:39  Maddock  阅读(847)  评论(0编辑  收藏  举报

导航