如何在TensorFlow急切执行模式下打印纯文本常量

时间:2019-03-08 14:06:13

标签: python tensorflow

我已经在tensorflow中初始化了一个常量:

hello = tf.constant('hello')

在正常模式下,print(sess.run(hello).decode())以恒定的张量输出纯文本。

但是在急切的执行模式下,上面的代码不起作用。

如何以恒定的Tensor问候打印纯文本?

此问题与python b'str'tf sess.run无关

1 个答案:

答案 0 :(得分:0)

将张量转换为numpy数组,然后解码

print(hello.numpy().decode())