Tensorflow 0.8进出口产出张量问题 [英] Tensorflow 0.8 Import and Export output tensors problems
问题描述
['Neg:0','Slice:0']
,但是当我导出输出张量在第二次迭代时,输出张量名称更改为 ['import / Neg:0','import / Slice:0']
,并导入此输出张量不起作用: ValueError:指定在导入期间不存在的op的托管:import /导入/变量/读
我想知道有没有人有这个问题的想法。谢谢!!!
这就是 tf.import_graph_def
的作品。 / p>
如果您不想要前缀,只需将名称
参数设置为空字符串,如下所示将模型导入到当前图形
中,将tf.Graph()。as_default()作为图形导入到
const_graph_def = tf.GraphDef()
with open(TRAINED_MODEL_FILENAME,'rb')as saved_graph:
const_graph_def.ParseFromString(saved_graph.read())
#替换当前图形与保存的图形def(和内容)
#name =是重要的,因为否则(name = None)
#图形定义将以前缀作为前缀。
#eg:定义的操作FC2 / unscaled_logits:0
#将导入/ FC2 / unscaled_logits:0
tf.import_graph_def(const_graph_def,name =)
[。 ..]
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="")
[...]
这篇关于Tensorflow 0.8进出口产出张量问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!