qq_41457701 2023-01-17 17:30 采纳率: 30%
浏览 214
已结题

python输出Tensor具体值时占位符的赋值问题

想看一看算法中某一步的输出结果coefs,Tensor不能直接print,先采用的下图这种

img

后来报了个错

img

然后改成下图又出现了错误

img

img

这里feed给占位符的数据应该用什么呢,看第一个报错说的要用dtype float and shape [1,2708,1433],这种类型的数据怎么弄呢

谁能解决私我一下发代码看看吧/(ㄒoㄒ)/~~

  • 写回答

7条回答 默认 最新

  • 元气少女缘结神 2023-01-17 17:47
    关注

    伪代码如下:将shape为[shape_dim1,shape_dim2,shape_dim3,shape_dim4]的输入数据input_data传到模型input_name处,然后运行run,打印out_name处的输出:

    input_name=graph.get_tensor_by_name('input:xxx')
    out_name=graph.get_tensor_by_name('output:xxx')
    feed_dict={input_name:np.reshape(input_data,[shape_dim1,shape_dim2,shape_dim3,shape_dim4])}
    output=sess.run(out_name,feed_dict)
    print(output)
    
    
    评论 编辑记录

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 1月24日
  • 赞助了问题酬金50元 1月21日
  • 赞助了问题酬金50元 1月18日
  • 专家修改了标签 1月18日
  • 展开全部