I have a dataset in which the class labels of the training set are not from 0 to C-1. It is a subset of a bigger range, but in no particular order. Hence, if I take the max class id as C-1, there will be many ids for which there are no training examples.
It would be great if I could pass in the one-hot vectors. What could be a good way to do it that way ?
Why would you like to pass the target in a one-hot format?
This would not change the fact that there are many class ids without training examples or do I misunderstand it?
I would recommend to remap the class indices to a valid range, i.e. [0, maxClassID].
Otherwise your model will output a large output tensor where a lot of logits are meaningless.
E.g. let’s assume your original target had 1000 classes. Your model would therefore output a tensor of shape [batch_size, 1000]. If your subset has only two classes, e.g. class0 and class999, your model might predict unknown classes (class1-class998).
How would you deal with it, if the maximal prediction is class789?