What does the embedding expect for input? I got this error code when trying to embed the sentences.



x = torch.randint(0, 10, (2, 5))
embedding = nn.Embedding(5, 3)
seq_len = len(x)
embedded = embedding(x)
Traceback (most recent call last):
File “”, line 1, in 
File “/usr/local/lib/python2.7/site-packages/torch/nn/modules/module.py”, line 477, in call
result = self.forward(*input, **kwargs)
File “/usr/local/lib/python2.7/site-packages/torch/nn/modules/sparse.py”, line 110, in forward
self.norm_type, self.scale_grad_by_freq, self.sparse)
File “/usr/local/lib/python2.7/site-packages/torch/nn/functional.py”, line 1110, in embedding
return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse)
RuntimeError: Expected tensor for argument #1 ‘indices’ to have scalar type Long; but got CPUFloatTensor instead (while checking arguments for embedding)