Hi NaN!



 111137:

Can we code a classification without onehot encoding,
…


If you’re asking specifically about whether we can avoid
one-hot encoding the target labels, the answer is yes.
Let’s say we have a classification problem with 5 classes.
The most common approach (probably) is to build a network
whose output (for a single sample) is a length-5 vector (of
real numbers, not integers).  But the label (for a single sample)
is a single integer class label (so not one-hot encoded).
Then we run the output and label through, for example,
nn.CrossEntropyLoss as the loss criterion.
Again, in this scheme, the output of your network is a vector of
length number-of-classes, but your labels are single numbers.
Best.
K. Frank