Assuming your current target is one-hot encoded in the channel dimension, i.e. it uses a 1 for the “active” class in that channel while all other channels contain zeros, you could use:
target = torch.argmax(target, dim=1)

to create the target with the expected class indices.
If that doesn’t work for you, could you post an example target with its values?
Also, don’t use Variables anymore, as they are deprecated since PyTorch 0.4.