TencentAILabHealthcare/scBERT

Error in prediction

zrpeak opened this issue · 2 comments

Prediction with "python predict.py" resulted in the following error message:

    TypeError: can't convert cuda:0 device type to numpy. Use Tensor.cpu() to copy the tensor to host memory first.

Replacing "pred_finals.append(pred_final)" with "pred_finals.append(torch.IntTensor.item(pred_final))" in line 123 of predict.py could fix this problem, but the output of inference had only one cell type, like this:

    ['CD8+ Cytotoxic T','CD8+ Cytotoxic T','CD8+ Cytotoxic T'...]

Is this due to the incorrect modification of the code, or the insufficient fine-tuning of the model?

were you able to download the pretrained model data?

Perhaps the dataset you used for finetune is extremely imbalanced and makes the model hard to learn useful information to distinguish the cell types of your data during the fine-tuning stage. There is a newly published work showing how to optimize scBERT finetuning process when dealing with imbalanced data (https://www.nature.com/articles/s42256-023-00757-8). Hope it helps.