deep-head-pose icon indicating copy to clipboard operation
deep-head-pose copied to clipboard

Assertion `cur_target >= 0 && cur_target < n_classes' failed.

Open jensleeGit opened this issue 5 years ago • 3 comments

Why occur this bug. Is the number of classes is wrong?

bins = np.array(range(-99, 102, 3))

Should it set 68 rather than 66 ?

jensleeGit avatar Oct 09 '19 02:10 jensleeGit

Traceback (most recent call last): File "/home/zlee/PycharmProjects/deep-head-pose-master/code/train_hopenet_cpu.py", line 166, in loss_pitch = criterion(pitch, label_pitch) File "/home/zlee/.local/lib/python3.5/site-packages/torch/nn/modules/module.py", line 491, in call result = self.forward(*input, **kwargs) File "/home/zlee/.local/lib/python3.5/site-packages/torch/nn/modules/loss.py", line 759, in forward self.ignore_index, self.reduce) File "/home/zlee/.local/lib/python3.5/site-packages/torch/nn/functional.py", line 1442, in cross_entropy return nll_loss(log_softmax(input, 1), target, weight, size_average, ignore_index, reduce) File "/home/zlee/.local/lib/python3.5/site-packages/torch/nn/functional.py", line 1332, in nll_loss return torch._C._nn.nll_loss(input, target, weight, size_average, ignore_index, reduce) RuntimeError: Assertion `cur_target >= 0 && cur_target < n_classes' failed. at /pytorch/aten/src/THNN/generic/ClassNLLCriterion.c:97

jensleeGit avatar Oct 09 '19 09:10 jensleeGit

I was doing some debugging and turns out this error doesnt popup up when using jsut the original datasets. The augmented ones (Flipped) cause thi error. I am not sure how. the code looks alright as i stepped through each of the tensors.

KaunilD avatar Jul 25 '20 08:07 KaunilD

The problem here is that for some images, the angles excess 99 or less than -99, so the index of the bins is not in range (0,66), that causes this bug. Maybe removing those samples can help.

vietth-bka avatar Mar 02 '21 04:03 vietth-bka