After you train a model in Tensorflow:
There are two parts to the model, the model definition, saved by Supervisor
as graph.pbtxt
in the model directory and the numerical values of tensors, saved into checkpoint files like model.ckpt-1003418
.
The model definition can be restored using tf.import_graph_def
, and the weights are restored using Saver
.
However, Saver
uses special collection holding list of variables that's attached to the model Graph, and this collection is not initialized using import_graph_def, so you can't use the two together at the moment (it's on our roadmap to fix). For now, you have to use approach of Ryan Sepassi -- manually construct a graph with identical node names, and use Saver
to load the weights into it.
(Alternatively you could hack it by using by using import_graph_def
, creating variables manually, and using tf.add_to_collection(tf.GraphKeys.VARIABLES, variable)
for each variable, then using Saver
)