Save tensorflow model to file
<p>I create a tensorflow model which I would like to save to file so that I can predict against it later.  In particular, I need to save the:  </p>

<ul>
<li>input_placeholder<br>
(<code>= tf.placeholder(tf.float32, [None, iVariableLen])</code>)</li>
<li>solution_space<br>
(<code>= tf.nn.sigmoid(tf.matmul(input_placeholder, weight_variable) + bias_variable)</code>)</li>
<li>session<br>
(<code>= tf.Session()</code>)</li>
</ul>

<p>I've tried using pickle which works on other objects like sklearn binarizers etc, but not on the above, for which I get the error at the bottom.</p>

<p>How I pickle:</p>

<pre><code>import pickle
with open(sModelSavePath, 'w') as fiModel:
    pickle.dump(dModel, fiModel)
</code></pre>

<p>where <code>dModel</code> is a dictionary that contains all the objects I want to persist, which I use for fitting against.</p>

<p>Any suggestions on how to pickle tensorflow objects?</p>

<p><strong>Error message</strong>:</p>

<pre><code>pickle.dump(dModel, fiModel)
...
    raise TypeError, "can't pickle %s objects" % base.__name__
TypeError: can't pickle module objects
</code></pre>