NLLLoss not implemented for

Hi all, I have problem with NLLLoss, I am getting error message: RuntimeError: “nll_loss_out_frame” not implemented for ‘Long’

This is my code:
for input_tensor, target_tensor in train_dataloader:
log_probs = encoder_decoder((input_tensor,target_tensor))
predicted = log_probs.argmax(dim=1)
loss = loss_function(predicted, target_tensor)

Shape of tensors are predicted.shape = (1,4) and targer_tensor.shape = (1,4).

I tried to change to other tensor type like int, but it doesn’t help. What i am doing wrong here?

Hi Ivan!

May I respectfully suggest that you read the documentation for

What types does NLLLoss expect / require for the input (your
predicted) and target (your target_tensor) tensors passed
into it? What shapes?


K. Frank

Ohhh, I think I was very tired yesterday how I didn’t saw obvious thing here what I did even after reading documentation. I just had to call loss function using log_probs and target_tensor like:
loss = loss_function(log_probs, target_tensor)
Now everything works, sorry for confusion.

Thank you Frank,