Skip to content

Instantly share code, notes, and snippets.

@shuuchen
Created July 30, 2020 10:34
Show Gist options
  • Save shuuchen/e2190910ca7981acc9843a2ed361efab to your computer and use it in GitHub Desktop.
Save shuuchen/e2190910ca7981acc9843a2ed361efab to your computer and use it in GitHub Desktop.
# inside a class __init__ function
for m in self.modules():
if isinstance(m, nn.Conv2d):
nn.init.normal_(m.weight, std=0.001)
elif isinstance(m, nn.BatchNorm2d):
nn.init.constant_(m.weight, 1)
nn.init.constant_(m.bias, 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment