this is my input shape
nn.CrossEntropyLoss
expects the model output to have the shape [batch_size, nb_classes]
and a target in the shape [batch_size]
containing class indices in the range [0, nb_classes-1]
for a multi-class classification use case.
Based on your screenshot it seems you are one-hot encoding the target, which is wrong.
In that case, use target = torch.argmax(target, dim=1)
to create the expected target tensor.
PS: you can post code snippets by wrapping them into three backticks ```, which makes debugging easier.