From 02bdebf45ff3a96c5189279f09dc9e73ceee58de Mon Sep 17 00:00:00 2001 From: jzhou316 <31744226+jzhou316@users.noreply.github.com> Date: Wed, 20 Feb 2019 22:52:44 -0500 Subject: [PATCH] Update operations.py Not putting all tensor to gpu will cause an error. --- src/utils/operations.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/operations.py b/src/utils/operations.py index d485aa8..5d08578 100644 --- a/src/utils/operations.py +++ b/src/utils/operations.py @@ -66,7 +66,7 @@ def masked_nllloss(logprobs, target, lengths, device): return ( (loss_raw * device( Variable(loss_mask.view(-1)))).sum() - / loss_mask.sum() + / device(loss_mask).sum() )