d-ailin / GDN

Implementation code for the paper "Graph Neural Network-Based Anomaly Detection in Multivariate Time Series" (AAAI 2021)
MIT License
482 stars 141 forks source link

RuntimeError... #39

Closed lovechang1986 closed 2 years ago

lovechang1986 commented 2 years ago

When I run the main.py using the default msl dataset. Then this error occured. My torch_geometric version is 2.0.4. Would you help to fix this ?

Traceback (most recent call last):
  File "main.py", line 256, in <module>
    main.run()
  File "main.py", line 108, in run
    self.train_log = train(self.model, model_save_path,
  File "/home/kaifazhe4/test/GDN/train.py", line 69, in train
    out = model(x, edge_index).float().to(device)
  File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/kaifazhe4/test/GDN/models/GDN.py", line 166, in forward
    gcn_out = self.gnn_layers[i](x, batch_gated_edge_index, node_num=node_num*batch_num, embedding=all_embeddings)
  File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/kaifazhe4/test/GDN/models/GDN.py", line 73, in forward
    out, (new_edge_index, att_weight) = self.gnn(x, edge_index, embedding, return_attention_weights=True)
  File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/kaifazhe4/test/GDN/models/graph_layer.py", line 65, in forward
    out = self.propagate(edge_index, x=x, embedding=embedding, edges=edge_index,
  File "/opt/conda/lib/python3.8/site-packages/torch_geometric/nn/conv/message_passing.py", line 317, in propagate
    out = self.message(**msg_kwargs)
  File "/home/kaifazhe4/test/GDN/models/graph_layer.py", line 110, in message
    alpha = softmax(alpha, edge_index_i, size_i)
RuntimeError: softmax() Expected a value of type 'Optional[Tensor]' for argument 'ptr' but instead found type 'int'.
d-ailin commented 2 years ago

I think it is caused by the inconsistent installed package. There are some solutions provided in the previous issues #2, #20. Hope it helps :)

lovechang1986 commented 2 years ago

Thanks, I checked the older doc of torch_geometric and found the same solution.

Thanks again...