在TensorFlow中使用多个模型
我有一个模型可以检测多达10个数字,我使用相同的图形架构来检测4个字母。这意味着第一个模型有10个类,第二个模型有4个类。不幸的是,我在训练时使用了相同的变量名。 现在,我正在尝试制作一个代码,使用这两个模型来检测代码中给出的数字和字母在TensorFlow中使用多个模型,tensorflow,Tensorflow,我有一个模型可以检测多达10个数字,我使用相同的图形架构来检测4个字母。这意味着第一个模型有10个类,第二个模型有4个类。不幸的是,我在训练时使用了相同的变量名。 现在,我正在尝试制作一个代码,使用这两个模型来检测代码中给出的数字和字母 graph_1 = tf.Graph() with graph_1.as_default() as g_1: ...graph_1 content..... graph_2 = tf.Graph() with graph_2.as_
graph_1 = tf.Graph()
with graph_1.as_default() as g_1:
...graph_1 content.....
graph_2 = tf.Graph()
with graph_2.as_default() as g_2:
...graph_2 content.....
sess_1 = tf.InteractiveSession(graph = g_1)
sess_1.as_default()
....restoring model....
sess_2 = tf.InteractiveSession(graph = g_2)
sess_2.as_default()
....restoring model....
.
.
.
sess_1.run(prob, feed_dict)
sess_2.run(prob, feed_dict)
但现在,我知道这不是正确的方法。如果有人知道,请帮助我安排这个代码或分享一些有用的链接。
提前感谢。这里有一些建议:1)为不同的模型使用不同的变量范围。2) 您可能需要重新组织文件。具体来说,创建一个train.py文件来训练模型。3) 然后使用单个脚本调用每个模型并运行它。根据需要合并这些结果4)检查此链接以获得类似的答案: