Updating Variable State

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, name = 'counter')

b = tf.add(a, tf.constant(2))

# update a with b value (which means a+1)
update = tf.assign(a, b)
with tf.Session() as sess:
        sess.run(tf.initialize_all_variables())

        print(sess.run(a))

        for _ in range(3):
            sess.run(update)
            print(sess.run(a))
0
2
4
6