I am using Tensorflow 0.8 with Python 3. I am trying to train the Neural Network, and the goal is to automatically export/import network states every 50 iteration. The problem is when I export the output tensor at the first iteration, the output tensor name is ['Neg:0', 'Slice:0']
, but when I export the output tensor at the second iteration, the output tensor name is changed as ['import/Neg:0', 'import/Slice:0']
, and importing this output tensor is not working then:
ValueError: Specified colocation to an op that does not exist during import: import/Variable in import/Variable/read
I wonder if anyone has ideas on this problem. Thanks!!!
That's how tf.import_graph_def
works.
If you don't want the prefix, just set the name
parameter to the empty string as showed in the following example.
# import the model into the current graph
with tf.Graph().as_default() as graph:
const_graph_def = tf.GraphDef()
with open(TRAINED_MODEL_FILENAME, 'rb') as saved_graph:
const_graph_def.ParseFromString(saved_graph.read())
# replace current graph with the saved graph def (and content)
# name="" is important because otherwise (with name=None)
# the graph definitions will be prefixed with import.
# eg: the defined operation FC2/unscaled_logits:0
# will be import/FC2/unscaled_logits:0
tf.import_graph_def(const_graph_def, name="")
[...]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With