Skip to content

Commit 8bc54e2

Browse files
committed
Match BVLC GoogLeNet zero initialization of classifier
1 parent 2c8caab commit 8bc54e2

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

torchvision/models/googlenet.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@ def __init__(self, num_classes=1000, aux_logits=True, batch_norm=False):
7979
if m.bias is not None:
8080
nn.init.constant_(m.bias, 0.2)
8181

82+
# zero init classifier
83+
for m in self.modules():
84+
if isinstance(m, InceptionAux):
85+
nn.init.zeros_(m.fc2.bias)
86+
elif m == self.fc:
87+
nn.init.zeros_(m.bias)
88+
8289
def forward(self, x):
8390
x = self.conv1(x)
8491
x = self.maxpool1(x)

0 commit comments

Comments
 (0)