KeyError: "The name 'DecodeJpg/contents:0' refers to a Tensor which does not exist. The operation, '

利用inceptionv3网络模型训练自己的图片时这段代码一直报错

#载入图片
image_data = tf.gfile.FastGFile(os.path.join(root, file), 'rb').read()
graph = tf.get_default_graph()

data_tensor = graph.get_tensor_by_name('DecodeJpg/contents:0')
predictions = sess.run(softmax_tensor, {data_tensor: image_data})#图片格式是jpg格式
predictions = np.squeeze(predictions)#把结果转为1维数据

这句报错意思是不存在DecodeJpg/contents这个参数,Stackoverflow网站上有个人说了解决办法

https://stackoverflow.com/questions/49166819/keyerror-the-tensor-variable-refer-to-the-tensor-which-does-not-exists

for op in graph.get_operations():
    print(op.name)

这段输出自己的参数,把参数名字改对就可以了

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值