Hi Aly!



 Alymostafa:

-> 1838         ret = torch._C._nn.nll_loss(input, target, weight, _Reduction.get_enum(reduction), ignore_index)
...
IndexError: Target 2 is out of bounds.



I assume that you are working on a classification problem, and
that you are using NLLLoss (or maybe CrossEntropyLoss)
as your criterion.
Your model probably outputs two values (or maybe only one),
presumably log-probabilities.  But your target (which should
consist of integer class labels) contains 2 as a value.
Before you call loss = criterion(output, target),
please print out output.shape and target.max() (and
target.min()).
If you are performing a multi-class classification, the output
of your network should have shape [nBatch, nClass],
and target should be integer class labels that range from
0 to nClass - 1 (and, in particular, not from 1 to nClass).
Best.
K. Frank