Hello world!

Let's look at an example of Hello, world! using TensorFlow. We will go over this example directly in the Python shell:

  1. Enter the Python shell.
  2. Import TensorFlow with the following command:
>>>import tensorflow as tf
  1. TensorFlow can understand constants, variables, and operations, when defined with a tf base definition. Define a constant string as follows:
>>>hello_world = tf.constant("Hello, world!")
  1. Create a session:
>>>sess = tf.Session()
  1. Run the session:
>>>print(sess.run(hello_world))
  1. The output should be as follows:
Hello, world!

Congratulations! You have written your first program using TensorFlow. Next, we will introduce a few concepts for using TensorFlow. 

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset