我已经在tensorflow中初始化了一个常量:
hello = tf.constant('hello')
在正常模式下,print(sess.run(hello).decode())
以恒定的张量输出纯文本。
但是在急切的执行模式下,上面的代码不起作用。
如何以恒定的Tensor问候打印纯文本?
此问题与python b'str'或tf sess.run无关
答案 0 :(得分:0)
将张量转换为numpy数组,然后解码
print(hello.numpy().decode())