O'Reilly logo

Hands-On Natural Language Processing with Python by Rajalingappaa Shanmugamani, Rajesh Arumugam

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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. 

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required