How can nn.Embedding output Tensor with dtype 'float64'?

I found the output of nn.Embedding is default to be ‘float32’
but I need it to be ‘float64’

CLASS torch.nn.Embedding(num_embeddings, embedding_dim, padding_idx=None, max_norm=None, norm_type=2.0, scale_grad_by_freq=False, sparse=False, _weight=None)

and torch documents don’t provide the way to set attr as ‘dtype=’

how can I change that?

Try calling double() on your layer:

emb = nn.Embedding(...)
emb = emb.double()

This should change the type of internal parameters to float64.

thanks a lot!
this really works!