Giphy / celeb-detection-oss

GIPHY's Open-Source Celebrity Detection Deep Learning Model

Home Page:https://celebrity-detection.giphy.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Trying transfer learning throwing runtime error

guccichurch opened this issue · comments

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

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:

top_1, top_5 = self._accuracy(prediction, labels, topk=(1, 5))

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 @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:

top_1, top_5 = self._accuracy(prediction, labels, topk=(1, 5))

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