Restoring graph in tensorflow fails because there is no variable to save
The list of variables is saved in a Collection
which is not saved in the GraphDef
. Saver
by default uses the list in ops.GraphKeys.VARIABLES
collection (accessible through tf.all_variables()
), and if you restored from GraphDef
rather than using Python API to build your model, that collection is empty. You could specify the list of variables manually in tf.train.Saver(var_list=['MyVariable1:0', 'MyVariable2:0',...])
.
Alternatively instead of GraphDef
you could use MetaGraphDef
which saves collections, there's a recently added MetaGraphDef HowTo