safe-graph / GNN-FakeNews

A collection of GNN-based fake news detection models.
Apache License 2.0
434 stars 88 forks source link

代码直接报错,什么原因? #21

Closed sinxiao closed 1 year ago

sinxiao commented 1 year ago

/usr/local/bin/python3.10 /Users/mac/PycharmProjects/gnnFakeNews/gnn_model/gnn.py dataset>> politifact(314) args>> Namespace(seed=777, device='cpu', dataset='politifact', batch_size=128, lr=0.01, weight_decay=0.01, nhid=128, dropout_ratio=0.0, epochs=35, concat=True, multi_gpu=False, feature='bert', model='sage') Traceback (most recent call last): File "/Users/mac/PycharmProjects/gnnFakeNews/gnn_model/gnn.py", line 119, in args.num_classes = dataset.num_classes File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch_geometric/data/in_memory_dataset.py", line 66, in num_classes return super().num_classes File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch_geometric/data/dataset.py", line 159, in num_classes data_list = _get_flattened_data_list([data for data in self]) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch_geometric/data/dataset.py", line 159, in data_list = _get_flattened_data_list([data for data in self]) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch_geometric/data/dataset.py", line 259, in getitem data = data if self.transform is None else self.transform(data) File "/Users/mac/PycharmProjects/gnnFakeNews/utils/data_loader.py", line 89, in call edge_index = to_undirected(data.edge_index, data.x.size(0)) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch_geometric/utils/undirected.py", line 173, in to_undirected return coalesce(edge_index, edge_attr, num_nodes, reduce) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torchgeometric/utils/coalesce.py", line 99, in coalesce idx[1:].mul(numnodes).add(edge_index[int(sort_byrow)]) TypeError: mul(): argument 'other' (position 1) must be Tensor, not str

Process finished with exit code 1

YingtongDou commented 1 year ago

The error might be due to the pyg dataloader version inconsistency. You can try to load the dataset like the pyg official example or install pyg 1.6.1 instead of 2.0+ version.