python – 在Tensorflow中打印张量的值

python – 在Tensorflow中打印张量的值,第1张

概述以下是我的完整代码的链接: https://github.com/roshanDD/YAD2K/blob/master/yad2k/models/keras_yolo.py#L253 我只想打印张量的值,称为true_areas.我运行了我的代码: sess = tf.InteractiveSession()true_areas = true_wh[..., 0] * true_wh[..., 以下是我的完整代码的链接:

https://github.com/roshanDD/YAD2K/blob/master/yad2k/models/keras_yolo.py#L253

我只想打印张量的值,称为true_areas.我运行了我的代码:

sess = tf.InteractiveSession()true_areas = true_wh[...,0] * true_wh[...,1]tf.Print(true_areas,[true_areas],message = "This is True Areas: ")b = tf.add(true_areas,true_areas).eval()

但它给了我错误:

Caused by op 'input_2',defined at:  file "learning.py",line 358,in <module>    _main(args)  file "learning.py",line 66,in _main    model_body,model = create_model(anchors,class_names)  file "learning.py",line 185,in create_model    Boxes_input = input(shape=(None,5))  file "/home/ubuntu/anaconda2/envs/py35/lib/python3.5/site-packages/keras/engine/topology.py",line 1388,in input    input_tensor=tensor)  file "/home/ubuntu/anaconda2/envs/py35/lib/python3.5/site-packages/keras/engine/topology.py",line 1299,in __init__    name=self.name)  file "/home/ubuntu/anaconda2/envs/py35/lib/python3.5/site-packages/keras/backend/tensorflow_backend.py",line 349,in placeholder    x = tf.placeholder(dtype,shape=shape,name=name)  file "/home/ubuntu/anaconda2/envs/py35/lib/python3.5/site-packages/tensorflow/python/ops/array_ops.py",line 1507,in placeholder    name=name)  file "/home/ubuntu/anaconda2/envs/py35/lib/python3.5/site-packages/tensorflow/python/ops/gen_array_ops.py",line 1997,in _placeholder    name=name)  file "/home/ubuntu/anaconda2/envs/py35/lib/python3.5/site-packages/tensorflow/python/framework/op_def_library.py",line 768,in apply_op    op_def=op_def)  file "/home/ubuntu/anaconda2/envs/py35/lib/python3.5/site-packages/tensorflow/python/framework/ops.py",line 2336,in create_op    original_op=self._default_original_op,op_def=op_def)  file "/home/ubuntu/anaconda2/envs/py35/lib/python3.5/site-packages/tensorflow/python/framework/ops.py",line 1228,in __init__    self._traceback = _extract_stack()InvalIDArgumentError (see above for traceback): You must Feed a value for placeholder tensor 'input_2' with dtype float     [[Node: input_2 = Placeholder[dtype=DT_float,shape=[],_device="/job:localhost/replica:0/task:0/cpu:0"]()]]

它正在谈论的占位符是什么?

解决方法 错误消息告诉您,您在代码中的某个位置定义了一个名为input_2的 tf.placeholder().

如果要评估依赖于此占位符的图形,则需要向此占位符提供feed值.它应该看起来像这样:

b = tf.add(true_areas,true_areas).eval({input_2: someinputValues})
总结

以上是内存溢出为你收集整理的python – 在Tensorflow中打印张量的值全部内容,希望文章能够帮你解决python – 在Tensorflow中打印张量的值所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1196314.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-03
下一篇 2022-06-03

发表评论

登录后才能评论

评论列表(0条)

保存