Forcing Dependence On A Variable Update
Say I have some function f of variable x: x = tf.Variable(1.0) fx = x*x and an op which updates x: new_x = x.assign(2.0) and I want to get the value of f resulting from the updat
Solution 1:
The with tf.control_dependencies([op])
block enforces control dependency on op
to other ops created within with block. In your case, x*x
is created outside, and the tf.identity
just gets the old value. Here is what you want :
with tf.control_dependencies([new_x,]):
new_fx = x*x
Post a Comment for "Forcing Dependence On A Variable Update"