Skip to content
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 normalization in training phase from Torch #13497

Merged
merged 1 commit into from Dec 21, 2018

Conversation

@dkurt
Copy link
Member

dkurt commented Dec 21, 2018

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 dkurt:dnn_torch_bn_train branch from b9ec137 to 840c892 Dec 21, 2018
@alalek
alalek approved these changes Dec 21, 2018
Copy link
Contributor

alalek left a comment

Looks good to me 👍

@alalek alalek added this to the 3.4.5 milestone Dec 21, 2018
@alalek alalek added the bug label Dec 21, 2018
@alalek alalek self-assigned this Dec 21, 2018
@opencv-pushbot opencv-pushbot merged commit 840c892 into opencv:3.4 Dec 21, 2018
1 check passed
1 check passed
default Required builds passed
Details
@alalek alalek mentioned this pull request Dec 21, 2018
@dkurt dkurt deleted the dkurt:dnn_torch_bn_train branch May 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants
You can’t perform that action at this time.