Jacob Stern
Jacob Stern

Reputation: 4597

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()

Upvotes: 14

Views: 7569

Answers (1)

Jacob Stern
Jacob Stern

Reputation: 4597

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

Upvotes: 41

Related Questions