Skip to content

Batch normalization in training phase from Torch - #13497

Merged
opencv-pushbot merged 1 commit into
opencv:3.4from
dkurt:dnn_torch_bn_train
Dec 21, 2018
Merged

opencv-pushbot merged 1 commit into
opencv:3.4from
dkurt:dnn_torch_bn_train

Conversation

@dkurt

@dkurt dkurt commented Dec 21, 2018 •

Copy link
Copy Markdown
Member

This pullrequest changes

resolves http://answers.opencv.org/question/205633

Proposed to add an extra flag to readNetFromTorch to 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 train flag 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

@dkurt
dkurt force-pushed the dnn_torch_bn_train branch from b9ec137 to 840c892 Compare December 21, 2018 11:37

@alalek alalek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 👍

@opencv-pushbot
opencv-pushbot merged commit 840c892 into opencv:3.4 Dec 21, 2018
@alalek alalek mentioned this pull request Dec 21, 2018
@dkurt
dkurt deleted the dnn_torch_bn_train branch May 6, 2019 05:50
SavyaSanchi-Sharma pushed a commit to SavyaSanchi-Sharma/opencv that referenced this pull request Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants