error
john012343210 opened this issue · 1 comments
john012343210 commented
Namespace(dropout=0.2, evaluate_every=500, gpu=-1, grad_norm=1.0, graph_batch_size=30000, graph_split_size=0.5, lr=0.01, n_bases=4, n_epochs=10000, negative_sample=1, regularization=0.01)
load data from ./data/FB15k-237
num_entity: 14541
num_relation: 237
num_train_triples: 272115
num_valid_triples: 17535
num_test_triples: 20466
Traceback (most recent call last):
File "main.py", line 121, in <module>
main(args)
File "main.py", line 48, in main
test_graph = build_test_graph(len(entity2id), len(relation2id), train_triplets)
File "utils.py", line 156, in build_test_graph
data = Data(edge_index = edge_index)
File "C:\Users\xxxxxxxxx\.conda\envs\a4\lib\site-packages\torch_geometric\data\data.py", line 88, in __init__
raise ValueError(
ValueError: Argument `edge_index` needs to be of type `torch.long` but found type `torch.int32`
JinheonBaek commented
It seems the versions of numpy, pytorch or pytorch_geometric are different to me.
This error means, the type of the edge_index (edge_index.type()) should be torch.LongTensor, and the dtype of the edge_index (edge_index.dtype) should be torch.int64.
You can explicitly fix this error, by replacing Line 146-148 of utils.py as follows:
src = torch.tensor(src, dtype=torch.long)
rel = torch.tensor(rel, dtype=torch.long)
dst = torch.tensor(dst, dtype=torch.long)
Best wishes,
Jinheon Baek