April 2017
Intermediate to advanced
320 pages
7h 46m
English
Variables are TensorFlow objects that hold and update parameters. A variable must be initialized; also you can save and restore it to analyze your code.
Variables are created by the tf.Variable() statement.
In the following example, we want to count the numbers from 1 to 10:
import tensorflow as tf
We create a variable that will be initialized to the scalar value 0:
value = tf.Variable(0,name="value")
The assign() and add() operators are just nodes of the computation graph so they do not execute the assignment until the session is run:
one = tf.constant(1) new_value = tf.add(value,one) update_value=tf.assign(value,new_value) initialize_var = tf.global_variables_initializer()
We can instantiate the computation graph:
with ...
Read now
Unlock full access