import tensorflow as tf

# tensorflow中变量必须按如下述这样显示声明（name不必要）
state = tf.Variable(0,name='counter') 
one = tf.constant(1) # 声明常量


new_value = tf.add(state,one)
# 把new_value的值加载到state上
update = tf.assign(state,new_value)
init = tf.global_variables_initializer() # must have if define variable

with tf.Session() as sess:
    sess.run(init)
    for _ in range(3):
        sess.run(update)
        print(sess.run(state))
10fb0d23e34c7a3b5dadab6f134ca62d1504d30b
<mask token>

<mask token>
with tf.Session() as sess:
    sess.run(init)
    for _ in range(3):
        sess.run(update)
        print(sess.run(state))

<mask token>
state = tf.Variable(0, name='counter')
one = tf.constant(1)
new_value = tf.add(state, one)
update = tf.assign(state, new_value)
init = tf.global_variables_initializer()
with tf.Session() as sess:
    sess.run(init)
    for _ in range(3):
        sess.run(update)
        print(sess.run(state))

import tensorflow as tf
state = tf.Variable(0, name='counter')
one = tf.constant(1)
new_value = tf.add(state, one)
update = tf.assign(state, new_value)
init = tf.global_variables_initializer()
with tf.Session() as sess:
    sess.run(init)
    for _ in range(3):
        sess.run(update)
        print(sess.run(state))

import tensorflow as tf

# tensorflow中变量必须按如下述这样显示声明（name不必要）
state = tf.Variable(0,name='counter') 
one = tf.constant(1) # 声明常量


new_value = tf.add(state,one)
# 把new_value的值加载到state上
update = tf.assign(state,new_value)
init = tf.global_variables_initializer() # must have if define variable

with tf.Session() as sess:
    sess.run(init)
    for _ in range(3):
        sess.run(update)
        print(sess.run(state))