title: How to use transform_graph to optimize Tensorflow model
body: <p>I used to use the <code>optimize_for_inference</code> library in optimizing frozen Tensorflow models. However, I have read from different sources that Tensorflow no longer supports it.</p>
  
  <p>I came across <code>transform_graph</code>, and its documentation is found here: <a href="https://github.com/tensorflow/tensorflow/tree/master/tensorflow/tools/graph_transforms#strip_unused_nodes" rel="nofollow noreferrer">https://github.com/tensorflow/tensorflow/tree/master/tensorflow/tools/graph_transforms#strip_unused_nodes</a></p>
  
  <p>At first, I ran into errors and found out that I need to install Tensorflow from source (<a href="https://www.tensorflow.org/install/install_sources#install_the_pip_package" rel="nofollow noreferrer">https://www.tensorflow.org/install/install_sources#install_the_pip_package</a>) instead of using PIP.</p>
  
  <p>I already re-installed Tensorflow from source, and ran this code in bash (/tensorflor/tensorflow dir):</p>
  
  <pre><code>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)'
  </code></pre>
  
  <p>And ran to again this error:</p>
  
  <p>-bash: bazel-bin/tensorflow/tools/graph_transforms/transform_graph: No such file or directory</p>
  
  <p>What seems to be the problem?</p>