February 2018
Intermediate to advanced
450 pages
11h 27m
English
Now that we are more familiar with the structure of data, we will take a look at how TensorFlow handles variables.
To define variables, we use the command tf.variable(). To be able to use variables in a computation graph, it is necessary to initialize them before running the graph in a session. This is done by running tf.global_variables_initializer().
To update the value of a variable, we simply run an assign operation that assigns a value to the variable:
state = tf.Variable(0)
Let's first create a simple counter, a variable that increases one unit at a time:
one = tf.constant(1)new_value = tf.add(state, one)update = tf.assign(state, new_value)
Variables must be initialized by running an initialization operation after having launched ...
Read now
Unlock full access