Skip to content

Commit

Permalink
Handle tied + dimensions mismatch (pytorch#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
nadavbh12 authored and soumith committed Apr 3, 2017
1 parent 18df41e commit f2a771a
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions word_language_model/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ def __init__(self, rnn_type, ntoken, ninp, nhid, nlayers, dropout=0.5, tie_weigh
# "Tying Word Vectors and Word Classifiers: A Loss Framework for Language Modeling" (Inan et al. 2016)
# https://arxiv.org/abs/1611.01462
if tie_weights:
if nhid != ninp:
raise ValueError('When using the tied flag, nhid must be equal to emsize')
self.decoder.weight = self.encoder.weight

self.init_weights()
Expand Down

0 comments on commit f2a771a

Please sign in to comment.