我已经在张量中初始化了一个常数:
hello = tf.constant('hello')
在正常模式下,print(sess.run(hello).decode())
以常数张量输出纯文本。
在急切的执行模式下,上面的代码不起作用。
如何打印纯文本张张tensor hello?
这个问题不是关于Python b'str'或tf sess.run
将张量转换为numpy数组,然后解码
print(hello.numpy().decode())