Да, это абсолютно возможно, но вы делаете это неправильно. Не определяйте две модели в двух отдельных графиках, просто загрузите их в один и тот же (и добавьте надлежащие области имен, чтобы избежать конфликтов имен):
graph = tf.Graph() # just one graph, with both models loaded
with graph.as_default():
od_graph_def = tf.GraphDef()
with tf.gfile.GFile(PATH_TO_FROZEN_GRAPH1, 'rb') as fid:
serialized_graph = fid.read()
od_graph_def.ParseFromString(serialized_graph)
tf.import_graph_def(od_graph_def, name='first_graph')
with tf.gfile.GFile(PATH_TO_FROZEN_GRAPH2, 'rb') as fid:
serialized_graph = fid.read()
od_graph_def.ParseFromString(serialized_graph)
tf.import_graph_def(od_graph_def, name='second_graph')
# [...] get the correct input and output tensors for the two graphs via their names
with tf.Session(graph=graph) as sess: # just one session
# Running only one of the two at a time
res_1 = sess.run(outputs_from_graph_1, feed_dict=graph_1_feeds)
res_2 = sess.run(outputs_from_graph_2, feed_dict=graph_2_feeds)
# Actually running them in parallel (might not fit in memory!)
res_1_and_2 = sess.run( outputs_from_graph_1 + outputs_from_graph_2, {**graph_1_feeds, **graph_2_feeds} )
Примечание : I ' м при условии, что каналы dict
с tensor_name:values
или placeholder_tensor:values
пара ключ / значение