Ubuntu16.04使用tensorflow压缩facenet网络训练的模型
- 压缩使用facenet训练好并冻结以后的模型
- facenet网络:https://github.com/davidsandberg/facenet
- 安装bazel和必要的编译步骤:ubuntu16.04中tensorflow压缩模型transform_graph方式
- 在训练好facenet网络,并使用freeze_graph.py冻结模型以后,对于输出的文件facenet_freeze.pb,经过多次尝试,终于压缩好。
- 压缩的方式:
- 各种选项解释:https://github.com/tensorflow/tensorflow/tree/master/tensorflow/tools/graph_transforms
- bazel-bin/tensorflow/tools/graph_transforms/transform_graph
- --in_graph=/home/用户名/facenet_freeze.pb
- --out_graph=/home/用户名/optimized_facenet.pb
- --inputs="input"
- --outputs="embeddings"
- --transforms='add_default_attributes
- fold_constants(ignore_errors=true)
- fold_batch_norms
- fold_old_batch_norms
- quantize_weights
- sort_by_execution_order'