Skip to content

Commit

Permalink
Fix initialization of weight of Decoder (pytorch#775)
Browse files Browse the repository at this point in the history
`nn.init.zeros_(self.decoder)` throws this error `AttributeError: module 'torch.nn.init' has no attribute 'zero_'` because the weights weren't passed.
  • Loading branch information
manashmandal authored May 21, 2020
1 parent 22ee056 commit 4e9172b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion word_language_model/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def __init__(self, rnn_type, ntoken, ninp, nhid, nlayers, dropout=0.5, tie_weigh
def init_weights(self):
initrange = 0.1
nn.init.uniform_(self.encoder.weight, -initrange, initrange)
nn.init.zeros_(self.decoder)
nn.init.zeros_(self.decoder.weight)
nn.init.uniform_(self.decoder.weight, -initrange, initrange)

def forward(self, input, hidden):
Expand Down

0 comments on commit 4e9172b

Please sign in to comment.