Hi there,
I meet a problem that the Pytorch Loss functions such as functional.nll_loss and nn.CrossEntropyLoss are not supporting subset dataset.
I want to splitted the mnist and cifar10 dataset for specific use. For example, while loading the mnist data, I explicitly exclude the data with lable “6” in my data and label set so that the training/test dataset only have number 0-5 and 7-9.
However, the loss function will fail
loss=F.nll_loss(output, target)
or
loss=nn.CrossEntropyLoss(output, target)
since the function expect:
input(N, C) where C = number of classes
Target: (N) where each value is 0 <= targets[i] <= C-1
http://pytorch.org/docs/master/nn.html
In my case, this will fail since my C=9 but my target is 0-5+7-9 in stead of 0-8.
Could somebody tell me how to solve this?
I appreciate any good suggestions.