Switch to loss .item(
@@ -99,7 +99,7 @@ class DocReaderModel(object):
# Compute loss and accuracies
loss = F.nll_loss(score_s, target_s) + F.nll_loss(score_e, target_e)
- self.train_loss.update(loss.data[0], ex[0].size(0))
+ self.train_loss.update(loss.data.item(), ex[0].size(0))
# Clear gradients and run backward
self.optimizer.zero_grad()
