Can't we use Tensor.Int8 as indices in Scatter_ method？

When I change a vecator into one-hot representation with " torch.zeros((len(state), 3)).scatter_(1, state, 1)", I got the following error:

``````{RuntimeError}Expected object of scalar type Long but got scalar type Char for argument #3 'index'
``````

Type information of state is given as follow:

``````tensor([1, 2], dtype=torch.int8)
``````

From the document, I guess we could use Int8 Tensor as index. But, why did I get this error?

Well, it seems that we really couldn’t use Int8 as indices, which I don’t know why.

Hi,

Indexing is only allowed using `LongTensor`s. This is to avoid possible indices overflow by using Int or Char Tensors.

1 Like