@ptrblck
Hi, i have the same problem, but i tried your suggestion and the error released again, can you help me please?
Thanks


max_len=250
min_count=50
batch_size=11


LSTM parameters
embed_size =251
hidden_size = 256
num_layers = 1
training parameters
lr = 0.001
num_epochs = 10


model = LSTMClassifier(embed_size=embed_size,
hidden_size=hidden_size,
vocab_size=vocab_size, # my vocab_size is 67
num_layers=num_layers,
num_classes=train_ds.num_classes,
batch_size=batch_size)
if use_gpu:
model = model.cuda()


criterion = nn.CrossEntropyLoss()
if use_gpu:
criterion = criterion.cuda()
optimizer = optim.Adam(model.parameters(), lr=lr, betas=(0.7, 0.99))
scheduler = optim.lr_scheduler.StepLR(optimizer, step_size=1, gamma=0.975)
`hist = train(model, train_dl, valid_dl, criterion, optimizer, scheduler, num_epochs)`

IndexError                                Traceback (most recent call last)
<ipython-input-192-7e0f888e140e> in <module>
----> 1 hist = train(model, train_dl, valid_dl, criterion, optimizer, scheduler, num_epochs)

~\train_utils.py in train(model, train_dl, valid_dl, criterion, optimizer, scheduler, num_epochs)
     85 
     86         ## perform one epoch of training and validation
---> 87         trn_loss, trn_acc = train_step(model, train_dl, criterion, optimizer, scheduler)
     88         val_loss, val_acc = validate_step(model, valid_dl, criterion)
     89 

~\train_utils.py in train_step(model, train_dl, criterion, optimizer, scheduler)
     29         model.zero_grad()
     30 
---> 31         output = model(train_inputs.t())
     32 
     33         loss = criterion(output, train_labels)

C:\ProgramData\Anaconda3\lib\site-packages\torch\nn\modules\module.py in _call_impl(self, *input, **kwargs)
    720             result = self._slow_forward(*input, **kwargs)
    721         else:
--> 722             result = self.forward(*input, **kwargs)
    723         for hook in itertools.chain(
    724                 _global_forward_hooks.values(),

<ipython-input-181-360ed93de0e5> in forward(self, x)
     24 
     25     def forward(self, x):
---> 26         x = self.embedding(x)
     27         x, self.hidden = self.lstm(x, self.hidden)
     28         x = self.fc(x[-1])  # select the last output

C:\ProgramData\Anaconda3\lib\site-packages\torch\nn\modules\module.py in _call_impl(self, *input, **kwargs)
    720             result = self._slow_forward(*input, **kwargs)
    721         else:
--> 722             result = self.forward(*input, **kwargs)
    723         for hook in itertools.chain(
    724                 _global_forward_hooks.values(),

C:\ProgramData\Anaconda3\lib\site-packages\torch\nn\modules\sparse.py in forward(self, input)
    122 
    123     def forward(self, input: Tensor) -> Tensor:
--> 124         return F.embedding(
    125             input, self.weight, self.padding_idx, self.max_norm,
    126             self.norm_type, self.scale_grad_by_freq, self.sparse)

C:\ProgramData\Anaconda3\lib\site-packages\torch\nn\functional.py in embedding(input, weight, padding_idx, max_norm, norm_type, scale_grad_by_freq, sparse)
   1812         # remove once script supports set_grad_enabled
   1813         _no_grad_embedding_renorm_(weight, input, max_norm, norm_type)
-> 1814     return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse)
   1815 
   1816 

IndexError: index out of range in self