在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

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

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