tf.assign,tf.assign_add,tf.assign_sub

a = tf.Variable(0.0,dtype=tf.float32)
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
print(sess.run(a))
a = tf.assign(a,10)
print(sess.run(a))
a = tf.assign(a,20)
print(sess.run(a))
0.0
10.0
20.0

tf.assign,tf.assign_add,tf.assign_sub

tf.assign,tf.assign_add,tf.assign_sub

a = tf.Variable(1,dtype=tf.float32)
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
print(sess.run(a))
a = tf.assign_add(a,10)
print(sess.run(a))
a = tf.assign_sub(a,20)
print(sess.run(a))
1.0
11.0
1.0
上一篇:linux视频学习5(top, 网络监控


下一篇:Eclipse开发Web常见异常