-
Notifications
You must be signed in to change notification settings - Fork 19.5k
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
Static Learning Phase ignored on CNTK #9946
Conversation
thanks @datumbox to bring this up. It looks when I implemented the "learning_phase" in cntk_backend, my understanding is not accurate. Let me try to make sure I understand correctly now: In keras, "learning_phase" by default is a scalar placeholder which is an input of the graph. But if user call "set_learning_phase" with a given value, "learning_phase" will turn to a static flag. When create keras_train/test_function, if "learning_phase" is not integer (the default case), we will append the "learning_phase" flag to inputs. Is my understanding correct? If yes, I think I can wrapper this logic inside cntk_backend without impact keras layer. Let me try some experiment and come back later. one question: what will happened if user at beginning create some keras layer with default "learning_phase" setting (the dynamic one), then call "set_learning_phase" to make it static flag with other layers? is this a valid case? |
hey @souptc, thanks for having a look, much appreciated mate. I believe your description is accurate based on what I saw on the code of the other backends. I also see your point for when you switch from dynamic to static; effectively changing it like that can mess up the graph. I typically avoid switching around learning_phase while I'm in the middle of operations. |
Sounds good to me. This would be preferable. |
Agreed. :) @souptc could you please let me know when your PR is submitted? I have another PR that depends on fixing this issue. I'll also close this PR as soon as yours is merged. |
@fchollet quick question. What is the timeline for releasing the next Keras version? I'm working a change on the behaviour of BatchNormalization layer; the code is ready but I need to document the "what and why". Any clue when the next release will happen? To cut the long story short, my proposal is to make BN operate in test-mode when trainable = False. I'll follow up with theoretical explanations of why we want this, examples and a properly documented PR. |
Closing PR as @souptc's solution is more elegant and localized to the CNTK backend. |
While working on a bigger PR for the behaviour of Learning Phase on BatchNormalization, I noticed that there is a bug on the CNTK backend that affects how it handles static learning phases. It seems that when the user sets a static learning_phase, it is ignored. I believe the bigger PR requires building a case and thorough discussion, so I decided to split the changes into 2 parts (I will soon document the problem on BN and submit another PR).
What's the problem on CNTK:
isinstance(K.learning_phase(), int)
to decide if the learning phase is static.K.set_learning_phase(1)
it is ignored.Things to know about this PR: