Declaring Operations

Now we must learn about the other operations we can add to a TensorFlow graph.

Getting ready

Besides the standard arithmetic operations, TensorFlow provides us with more operations that we should be aware of. We need to know how to use them before proceeding. Again, we can create a graph session by running the following code:

import tensorflow as tf
sess = tf.Session()

How to do it…

TensorFlow has the standard operations on tensors: add(), sub(), mul(), and div(). Note that all of these operations in this section will evaluate the inputs element-wise unless specified otherwise:

  1. TensorFlow provides some variations of div() and relevant functions.
  2. It is worth mentioning that div() returns the same type as the inputs. This means it ...

Get TensorFlow Machine Learning Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.