Wondering if there are any easy pytorch functions to rebin a target 1-hot vector. E.g. Change the dimensionality from 1000->100
Could you explain your use case a bit?
How would you rebin the one-hot vector? Just considering multiple entries in the original tensor as one bin in the new one?
Another side question: what do you need the one-hot tensor for?
Thanks for helping, I’d be happy to.
Targets tensor size: [10000 x 1000] So the shape of each is (1000,) as a 1-hot vector.
I want to reduce the tensor to [10000 x 100] where the 1 is redistributed to the correct overlapping bin.
As probably the real question, are there any loss functions that consider proximity of classes within the loss? So if the correct target class is N in range [0, C-1], it could consider a classification of N-1 or N+1 partially correct?
Well, you could use regression loss functions like
nn.MSELoss, but they might perform poorly on a classification task. Another approach would be to soften your target and use soft labels in
nn.CrossEntropyLoss. There are some shortcomings to this approach also, as explained here.