TensorFlow programming model

The TensorFlow programming model signifies how to structure your predictive models. A TensorFlow program is generally divided into four phases once you have imported TensorFlow library for associated resources:

  1. Construction of the computational graph that involves some operations on tensors (we will see what is a tensor soon)
  2. Create a session
  3. Running a session, that is performed for the operations defined in the graph
  4. Computation for data collection and analysis

These main steps define the programming model in TensorFlow. Consider the following example, in which we want to multiply two numbers:

import tensorflow as tf x = tf.constant(8) y = tf.constant(9) z = tf.multiply(x, y) sess = tf.Session() out_z = sess.run(z) Finally, ...

Get Predictive Analytics with TensorFlow now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.