Skip to content

Commit

Permalink
protect against _valid_batch_iter returning an empty batch
Browse files Browse the repository at this point in the history
  • Loading branch information
gooofy committed Jul 28, 2019
1 parent 33e561f commit 27ea69e
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lm/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ def get_valid_loss():
with torch.no_grad():
for ctx in _valid_batch_iter(
valid_dataset, batch_size=batch_size, n_ctx=n_ctx):
if not ctx:
continue
ctx = torch.LongTensor(ctx).to(device)
logits = model(ctx)['logits']
loss = loss_fn(logits, ctx)
Expand Down

0 comments on commit 27ea69e

Please sign in to comment.