title: TensorFlow: Quantize model using python before save
body: <p>There are tutorials online showing how to quantize a <code>.pb</code> TensorFlow model, see:</p>
  
  <p><a href="https://petewarden.com/2016/05/03/how-to-quantize-neural-networks-with-tensorflow/" rel="nofollow noreferrer">https://petewarden.com/2016/05/03/how-to-quantize-neural-networks-with-tensorflow/</a></p>
  
  <p>What I am wondering is if there is a way to quantize the graph using python before saving the <code>.pb</code> file with <code>tf.train.write_graph()</code></p>
  
  <p>In other words is there some function like <code>quantize(graph_def)</code> that I can run to quantize the graph to 8bit weights and operations before I save it, saving me the hassle of having to do it via the command line after saving the file (like the tutorial linked above outlines).</p>