如何将tensorflow变量转换为python变量?

时间:2016-05-16 09:00:47

标签: python variables tensorflow

我有一个变量命名解码器。一开始它是一个python数组。然后将其分配给张量进行进一步计算,计算完成后,我想再次看到该数组的实际值。怎么可能?
通过撰写tf.Print(value)print(value),我得到如下内容:

<tf.Tensor 'decoder1:0' shape=(?,) dtype=int32>    

并且通过写tf.get_variable("decoder1:0",0)我在控制台上得到了这个:tensorflow.python.ops.variables.Variable object at 0x7fe5000deb50>

如何查看此变量的内部值?

P.S。我也看过SO中的其他帖子,例如:TensorFlow - get current value of a Variable等等,但没有人帮助过我。

提前致谢

1 个答案:

答案 0 :(得分:4)

您需要评估张量变量:

p_value = sess.run(value)

如果您有默认会话:

p_value = value.eval()