tensorflow的assgin方法

官网API是这么说的

This operation outputs a Tensor that holds the new value of 'ref' after the value has been assigned. This makes it easier to chain operations that need to use the reset value.

该操作输出一个tensor。当委派结束后,ref就会有新的值value。就是把value值赋值给ref

使用:

1     A = tf.Variable(tf.constant(0.0), dtype=tf.float32)
2     with tf.Session() as sess:
3         sess.run(tf.global_variables_initializer())
4         print(sess.run(A))
5         print(sess.run(tf.assign(A, 10)))
6         print(sess.run(A))

输出:

    

原文地址:https://www.cnblogs.com/demo-deng/p/10154502.html