nn.CrossEntropyLoss won’t work with one-hot encoded targets and expects a LongTensor in the shape [batch_size] containing the class indices.
However, since this is not the current error, could you please print the output and target shape before calculating the loss?