在TensorFlow中加载多个DNN模型并多次使用它们

我有两个Inception-v3模型的检查点文件(.data, .index, .meta 文件)

我想在程序开始时将它们都加载到内存中,并在while循环中同时使用它们。

load model1load model2while True :    predict output from model1    predict output from model2

我遇到的问题是因为我对两个变量使用了同一个图(graph)。我已经添加了一个解决此问题的答案。


回答:

以下是我用来解决这个问题的代码。

turn_graph = tf.Graph()posn_graph = tf.Graph()with turn_graph.as_default():    from models import inception_v3 as googlenet    turn_model = googlenet(227,227,3,1.0e-3,output=4)    turn_model.load('turn_model_01')with posn_graph.as_default():    from models import inception_v3 as googlenet    posn_model = googlenet(227,227,3,1.0e-3,output=4)    posn_model.load('posn_model_01')## 其他代码while True :    posn_model.predict([image])    turn_model.predict([image])

Related Posts

Keras Dense层输入未被展平

这是我的测试代码: from keras import…

无法将分类变量输入随机森林

我有10个分类变量和3个数值变量。我在分割后直接将它们…

如何在Keras中对每个输出应用Sigmoid函数?

这是我代码的一部分。 model = Sequenti…

如何选择类概率的最佳阈值?

我的神经网络输出是一个用于多标签分类的预测类概率表: …

在Keras中使用深度学习得到不同的结果

我按照一个教程使用Keras中的深度神经网络进行文本分…

‘MatMul’操作的输入’b’类型为float32,与参数’a’的类型float64不匹配

我写了一个简单的TensorFlow代码,但不断遇到T…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注