I am getting this error while training a Bidirectional attention flow model for question answering.
Starting training …
Starting batch: 0
IndexError Traceback (most recent call last)
in ()
----> 1 train(model, train_dataset)
2 frames
/usr/local/lib/python3.6/dist-packages/torch/nn/functional.py in nll_loss(input, target, weight, size_average, ignore_index, reduce, reduction)
2262 .format(input.size(0), target.size(0)))
2263 if dim == 2:
-> 2264 ret = torch._C._nn.nll_loss(input, target, weight, _Reduction.get_enum(reduction), ignore_index)
2265 elif dim == 4:
2266 ret = torch._C._nn.nll_loss2d(input, target, weight, _Reduction.get_enum(reduction), ignore_index)
IndexError: Target 545 is out of bounds.
It seems that there is some problem with the way I set the target values in data preprocessing.
What are the best ways to debug these kinds of errors in pytorch. Are there any tutorials or books I can refer to ?