Skip to content

Instantly share code, notes, and snippets.

@kinoko3
Created April 14, 2018 08:02
Show Gist options
  • Save kinoko3/e968ece1a67e435378889b91829d8de6 to your computer and use it in GitHub Desktop.
Save kinoko3/e968ece1a67e435378889b91829d8de6 to your computer and use it in GitHub Desktop.
tensorflow study
import tensorflow as tf
state = tf.Variable(0, name='test') # 变量
one = tf.constant(1) # 张量
new_value = tf.add(state, one)
update = tf.assign(state, new_value) #更新 new_value 替换state
init = tf.global_variables_initializer()
with tf.Session() as sess:
sess.run(init)
for _ in range(3):
sess.run(update)
print(sess.run(state))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment