Solved by ptrblck in post #14 
              
              
                How would you like to ignore the class in your one-hot encoded tensor? 
Do you want to remove it completely? 
This code should just remove the unwanted class channel: 
batch_size = 10
n_classes = 5
h, w = 24, 24
labels = torch.empty(batch_size, 1, h, w, dtype=torch.long).random_(n_classes)
one_hot =…