For a classification use case you would most likely use a loss function like nn.NLLLoss or nn.CrossEntropyLoss, which both expect a target tensor containing class indices instead of a one-hot encoded representation.
How are you currently trying to calculate your loss?
Could you post some code so that we could have a look?