Shen-Lab / GraphCL

[NeurIPS 2020] "Graph Contrastive Learning with Augmentations" by Yuning You, Tianlong Chen, Yongduo Sui, Ting Chen, Zhangyang Wang, Yang Shen
MIT License
541 stars 103 forks source link

ValueError: `MessagePassing.propagate` only supports `torch.LongTensor` of shape `[2, num_messages]` or `torch_sparse.SparseTensor` for argument `edge_index`. #53

Closed TianyuFan0504 closed 1 year ago

TianyuFan0504 commented 1 year ago

Hi! Thanks for the amazing work and released code. They are really interesting. When I run ./transferLearning_MoleculeNet_PPI/chem/pretrain_graphcl.py, the error occur. When I print it, i got the value of edge_index, but it is a str "add" instead of a tensor. Can someone help me? Traceback (most recent call last): File "pretrain_graphcl.py", line 185, in main() File "pretrain_graphcl.py", line 176, in main train_acc, train_loss = train(args, model, device, dataset, optimizer) File "pretrain_graphcl.py", line 103, in train x1 = model.forward_cl(batch1.x, batch1.edge_index, batch1.edge_attr, batch1.batch) File "pretrain_graphcl.py", line 61, in forward_cl x = self.gnn(x, edge_index, edge_attr) File "/opt/anaconda3/envs/torch170/lib/python3.7/site-packages/torch/nn/modules/module.py", line 727, in _call_impl result = self.forward(*input, *kwargs) File "/root/GSSL/Molecular/GraphCL/transferLearning_MoleculeNet_PPI/chem/model.py", line 277, in forward h = self.gnns[layer](h_list[layer], edge_index, edge_attr) File "/opt/anaconda3/envs/torch170/lib/python3.7/site-packages/torch/nn/modules/module.py", line 727, in _call_impl result = self.forward(input, **kwargs) File "/root/GSSL/Molecular/GraphCL/transferLearning_MoleculeNet_PPI/chem/model.py", line 55, in forward return self.propagate(self.aggr, edge_index, x=x, edge_attr=edge_embeddings) File "/opt/anaconda3/envs/torch170/lib/python3.7/site-packages/torch_geometric/nn/conv/message_passing.py", line 272, in propagate size = self.check_input__(edge_index, size) File "/opt/anaconda3/envs/torch170/lib/python3.7/site-packages/torch_geometric/nn/conv/message_passing.py", line 158, in check_input__ ('MessagePassing.propagate only supports torch.LongTensor of ' ValueError: MessagePassing.propagate only supports torch.LongTensor of shape [2, num_messages] or torch_sparse.SparseTensor for argument edge_index.

yyou1996 commented 1 year ago

Hi @TianyuFan0504,

Sorry for the late reply and I am not sure whether you resolve it. If not, I think this issue https://github.com/Shen-Lab/GraphCL/issues/13 should be helpful.