3
我想添加一个分支到以前创建的张量流图。我是按照mrry对这个问题的回答(Tensorflow: How to replace a node in a calculation graph?)做的,我保存了新图的定义。合并张量流图时如何保留占位符名称?
当我导入新图并尝试获取原始图的占位符时,出现以下错误:ValueError: Requested return_element 'pool_3/_reshape:0' not found in graph_def.
,但代码在我使用原始图时正常工作。
我如何保持原来的占位符
我的代码引用合并这两个图是
with tf.Session() as sess:
# Get the b64_graph and its output tensor
resized_b64_tensor, = (tf.import_graph_def(b64_graph_def, name='',
return_elements=[B64_OUTPUT_TENSOR_NAME+":0"]))
with gfile.FastGFile(model_filename, 'rb') as f:
inception_graph_def = tf.GraphDef()
inception_graph_def.ParseFromString(f.read())
# Concatenate b64_graph and inception_graph
g_1 = tf.import_graph_def(inception_graph_def, name='graph_name',
input_map={RESIZED_INPUT_TENSOR_NAME : resized_b64_tensor})
# Save joined graph
joined_graph = sess.graph
with gfile.FastGFile(output_graph_filename, 'wb') as f:
f.write(joined_graph.as_graph_def().SerializeToString())
解决:我忘了“graph_name /”添加到张量名称的新图。现在它可以工作 – EffePi
你可以把问题标记为已回答吗? –