I used to use the optimize_for_inference
library in optimizing frozen Tensorflow models. However, I have read from different sources that Tensorflow no longer supports it.
I came across transform_graph
, and its documentation is found here: https://github.com/tensorflow/tensorflow/tree/master/tensorflow/tools/graph_transforms#strip_unused_nodes
At first, I ran into errors and found out that I need to install Tensorflow from source (https://www.tensorflow.org/install/install_sources#install_the_pip_package) instead of using PIP.
I already re-installed Tensorflow from source, and ran this code in bash (/tensorflor/tensorflow dir):
bazel build tensorflow/tools/graph_transforms:transform_graph
bazel-bin/tensorflow/tools/graph_transforms/transform_graph \
--in_graph=tensorflow_inception_graph.pb \
--out_graph=optimized_inception_graph.pb \
--inputs='Mul' \
--outputs='softmax' \
--transforms='
strip_unused_nodes(type=float, shape="1,299,299,3")
fold_constants(ignore_errors=true)
fold_batch_norms
fold_old_batch_norms
round_weights(num_steps=256)'
And ran to again this error:
-bash: bazel-bin/tensorflow/tools/graph_transforms/transform_graph: No such file or directory
What seems to be the problem?