Skip to content

Commit 1b21b89

Browse files
author
Mofan Zhou
committed
create tensorflow7
1 parent b5e2680 commit 1b21b89

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎tensorflow/tensorflow7_variable.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import tensorflow as tf
2+
3+
state = tf.Variable(0, name='counter')
4+
one = tf.constant(1)
5+
6+
new_value = tf.add(state, one)
7+
update = tf.assign(state, new_value)
8+
9+
init = tf.initialize_all_variables() # must have
10+
11+
with tf.Session() as sess:
12+
sess.run(init) # run and activate
13+
for _ in range(3):
14+
sess.run(update)
15+
print(sess.run(state))

0 commit comments

Comments
 (0)