1

I have initialized a constant in tensorflow:

hello = tf.constant('hello')

In normal mode, print(sess.run(hello).decode()) outputs the plain text in a constant Tensor.

In eager execution mode however, the code above does not work.

How can I print the plain text in constant Tensor hello?

This question is NOT about python b'str' or tf sess.run

kalehmann
  • 4,821
  • 6
  • 26
  • 36
  • @ShubhamPanchal `print( hello )` gives 'tf.Tensor(b'hello', shape=(), dtype=string)', I want just 'hello' part –  Mar 08 '19 at 16:13

1 Answers1

1

convert tensor to numpy array and then decode

print(hello.numpy().decode())
Siva-Sg
  • 2,741
  • 19
  • 27