Reputation: 21
I am beginner in tensorflow and I have run into a problem: how to manually change Variable? More precisely, I want to add some noise to my Weights tensor, see how good it does, and based on that, apply/ignore the change.
W = tf.Variable(tf.randomNormal([xsize,ysize]))
TempW = W + tf.randomNormal([xsize,ysize])
compute = x*TempW
#initialize, run the computation etc.
# how can I make W = TempW now?
Upvotes: 1
Views: 1358
Reputation: 21
After kratenko pointed it out, I figured that there are methods like
tf.Variable.assign(value)
tf.Variable.assign_add(value)
tf.Variable.assign_subtract(value)
In my case, usage was:
#initialisation
apply = W.assign(TempW)
#usage
sess.run(apply)
So if anyone also skipped these ones in docs, I hope it helps.
Upvotes: 1