title: In Tensorflow how to freeze saved model
body: <p>This is probably a very basic question...</p>
  
  <p>But how do I convert checkpoint files into a single .pb file.
  My goal is to serve the model using probably C++</p>
  
  <p>These are the files that I'm trying to convert.</p>
  
  <p><a href="https://i.stack.imgur.com/ILnK2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ILnK2.png" alt="Checkpoints"></a></p>
  
  <p>As a side note I'm using tflearn with tensorflow.</p>
  
  <p><strong>Edit 1:</strong>
  I found an article that explains how to do this: <a href="https://blog.metaflow.fr/tensorflow-how-to-freeze-a-model-and-serve-it-with-a-python-api-d4f3596b3adc" rel="nofollow noreferrer">https://blog.metaflow.fr/tensorflow-how-to-freeze-a-model-and-serve-it-with-a-python-api-d4f3596b3adc</a></p>
  
  <p>The problem is that I'm stuck with the following error</p>
  
  <pre><code>KeyError: "The name 'Adam' refers to an Operation not in the graph."
  </code></pre>
  
  <p>How do I fix this?</p>
  
  <p><strong>Edit 2:</strong>
  Maybe this will shed some light on the problem.</p>
  
  <p><a href="https://i.stack.imgur.com/1WgzL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1WgzL.png" alt="Regression Layer"></a></p>
  
  <p>The error that I get comes from the regression layer, if I use: <code>sgd</code>.
  I'll get</p>
  
  <pre><code>KeyError: "The name 'SGD' refers to an Operation not in the graph."
  </code></pre>