BUG
RuntimeError when using Cross_entropy loss function: multi-target not supported at ...
potential problem
1) which labels must be 0 ~ n-1, and must be of a dimension, if the label is set [nxl], the above error can also occur.
2) Print Label y:
tensor([[1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0]], device='cuda:0')
For n.CrossEntroyLoss, the goal must be the interval [0, # class] single number, rather than a heat-coded target vector. Your goal is to [1,0], so PyTorch think you want each input has more unsupported tag.
Replace your one-hot encoding tags:
[1, 0] --> 0
[0, 1] --> 1
Enter the following code solves the above problems.
y = torch.argmax(y, dim=1)