Open
Description
🐛 Describe the bug
The doc of nn.CrossEntropyLoss()
says that target
argument with class probabilities should be between [0, 1]
as shown below:
Target
: ... If containing class probabilities, same shape as the input and each value should be between[0,1]
.
But setting the tensor of the values out of [0,1]
to target
argument with class probabilities works against the doc above as shown below:
import torch
input = torch.tensor([[0.4, 0.8, 0.6], [0.3, 0.0, 0.5]])
target = torch.tensor([[6.2, -7.9, 3.4], [2.1, 8.6, -12.5]]) # Here
cel = nn.CrossEntropyLoss()
cel(input=input, target=target) # tensor(3.9178)
Versions
import torch
torch.__version__ # 2.4.0+cu121
cc @svekars @sekyondaMeta @AlannaBurke @brycebortree @tstatler