Reputation: 215
I have problem with following code:
v_background.assign(
tf.cond(tf.less(candidate_mse, mse),
lambda: resp,
lambda: v_background)
)
Basically what I want to happen is when candidate_mse is lower than old mse, v_background will be overridden with resp, otherwise it stays the same. Issue is when I call
v_background.eval()
it seems to have initial value regardless of mse.
print(mse.eval())
print(candidate_mse.eval())
Results with
0.0314396114956
0.031410553229
Upvotes: 0
Views: 66
Reputation: 4183
This creates the assignment operation, but doesn't actually run it. If you want to do one-time assignment, just run the operation.
assign_op = v_background.assign(
tf.cond(tf.less(candidate_mse, mse),
lambda: resp,
lambda: v_background)
)
sess.run(assign_op)
If you want a value that switches between the two depending on the values candidate_mse
and mse
, use tf.where
.
v_background = tf.where(tf.less(candidate_mse, mse), resp, v_background)
sess.run(v_background)
Upvotes: 1