However, there are two errors.When I try to train my model, I get an error for the loss function: multi-target not supported at /pytorch/aten/src/THCUNN/generic/ClassNLLCriterion.cu:15.
The second error occurs when I change the hidden_dim back to 256, I get an error regarding the batch normalization.
This error is raised, if the shapes of the input tensors are unexpected, so make sure the model output has the shape [batch_size, nb_classes, *], while the target has the shape [batch_size, *] containing the class indicex in the range [0, nb_classes-1].
Here is a small code snippet showing the error:
batch_size, nb_classes = 2, 10
x = torch.randn(batch_size, nb_classes)
y = torch.randint(0, nb_classes, (batch_size,))
criterion = nn.CrossEntropyLoss()
loss = criterion(x, y)
y = torch.randint(0, nb_classes, (batch_size, nb_classes))
loss = criterion(x, y)
> RuntimeError: 1D target tensor expected, multi-target not supported