我试图在python中为tensorflow变量赋一个新值.
import tensorflow as tf
import numpy as np
x = tf.Variable(0)
init = tf.initialize_all_variables()
sess = tf.InteractiveSession()
sess.run(init)
print(x.eval())
x.assign(1)
print(x.eval())
Run Code Online (Sandbox Code Playgroud)
但我得到的输出是
0
0
Run Code Online (Sandbox Code Playgroud)
所以价值没有改变.我错过了什么?
python variable-assignment neural-network deep-learning tensorflow