theislab / scarches

Reference mapping for single-cell genomics
https://docs.scarches.org/en/latest/
BSD 3-Clause "New" or "Revised" License
331 stars 51 forks source link

Scpoli:RuntimeError: expected scalar type Float but found Double #195

Closed melancholy12 closed 1 year ago

melancholy12 commented 1 year ago

Hello all, I meet this problem and need help. scpoli_model.train(n_epochs=200, pretraining_epochs=40, early_stopping_kwargs=early_stopping_kwargs, eta=5, )

RuntimeError Traceback (most recent call last) /tmp/ipykernel_118840/3049929526.py in ----> 1 scpoli_model.train(n_epochs=200, 2 pretraining_epochs=40, 3 early_stopping_kwargs=early_stopping_kwargs, 4 eta=5, 5 )

~/anaconda3/lib/python3.9/site-packages/torch/nn/modules/linear.py in forward(self, input) 112 113 def forward(self, input: Tensor) -> Tensor: --> 114 return F.linear(input, self.weight, self.bias) 115 116 def extra_repr(self) -> str:

RuntimeError: expected scalar type Float but found Double

cdedonno commented 1 year ago

Hi @melancholy12, could you try casting your input matrix to float32?

You should be able to do this with this line of code: adata.X = adata.X.astype('float32')