Vinh Nguyen
1 min readOct 8, 2020

--

I am getting an index error:

IndexError Traceback (most recent call last)

<ipython-input-14-2b583fac0fc3> in <module>()

3 optimizer = optim.Adam(model.parameters(), lr=2e-5)

4

----> 5 train(model=model, optimizer=optimizer)

8 frames/usr/local/lib/python3.6/dist-packages/torch/nn/functional.py in nll_loss(input, target, weight, size_average, ignore_index, reduce, reduction)

2216 .format(input.size(0), target.size(0)))

2217 if dim == 2:

-> 2218 ret = torch._C._nn.nll_loss(input, target, weight, _Reduction.get_enum(reduction), ignore_index)

2219 elif dim == 4:

2220 ret = torch._C._nn.nll_loss2d(input, target, weight, _Reduction.get_enum(reduction), ignore_index)

IndexError: Target 6328 is out of bounds.

I switched the device to 'cpu' in order to get a look at what's going on here. How do I resolve this?

--

--

Responses (2)