Skip to content

Commit

Permalink
Match BVLC GoogLeNet zero initialization of classifier
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCodez committed Jan 9, 2019
1 parent 2c8caab commit 8bc54e2
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions torchvision/models/googlenet.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ def __init__(self, num_classes=1000, aux_logits=True, batch_norm=False):
if m.bias is not None:
nn.init.constant_(m.bias, 0.2)

# zero init classifier
for m in self.modules():
if isinstance(m, InceptionAux):
nn.init.zeros_(m.fc2.bias)
elif m == self.fc:
nn.init.zeros_(m.bias)

def forward(self, x):
x = self.conv1(x)
x = self.maxpool1(x)
Expand Down

0 comments on commit 8bc54e2

Please sign in to comment.