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

Adding two numbers

We will look at an example of adding two numbers using TensorFlow. A placeholder is a node in a TensorFlow graph to which values can be passed during a session. A session is when the graph is initialized and ready to process the values:

  1. We will define two placeholders to take two integer values:
a = tf.Placeholder(tf.int32)b = tf.Placeholder(tf.int32)
  1. Add these two variables and store them in a variable:
c = a + b
Note that this operation is just defined and not yet executed.
  1. A dictionary of values is created to load to the placeholders. The keys are variables with placeholders themselves, as shown here:
values = {a: 5, b: 3}
  1. Create a session. Once a session is initialized, the graph is loaded into the memory and ...

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