spoter
spoter copied to clipboard
IndexError when training model
This is the command used to train the model :
python -m train --experiment_name "Spoter" --training_set_path "data/WLASL100_train_25fps.csv" --validation_set_path "data/WLASL100_val_25fps.csv" --testing_set_path "data/WLASL100_test_25fps.csv"
I get the following error after the program runs for awhile:
Starting Spoter... Traceback (most recent call last): File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "/usr/lib/python3.7/runpy.py", line 85, in _run_code exec(code, run_globals) File "/content/drive/MyDrive/Spoter/train.py", line 272, in
train(args) File "/content/drive/MyDrive/Spoter/train.py", line 174, in train train_loss, _, _, train_acc = train_epoch(slrt_model, train_loader, cel_criterion, sgd_optimizer, device) File "/content/drive/MyDrive/Spoter/spoter/utils.py", line 19, in train_epoch loss = criterion(outputs[0], labels[0]) File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1102, in _call_impl return forward_call(*input, **kwargs) File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/loss.py", line 1152, in forward label_smoothing=self.label_smoothing) File "/usr/local/lib/python3.7/dist-packages/torch/nn/functional.py", line 2846, in cross_entropy return torch._C._nn.cross_entropy_loss(input, target, weight, _Reduction.get_enum(reduction), ignore_index, label_smoothing) IndexError: Target 78 is out of bounds.
Changing parameters like the epochs and learning rate does not fix the issue.
Hi @adhithiyaa-git,
It seems that wou are training the WLASL100 dataset (with 100 classes) but only using the default --num_classes
argument, which is 64. This would cause the IndexError
.
Try adding --num_classes 100
to your training command and please let me know if this helps.
Hi, I was getting the same problem, and I saw this question. I tried adding the --num_classes 100 but I got another error.
The command I used to train the model:
python -m train --experiment_name trial --epochs 1 --training_set_path "C:\Users\Asus\Documents\Lecture Notes\Intro to Artificial Intelligence\spoter-main\datasets\WLASL100_train_25fps.csv" --validation_set_path "C:\Users\Asus\Documents\Lecture Notes\Intro to Artificial Intelligence\spoter-main\datasets\WLASL100_val_25fps.csv" --testing_set_path "C:\Users\Asus\Documents\Lecture Notes\Intro to Artificial Intelligence\spoter-main\datasets\WLASL100_test_25fps.csv" --num_classes 100
The error:
Starting trial...
Traceback (most recent call last):
File "C:\Users\Asus\anaconda3\envs\CS5804_AI\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\Asus\anaconda3\envs\CS5804_AI\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\Asus\Documents\Lecture Notes\Intro to Artificial Intelligence\spoter-main\train.py", line 271, in
Issue is solved with the change proposed in this comment from another issue thread https://github.com/matyasbohacek/spoter/issues/2#issuecomment-1172304554