I am working on LSTMs and I want to compute cross_entropy loss, given X and y.
X.shape: (batch_size, time_steps, number_of_classes)
y.shape: (batch_size, time_steps)
y contains the ground truth indices, such as 0,1,2,3,..,10.
When I use torch.nn.functional.cross_entropy(X, y)
I get error:
ValueError: Expected target size (1000, 10), got torch.Size([1000, 1])
What is the correct way to use PyTorch's cross_entropy with this kind of Sequential model?