首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >inception_v2_resnet推理

inception_v2_resnet推理
EN

Stack Overflow用户
提问于 2016-10-12 15:47:21
回答 1查看 881关注 0票数 1

关于这一职位:

v2与Tensorflow

我也尝试使用inception_resnet_v2模型来获得图像的预测。因此,我查看了这个片段,并试图让它运行,但它说"input_tensor“是没有定义的。在提到的代码中有没有遗漏什么,或者有人能给我一些提示让它运行/如何定义input_tensor变量?

这里又是一个片段:

代码语言:javascript
复制
import tensorflow as tf
slim = tf.contrib.slim
from PIL import Image
from inception_resnet_v2 import *
import numpy as np

checkpoint_file = 'inception_resnet_v2_2016_08_30.ckpt'
sample_images = ['dog.jpg', 'panda.jpg']
#Load the model
sess = tf.Session()
arg_scope = inception_resnet_v2_arg_scope()
with slim.arg_scope(arg_scope):
  logits, end_points = inception_resnet_v2(input_tensor, is_training=False)
saver = tf.train.Saver()
saver.restore(sess, checkpoint_file)
for image in sample_images:
  im = Image.open(image).resize((299,299))
  im = np.array(im)
  im = im.reshape(-1,299,299,3)
  predict_values, logit_values = sess.run([end_points['Predictions'],logits], feed_dict={input_tensor: im})
  print (np.max(predict_values), np.max(logit_values))
  print (np.argmax(predict_values), np.argmax(logit_values))

谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-10-12 18:50:39

代码片段似乎缺乏对input_tensor的任何定义。查看定义inception_resnet_v2()函数,张量在feed_dict中使用的事实,以及图像大小为299x299的事实,您可以定义input_tensor如下:

代码语言:javascript
复制
input_tensor = tf.placeholder(tf.float32, [None, 299, 299, 3])
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40002908

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档