AndreaCossu / Relation-Network-PyTorch

Implementation of Relation Network and Recurrent Relational Network using PyTorch v1.3. Original papers: (RN) https://arxiv.org/abs/1706.01427 (RRN): https://arxiv.org/abs/1711.08028
MIT License
19 stars 7 forks source link

Index Out of Range Error #7

Closed Alberto15Romero closed 2 years ago

Alberto15Romero commented 3 years ago

I am trying to run the network using the tag --babi_tasks to execure only one task. I realised that to do so I have to download the full dataset and I did so. Nevertheless, I am getting this error:

Done reading babi! Start training Traceback (most recent call last): File "D:\Documentos\Classroom_Activity_Recognition\Relation-Network-PyTorch\launch_rrn_babi.py", line 141, in avg_train_losses, avg_train_accuracies, val_losses, val_accuracies = train(train_stories, validation_stories, args.epochs, lstm, rrn, criterion, optimizer, args.batch_size, args.no_save, device, result_folder) File "D:\Documentos\Classroom_Activity_Recognition\Relation-Network-PyTorch\task\babi_task\rrn\train.py", line 48, in train facts_emb, one_of_k, h_f = lstm.process_facts_rrn(facts_batch, h_f) File "D:\Documentos\Classroom_Activity_Recognition\Relation-Network-PyTorch\src\models\LSTM.py", line 40, in process_facts_rrn emb = self.embeddings(x) # (n_facts, n_words_facts, dim_emb) File "C:\Users\alber\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\nn\modules\module.py", line 1071, in _call_impl result = forward_call(*input, **kwargs) File "C:\Users\alber\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\nn\modules\sparse.py", line 158, in forward return F.embedding( File "C:\Users\alber\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\nn\functional.py", line 2043, in embedding return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse) IndexError: index out of range in self

is this an error in the code or am I doing something wrong?

Thanks!

Alberto15Romero commented 2 years ago

Solved!

This happens when you change something on the train set and the dictionary size changes.

The utils.py script has a 157 value that you must change to your dictionary size.