Skip to content

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

@chuangzhao0601

Description

@chuangzhao0601

Hello author, when I reproduce the DeepTalk-singleST.ipynb file, I encountered such error:
dt.File_Train(st_data, pathways, lrpairs_train, meta_data, species, LR_train = 'Sst_Sstr2',
outdir = Test_dir)

dt.data_for_train(st_data,data_dir='/mnt/workspace/test/single-cell/data/',LR_train="Sst_Sstr2")

dt.Train(data_name='Sst_Sstr2',
data_path='/mnt/workspace/test/single-cell/data/',
outdir='/mnt/workspace/test/single-cell/data/Sst_Sstr2/output',
pretrained_embeddings='/mnt/workspace/test/single-cell/data/Sst_Sstr2/data_pca.emd',
n_epochs=30, ft_n_epochs=10)

Loading graph...
DataSet Stats :
Number of Nodes 2399
Number of Edges 119477
Number of Node types 1
Number of relations 1
Graph with 2399 nodes and 119477 edges
2399 2
check torch.Size([2399, 128]) 2399
node2vec tensor torch.Size([2399, 128])
No. of nodes with pretrained embedding: 2399
No. edges in test data: 48252
PRETRAINING

generate walks ...
no. of walks 19192
train /mnt/workspace/test/single-cell/data//Sst_Sstr2/outdir/Sst_Sstr2_walks_train.txt
validate /mnt/workspace/test/single-cell/data//Sst_Sstr2/outdir/Sst_Sstr2_walks_validate.txt
test /mnt/workspace/test/single-cell/data//Sst_Sstr2/outdir/Sst_Sstr2_walks_test.txt

Run model for pre-training ...

Begin Training

Epoch: 0
MinLoss: 1000000.0, CurLoss: 7.9438
epoch time: (s) 138.76754474639893

Epoch: 10
MinLoss: 1000000.0, CurLoss: 7.8022
epoch time: (s) 138.13774728775024

Epoch: 20
MinLoss: 1000000.0, CurLoss: 7.7198
epoch time: (s) 140.38009071350098

Best Epoch: 29
In GenericGraph link Prediction Generation
168882
Generating false edges by random false target
train
valid
test

!!!!
4 4 Linear(in_features=512, out_features=512, bias=True)
Evaluating valid batch 0
Evaluating valid batch 100
Evaluating test batch 0
Evaluating test batch 100
Evaluating test batch 200

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

the important package versions:
deeptalk-st 0.0.4
as for other packages,I followed the Installation guidance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions