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

Fixed error when first inplace ReLU from first middle ResBlock appears on the main data propagation path #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Apich238
Copy link

First, I tried to create IResNet 50, save it in ONNX and view in Netron. This is what I saw:
image
According to paper, ReLUs on the main information propagation path have to appear only at the end of stages. But in fact, they also appear at the first middle ResBlock.

The problem source I found is the following lines:
self.relu = nn.ReLU(inplace=True) in __init__ of BasicBlock and Bottleneck, and
out = self.relu(x) in following forward method.
Inplace ReLU modifies tensor in place, and after second line out and x refer to the same object and both equal ReLU(x). As the result, identity equals to ReLU(x) instead of x.

To fix issue, I deleted inplace=True in classes where line out = self.relu(x) appears. Now Netron diagram for ResNet50 more corresponds paper:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant