I have my logits of shape (16, 100, 1024), where 16 is batch size, 100 is sequence length, and 1024 is feature length.

My target is of shape (16, 100), where 16 is batch size and 100 is sequence length

while applying nn.CrossEntropyLoss on the both i get the following error

criterion(pred, target)

#ValueError: Expected target size (16, 1024), got torch.Size([16, 100])

wheres this is working with this snipped

criterion(pred[0], target[0])

what am i doing wrong?