1

I've recently installed tensorflow into my Conda: while running following code it gives me an additional 'b'. I don't know the reason for that 'b'..? Why is it being printed and how to get rid of it? This program is running in Tensorflow environment implemented in Jupyter NoteBook

import tesnorflow as tf
msg_1 = tf.constant('Welcome to TensorFlow')
with tf.Session() as s:
    print(s.sub(msg_1))

results in

b'Welcome to TensorFlow'

See also here

1 Answers1

0

Tensorflow represents strings as Bytes objects. This 'b' is Python's way of marking Bytes objects. You can convert the Bytes object returned by session.run() to a regular python string by applying .decode():

print(s.run(msg_1).decode('UTF-8'))
Trisoloriansunscreen
  • 1,543
  • 1
  • 15
  • 27