卷积神经网络 - 如何在同一图像上使用两个cnn模型

时间:2017-07-09 15:13:29

标签: python-2.7 tensorflow deep-learning keras

我想在同一张图片上使用两个不同训练的CNN(卷积神经网络)模块。我训练了两个模块,1个用于检测,1个用于分类。现在,我想在同一图像上使用这两个模块。代码在python中使用keras和tensorflow库。 Two different CNN on the same image

1 个答案:

答案 0 :(得分:0)

在tensorflow中,您需要为两个模型明确指定the computational graph

# build two separate graphs `g1` and `g2`

tf.reset_default_graph()
with tf.Session(graph=g1) as session:
    result = sess.run(detect, feed_dict={x: test_x})
    print(result)

tf.reset_default_graph()
with tf.Session(graph=g2) as session:
    result = sess.run(recognize, feed_dict={x: test_x})
    print(result)

在一个应用程序中构建多个图表时,还有一些注意事项,请参阅this question