Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Target -1 is out of bounds #1

Open
126zz6 opened this issue Apr 25, 2024 · 1 comment
Open

Target -1 is out of bounds #1

126zz6 opened this issue Apr 25, 2024 · 1 comment

Comments

@126zz6
Copy link

126zz6 commented Apr 25, 2024

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
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants