nickuntitled / pyramid_aggregate_head_pose_estimation

Pyramid-based structure for head pose estimation
MIT License
1 stars 0 forks source link

Target -1 is out of bounds #1

Closed 126zz6 closed 2 months ago

126zz6 commented 6 months ago

return torch._C._nn.cross_entropy_loss(input, target, weight, _Reduction.get_enum(reduction), ignore_index, label_smoothing) IndexError: Target -1 is out of bounds. How can I solve this problem

nickuntitled commented 6 months ago

Hello @126zz6 for creating an issue about "Target -1 is out of bounds".

From the issue, the IndexError during using torch._C._nn.cross_entropy_loss is from the target (or label) index is outside the range (which means the head pose labels are outside the range -99 and 99 degrees).

I wrote the code that it caused an error like that below.

test = torch.Tensor([[0, 0.5, 0.2], [0.1, 0.3, 0.4]])
gt = torch.LongTensor([-1, 1])
output = class_criterion(test, gt)

It showed.

IndexError: Target -1 is out of bounds.

Next, I saw the CrossEntropyLoss was available on the HPE training code (train.py). When training the model, you have to follow the instruction inside README.md such as

The filename list used for training (argument --filename_list) is available inside the folder

However, if you want to create your own filename list, you have to make sure that each head pose values (yaw, pitch, and roll) is between -99 and 99 degrees, otherwise, you will see the error Target -1 is out of bounds.