Hello,
Thank you for your response. Yes, I do know that Cross-EntropyLoss has a softmax “embedded”. Without the Softmax, the outputs are not necessarily between 0 an 1. See below:
outputs: tensor([[ 0.2439, 0.0890],
[ 0.2258, 0.1119],
[-0.2149, 0.2282],
[ 0.0222, -0.1259]]
The piece of code related to this post is like that:
def train_model(model, criterion, ...)
...
   outputs = model(inputs)
   _, preds = torch.max(outputs, 1)  
   loss = criterion(outputs, labels)
...


# main code

my_model = my_model.to(device)
my_criterion = nn.CrossEntropyLoss()
...
my_model = train_model(my_model, my_criterion,...)



Above, I use integer encoding. I am just wondering whether I can use integer encoding with Softmax + Cross-Entropy in PyTorch. The point is that some authors, by using other frameworks rather than PyTorch, state that we MUST use one-hot encoding for binary classification, because, eventually, we may have all outputs equal. For instance, see this Stack Overflow post (Keras): python - keras CNN same output - Stack Overflow 3
Hence, the explanation here is the incompatibility between the softmax as output activation and binary_crossentropy as loss function. To solve this, we must rely on one-hot encoding otherwise we will get all outputs equal (this is what I read). But I used Cross-Entropy here. In my case, as shown above, the outputs are not equal. Hence, it seems there is no problem in using integer encoding in PyTorch in a situation like that. But, I would like to be sure.
Thanks.