Skip to content

Commit

Permalink
using fan_out in kaiming init and pass loss to device
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikronic committed Jun 9, 2019
1 parent e26cb0b commit 51a57ca
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Train.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def init_weights(m):
"""

if isinstance(m, nn.Conv2d) or isinstance(m, nn.ConvTranspose2d):
torch.nn.init.kaiming_normal_(m.weight, mode='fan_in')
torch.nn.init.kaiming_normal_(m.weight, mode='fan_out')
m.bias.data.fill_(0.0)
elif isinstance(m, nn.BatchNorm2d): # reference: https://github.com/pytorch/pytorch/issues/12259
nn.init.constant_(m.weight, 1)
Expand Down Expand Up @@ -173,7 +173,7 @@ def show_batch_image(image_batch):


# %% run model
criterion = EdgeLoss()
criterion = EdgeLoss().to(device)
edgenet = EdgeNet().to(device)
optimizer = optim.Adam(edgenet.parameters(), lr=args.lr)
edgenet.apply(init_weights)
Expand Down

0 comments on commit 51a57ca

Please sign in to comment.