将错误索引嵌入自身范围之外

时间:2020-06-04 05:13:37

标签: python pytorch

我遵循了这个tutorial

但是我收到此错误。

`This is a test of our preprocessing function. It took 46.7 seconds to load the data. Our German vocab has size 13354 and our English vocab has size 11560. Our training data has 7443 batches, each with 16 sentences, and our validation data has 570 batches.
Validating Epoch [0/50]  Average loss: 9.379     Perplexity: 11833.884
Epoch [1/50]     Batch [10/7443]     Loss: 8.345
Epoch [1/50]     Batch [1010/7443]   Loss: 4.692
Epoch [1/50]     Batch [2010/7443]   Loss: 4.192
Traceback (most recent call last):
  File "/home/hasara/python code/benchmark- IWSLT data/test.py", line 334, in <module>
    train(train_iter, val_iter, model, criterion, optimizer, 50)
  File "/home/hasara/python code/benchmark- IWSLT data/test.py", line 255, in train
    scores = model(src, tgt)
  File "/home/hasara/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 550, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/hasara/python code/benchmark- IWSLT data/test.py", line 159, in forward
    out_e, final_e = self.encoder(src)
  File "/home/hasara/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 550, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/hasara/python code/benchmark- IWSLT data/test.py", line 75, in forward
    x = self.dropout(self.embedding(x)) # embedding
  File "/home/hasara/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 550, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/hasara/.local/lib/python3.6/site-packages/torch/nn/modules/sparse.py", line 114, in forward
    self.norm_type, self.scale_grad_by_freq, self.sparse)
  File "/home/hasara/.local/lib/python3.6/site-packages/torch/nn/functional.py", line 1724, in embedding
    return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse)
IndexError: index out of range in self`

一些资源提到该问题与嵌入有关。但是我仍然无法弄清错误。我是pyTorch的新手。任何见解将不胜感激。

0 个答案:

没有答案