Skip to content

Commit dfa4c26

Browse files
Typo and fix the input of labels to cross_entropy (huggingface#7841)
The current version caused some errors. The changes fixed it for me. Hope this is helpful!
1 parent a5a8eeb commit dfa4c26

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

docs/source/training.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ The following is equivalent to the previous example:
109109
.. code-block:: python
110110
111111
from torch.nn import functional as F
112-
labels = torch.tensor([1,0]).unsqueeze(0)
112+
labels = torch.tensor([1,0])
113113
outputs = model(input_ids, attention_mask=attention_mask)
114-
loss = F.cross_entropy(labels, outputs.logitd)
114+
loss = F.cross_entropy(outputs.logits, labels)
115115
loss.backward()
116116
optimizer.step()
117117

0 commit comments

Comments
 (0)