-
Notifications
You must be signed in to change notification settings - Fork 18.6k
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
batch_norm layer isn't affected by the updated phase (train/test) #5045
Comments
This is the behavior when It sounds like dynamically changing the phase is not supported and generally should not be done. You can create a training network and testing network and share the weights (https://groups.google.com/d/msg/caffe-users/pjqs-DE0eWw/VrM-dFvZLNMJ):
Quotes from the Caffe Canon* (#192):
and (#1250):
Caffe Canon - is the standard collection of texts in the BVLC tradition that can be ascribed to the original BVLC members, as recorded by the Octocat. |
Thanks a lot ! |
@williford thanks for helping to collect and share the lore ☕ |
Issue summary
The parameter use_global_stats_ in batch_norm layer is defined automatically in layer setup, based on the current phase (train/test). see batch_norm_layer.cpp line 14 (false for train phase, true for test phase).
However the layer phase is dynamic and can be changed during train/test iterations.
For that reason, the correct behavior is to change use_global_stats_ value in forward & backward methods (based on the current phase_ value) instead of doing it only once in setup method.
This behavior is similar to what is done in dropout layer, which acts differently in train/test phase.
I will explain why this issue bothers me :
In my application, i use one prototxt network definition file and all layers are initialized in train mode. When i change the network phase from train the test i expect all layers to act respectively. However, the batch_norm layer doesn't change use_global_stats_ from false to true, so actually continue to act like it's in train phase.
The text was updated successfully, but these errors were encountered: