Add Method

import tensorflow as tf

import os

# Just disables the warning, doesn't enable AVX/FMA
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
a = tf.Variable(0)
b = tf.constant(1)
c = tf.add(a, b)
c
<tf.Tensor 'Add_2:0' shape=() dtype=int32>
# assign the new value to a
update = tf.assign(a, c)
a
<tf.Variable 'Variable_4:0' shape=() dtype=int32_ref>
# You can't change the constant by using assign. 
# Initialize global variables

init_op = tf.global_variables_initializer()
session = tf.Session()
session.run(init_op)
print(session.run(a))
0
session.run(update)
1
session.run(a)
1
for _ in range(4):
    session.run(update)
    print(session.run(a))
2
3
4
5
session.close()