Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AttributeError: 'Tensor' has no attribute: 'backwards'

I'm posting this question for those who made the same error I did. I got this error when trying to compute my gradients:

criterion = torch.nn.CrossEntropyLoss()
loss = criterion(y_hat, y_truth)
loss.backwards()
like image 574
Jacob Stern Avatar asked Oct 15 '18 12:10

Jacob Stern


1 Answers

It's loss.backward(), not loss.backwards().

like image 76
Jacob Stern Avatar answered Oct 19 '22 23:10

Jacob Stern