Tensorflow会话运行中的批预测

2024-09-26 22:45:11 发布

您现在位置:Python中文网/ 问答频道 /正文

我对Tensorflow很陌生,我想知道当我加载一个冻结的图进行预测时,是否可以像keras一样进行批量预测。在

我的代码在Tensorflow中如下所示:

path='some_path.pb'
with dgraph.as_default():
     od_graph_def=tf.GraphDef()
     with tf.gfile.GFile(path,'rb') as fid:
          serialized_graph=fid.read()
          od_graph_def.ParseFromString(serialized_graph)
          tf.import_graph_def(od_graph_def,name='')
sess = tf.Session(graph=dgraph)   

feat_5=detection_graph.get_tensor_by_name('Relu6:0')
input=np.random.randn(100,300,300,3)

sess.run([feat_5],feed_dict={image_tensor: input}) **want to add batches of data here instead of input directly

Tags: pathnameinputtftensorflowdefaswith

热门问题