Embedding: argument indices must be a Tensor, not a list
I am trying to train a RNN, but I am having trouble with my embedding.
I am getting the following error message:
TypeError: embedding(): argument 'indices' (position 2) must be Tensor, not list

The code in the forward method starts like that:
def forward(self, word_indices: [int]):
        print(&quot;sentences&quot;)
        print(len(word_indices))
        print(word_indices)

        word_ind_tensor = torch.tensor(word_indices, device=&quot;cpu&quot;)

        print(word_ind_tensor)
        print(word_ind_tensor.size())

        embeds_word = self.embedding_word(word_indices)

The output of all of that is:
sentences
29
[261, 15, 5149, 44, 287, 688, 1125, 4147, 9874, 582, 15, 9875, 3, 2, 6732, 34, 2, 6733, 9, 2, 485, 7, 6734, 3, 741, 2, 2179, 1571, 1]
tensor([ 261,   15, 5149,   44,  287,  688, 1125, 4147, 9874,  582,   15, 9875,
           3,    2, 6732,   34,    2, 6733,    9,    2,  485,    7, 6734,    3,
         741,    2, 2179, 1571,    1])

torch.Size([29])

Traceback (most recent call last):
  File &quot;/home/lukas/Documents/HU/Materialen/21SoSe-Studienprojekt/flair-Studienprojekt/TestModel.py&quot;, line 68, in &lt;module&gt;
    embeddings_storage_mode = &quot;CPU&quot;) #auf cuda ändern
  File &quot;/home/lukas/Documents/HU/Materialen/21SoSe-Studienprojekt/flair-Studienprojekt/flair/trainers/trainer.py&quot;, line 423, in train
    loss = self.model.forward_loss(batch_step)
  File &quot;/home/lukas/Documents/HU/Materialen/21SoSe-Studienprojekt/flair-Studienprojekt/flair/models/sandbox/srl_tagger.py&quot;, line 122, in forward_loss
    features = self.forward(word_indices = sent_word_ind, frame_indices = sent_frame_ind)
  File &quot;/home/lukas/Documents/HU/Materialen/21SoSe-Studienprojekt/flair-Studienprojekt/flair/models/sandbox/srl_tagger.py&quot;, line 147, in forward
    embeds_word = self.embedding_word(word_indices)
  File &quot;/home/lukas/miniconda3/envs/studienprojekt/lib/python3.7/site-packages/torch/nn/modules/module.py&quot;, line 550, in __call__
    result = self.forward(*input, **kwargs)
  File &quot;/home/lukas/miniconda3/envs/studienprojekt/lib/python3.7/site-packages/torch/nn/modules/sparse.py&quot;, line 114, in forward
    self.norm_type, self.scale_grad_by_freq, self.sparse)
  File &quot;/home/lukas/miniconda3/envs/studienprojekt/lib/python3.7/site-packages/torch/nn/functional.py&quot;, line 1724, in embedding
    return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse)
TypeError: embedding(): argument 'indices' (position 2) must be Tensor, not list

I originally initialised the embedding the following way:
self.embedding_word = torch.nn.Embedding(self.word_dict_size, embedding_size)

word_dict_size and embedding_size are both integers.
Is there something obviously I did wrong or is that a deeper mistake?

You're passing in a list to self.embedding_word: word_indices, not the tensor you just created for that purpose word_ind_tensor.
