Hello World in TensorFlow

Aptha Gowda

When I tried to run the hello world program in TensorFlow import tensorflow as tf hello = tf.constant('Hello, TensorFlow!') sess = tf.Session() print(sess.run(hello)) I am getting a different formate of output i.e

b'Hello, TensorFlow!'

but the actual output is

Hello, TensorFlow!

is it an error? or can I just ignore? TensorFlow documentation

Kenny Alvizuris

This has nothing to do with TensorFlow. What you are facing is a byte-literal

To quote the Python 2.x documentation:

A prefix of 'b' or 'B' is ignored in Python 2; it indicates that the literal should become a bytes literal in Python 3 (e.g. when code is automatically converted with 2to3). A 'u' or 'b' prefix may be followed by an 'r' prefix.

The Python 3.3 documentation states:

Bytes literals are always prefixed with 'b' or 'B'; they produce an instance of the bytes type instead of the str type. They may only contain ASCII characters; bytes with a numeric value of 128 or greater must be expressed with escapes.

I would also recommend reading the following Unicode HOWTO, this will clear a lot of possible doubts about printing, handling strings in Python.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related