Python 如何在tensorflow执行模式下打印纯文本常量

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

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

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

然而,在急切执行模式下,上面的代码不起作用

如何以常量张量hello打印纯文本


这个问题不是关于或

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

print(hello.numpy().decode())
@ShubhamPanchal
print(hello)
给出了“tf.Tensor(b'hello',shape=(),dtype=string)”,我只想要“hello”部分