在编译后的tensorflow根目录(tensorflow-master)下运行以下代码,需安装bazel。
bazel-bin/tensorflow/tools/graph_transforms/transform_graph \
--in_graph=/home/zzl/zzl/noDCT_retrained5000_Pruned_Discriminative145000.pb \ #输入pb文件路径
--out_graph=/home/zzl/zzl/quantized64_noDCT_retrained5000_Pruned_Discriminative145000.pb \ #输出pb文件路径
--outputs=Group_22/y_ \
--transforms='
strip_unused_nodes(type=float, shape="1,253,253,1")
fold_constants(ignore_errors=true)
fold_batch_norms
fold_old_batch_norms
quantize_weights(minimum_size=0)'
bazel-bin/tensorflow/tools/graph_transforms/transform_graph \
--in_graph=/home/zzl/zzl/noDCT_retrained5000_Pruned_Discriminative145000.pb \ #输入pb文件路径
--out_graph=/home/zzl/zzl/quantized64_noDCT_retrained5000_Pruned_Discriminative145000.pb \ #输出pb文件路径
--outputs=Group_22/y_ \
--transforms='add_default_attributes
strip_unused_nodes(type=float, shape="1,253,253,1")
remove_nodes(op=Identity, op=CheckNumerics)
fold_constants(ignore_errors=true)
fold_batch_norms
fold_old_batch_norms
quantize_weights(minimum_size=0)
quantize_nodes
strip_unused_nodes sort_by_execution_order'
quantize_nodes:表示进行8bit量化,添加这个参数需要TensorFlow版本在1.7(大概)以上
网友评论