【问题标题】:TensorFlow and print [duplicate]TensorFlow 和打印 [重复]
【发布时间】:2016-10-03 20:27:54
【问题描述】:

我正在学习 Tensorflow 的教程。

我想使用print显示变量Wb的值,它们分别是权重和偏差以及占位符xy

可以显示吗?

print x,y,b,W

我目前看到的如下

Tensor("Placeholder:0", shape=TensorShape([Dimension(None), Dimension(784)]), dtype=float32)
Tensor("Softmax:0", shape=TensorShape([Dimension(None), Dimension(10)]), dtype=float32)
tensorflow.python.ops.variables.Variable object at 0x1006b0b90>
tensorflow.python.ops.variables.Variable object at 0x101b76410>

【问题讨论】:

    标签: python tensorflow


    【解决方案1】:

    您有 3 个选项:

    1. 使用tf.Print 这是一个身份操作,在评估时会打印数据。
    2. 手动评估变量:

      print x.eval(), y.eval(), b.eval() , W.eval()

    3. 在单个调用中手动评估变量:假设 sess 为当前的 tf.Session 变量

      print sess.run([x,y,b,W])

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-08-25
      • 2023-04-02
      • 2012-05-28
      • 2013-03-31
      • 2018-04-22
      • 1970-01-01
      • 2016-05-24
      相关资源
      最近更新 更多