-
Notifications
You must be signed in to change notification settings - Fork 74k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updating ExponentialMovingAverage based on a condition #1724
Comments
Reproduced this. I'm compiling from source, commit b4b276e. Even more confusing to me:
results in
|
I think the dependencies set in a tf.cond() function are always getting executed. For example:
will output:
|
Interesting. This might imply that the |
Is there any update regarding this issue? |
@mikowals is correct, tf.cond() seems to be executing both fn1 and fn2 regardless of the condition. I have figured out a work around without using tf.train.ExponentialMovingAverage
Notice that now update becomes an assign_op that executes each time, however with a different value. Now I can execute the following with desired behavior
Which results in
|
There was an explanation / workaround posted to a issue #2062 a couple of days ago. The dependency node needs to be moved inside the conditional function. So an EMA update from this issues works as expected if the condition is done like this:
|
Thanks for adding a reference to issue #2062! I meant but forgot to do that. |
Using tensorflow 0.7.1.
I have followed issue #804 to make use of batch normalization with tensorflow. However, I struggle to get the snippet to work as expected and have nailed down the problem to something more concise.
Let us assume we want to perform a moving average over incoming scalars; sometimes we want to update the statistics of that moving average, sometimes we don't. We will model that with a placeholder
do_update
, which we can set toTrue
orFalse
in thefeed_dict
passed tosess.run(...)
. Basically, this is the code from #804 but greatly simplified.However, when I execute
run
updating will happen. It does not matter what the value ofdo_update
is.Curiously, if I remove the
tf.identity
above in the definition ofupdate
, neither of them performs an update after starting a new session.This seems as uninteded behaviour to me, but maybe I am missing something.
The text was updated successfully, but these errors were encountered: