I am trying a two-way classification using a linear layer: nn.Linear(4096, 2)
to get the final predictions; and deliberately using target from 50 classes. I think I should be getting an error when using CrossEntropy loss, since target has classes outside of final linear layer. However, I am not getting the any error. I am using version 1.5.0. Any insights? Am I missing something?
Output (batch-size of 5):
Target: tensor([ 6, 12, 8, 29, 3], device='cuda:0')
Pred cls: tensor([[ 5.7777, 11.3648],
[ 0.4722, 2.3781],
[ 2.2436, -1.5575],
[-4.2130, 1.2372],
[ 9.2907, 4.8596]], device='cuda:0', grad_fn=<AddmmBackward>)
CE loss: tensor(1.0909, device='cuda:0', grad_fn=<NllLossBackward>)