Giphy / celeb-detection-oss

GIPHY's Open-Source Celebrity Detection Deep Learning Model
https://celebrity-detection.giphy.com/
Mozilla Public License 2.0
677 stars 68 forks source link

Trying transfer learning throwing runtime error #3

Closed guccichurch closed 5 years ago

guccichurch commented 5 years ago

trying to python experiments/example_experiment.py

Traceback (most recent call last): File "experiments/example_experiment.py", line 107, in trainer.perform() File "/mnt/data_3/bilguun-ml/celeb-detection-oss/model_training/trainers/trainer.py", line 68, in perform top_1, top_5 = self._accuracy(prediction, labels, topk=(1, 5)) File "/mnt/data_3/bilguun-ml/celeb-detection-oss/model_training/trainers/trainer.py", line 128, in accuracy , pred = output.topk(maxk, 1, True, True) RuntimeError: invalid argument 5: k not in range for dimension at /pytorch/aten/src/THC/generic/THCTensorTopK.cu:21

can't find anything on google

dvoitekh commented 5 years ago

hi @guccichurch the issue happens because the trainer attempts to calculate top-5 precision, while your dataset has less than 5 classes (I assume you're running it on the example dataset from the repo which contains only 2 classes). if you haven't added any new classes to the example dataset and just wanted to test the model, please change 5 to 2 here: https://github.com/Giphy/celeb-detection-oss/blob/6ff7aa97ffaba30b3b853abec489946556e1e671/model_training/trainers/trainer.py#L68 so basically you need to either ensure that the number of your classes is not less than 5 or just reduce the related value.

guccichurch commented 5 years ago

hi @guccichurch the issue happens because the trainer attempts to calculate top-5 precision, while your dataset has less than 5 classes (I assume you're running it on the example dataset from the repo which contains only 2 classes). if you haven't added any new classes to the example dataset and just wanted to test the model, please change 5 to 2 here:

https://github.com/Giphy/celeb-detection-oss/blob/6ff7aa97ffaba30b3b853abec489946556e1e671/model_training/trainers/trainer.py#L68

so basically you need to either ensure that the number of your classes is not less than 5 or just reduce the related value.

hi @dvoitekh Thank you for replying and sorry for asking something so simple ,the issue is resolved and i'm currently in training process