我有两个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])