tf.Variable class creates a tensor with an initial value that can be modified, much like a normal Python variable. This tensor stores its state in the session, so you must initialize the state of the tensor manually.
We use the
tf.global_variables_initializer() function to initialize the state of all the Variable tensors.
init = tf.global_variables_initializer() with tf.Session() as sess: sess.run(init)
tf.global_variables_initializer() call returns an operation that will initialize all TensorFlow variables from the graph. You call the operation using a session to initialize all the variables as shown above.