【Python】tf.assign的用法

tf.assign(A, new_number): 这个函数的功能主要是把A的值变为new_number

例如:

  1. import tensorflow as tf;

  2.  
  3. A = tf.Variable(tf.constant(0.0), dtype=tf.float32)

  4. with tf.Session() as sess:

  5. sess.run(tf.initialize_all_variables())

  6. print sess.run(A)

  7. sess.run(tf.assign(A, 10))

  8. print sess.run(A)

输出:

0.0
10.0

开始给A赋值为0,经过tf.assign函数后,把A的值变为10

https://blog.csdn.net/uestc_c2_403/article/details/72235310?utm_source=copy

猜你喜欢

转载自blog.csdn.net/qq_37701443/article/details/82882919