Repository navigation
Batch normalization in training phase from Torch - #13497
Merged
Merged
Conversation
dkurt
force-pushed
the
dnn_torch_bn_train
branch
from
December 21, 2018 11:37
b9ec137 to
840c892
Compare
opencv-pushbot
pushed a commit
that referenced
this pull request
Dec 21, 2018
Merged
SavyaSanchi-Sharma
pushed a commit
to SavyaSanchi-Sharma/opencv
that referenced
this pull request
Jul 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pullrequest changes
resolves http://answers.opencv.org/question/205633
Proposed to add an extra flag to
readNetFromTorchto specify learning/testing phase.Torch networks can be serialized in train (
net:training()) or in evaluation (net:evaluate()) phases. Depends on it, layers such Batch Normalization work in a different way. OpenCV loads networks in evaluation mode by default but there are test cases when training phase of Batch Norm is used to deploy the model (see the question at forum).However we cannot rely only on
trainflag of Batch Norm layer from Torch because some of public models are serialized in training phase (perhaps their authors forgot to switch it). So to keep compatibility with existing models we can specify this phase manually.Merge with extra: opencv/opencv_extra#563