Python Tensorflow初始化滞后

Python Tensorflow初始化滞后,python,tensorflow,Python,Tensorflow,试图使用经过训练的模型进行预测,初始化会话似乎需要一段时间。有没有一种从命令行获取模型预测的快速方法 import tensorflow as tf import time graph = tf.Graph() with graph.as_default(): t0 = time.time()

试图使用经过训练的模型进行预测,初始化会话似乎需要一段时间。有没有一种从命令行获取模型预测的快速方法

import tensorflow as tf
import time

graph = tf.Graph()                                                    
with graph.as_default():
    t0 = time.time()                                                                                                 
    sess = tf.Session()                                                                                              
    t1 = time.time()                                                                                                 
print('time: %s ' % (t1-t0))                                                                                                     

>>> time: 11.136097192764282

使用冻结的protobuf模型-

使用冻结的protobuf模型-

您是否编写了上面的代码tf。初始化所有变量()?不,添加它会引发错误“对象从未使用过”您可以粘贴所有代码吗?这就是我花费的所有时间:0.0029993057250976562您是否编写了上面的代码tf。初始化所有变量()?不,添加它会引发一个错误“Object was never used”你能粘贴你所有的代码吗?这就是我花费的时间:0.0029993057250976562