Skip to content

Commit

Permalink
Fix model to be properly exported to ONNX (pytorch#1144)
Browse files Browse the repository at this point in the history
Co-authored-by: Brian Johnson <[email protected]>
  • Loading branch information
Thiago Crepaldi and brianjo authored Sep 15, 2020
1 parent fe33b54 commit ba6070e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions beginner_source/transformer_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ def init_weights(self):
self.decoder.weight.data.uniform_(-initrange, initrange)

def forward(self, src):
if self.src_mask is None or self.src_mask.size(0) != len(src):
if self.src_mask is None or self.src_mask.size(0) != src.size(0):
device = src.device
mask = self._generate_square_subsequent_mask(len(src)).to(device)
mask = self._generate_square_subsequent_mask(src.size(0)).to(device)
self.src_mask = mask

src = self.encoder(src) * math.sqrt(self.ninp)
Expand Down

0 comments on commit ba6070e

Please sign in to comment.