0

I'm a Tensorflow beginner. I've tried to print Hello world using below Tensorflow 1.15.0 code.

import tensorflow as tf

h = tf.constant("Hello")
w = tf.constant(" World!")
hw = h + w

with tf.Session() as sess:
    ans = sess.run(hw)

    print(ans)

When I run the code using jupyter notebook, b'Hello World!' came out.

What I expected is only 'Hello World!". Why does the b come out in front of my output?

Many thank

Hume
  • 93
  • 7

1 Answers1

1

The b prefix indicates that it is a byte string and not unicode string. You can use tf.print() to print it properly

This question has already been answered here: The print of string constant is always attached with 'b' inTensorFlow