GilLevi/AgeGenderDeepLearning

Assertion `cur_target >= 0 && cur_target < n_classes’ failed

DrLusine opened this issue · 1 comments

I have added two extra labels (with corresponding images) to the existing image dataset (one for the age and one for the gender class).
mapping = { 0: '0-2 years', 1: '4-6 years', 2: '8-13 years', 3: '15-20 years', 4: '25-32 years', 5: '38-43 years', 6: '48-53 years', 7: '60 years and above', 8: 'none', 9: 'male', 10: 'female', 11:'none' }
Hence, the network's final output layer is modified to
**self.fc3 = nn.Linear(512, 12)** instead of self.fc3 = nn.Linear(512, 10)

However, I am receiving the below error:
RuntimeError: Assertion cur_target >= 0 && cur_target < n_classes' failed. at /Users/distiller/project/conda/conda-bld/pytorch_1556653464916/work/aten/src/THNN/generic/ClassNLLCriterion.c:92`

Was wondering if you could point out any additional changes I need to make to the network?

FYI: the issue was resolved by changing the label of the new data that was added to the model from -1 to a positive number. It looks like PyTorch expects to receive zero-based labels.