divelab / DIG

A library for graph deep learning research
https://diveintographs.readthedocs.io/
GNU General Public License v3.0
1.86k stars 281 forks source link

AttributeError: 'GCNConv' object has no attribute '__explain__' #153

Closed cxw-droid closed 1 year ago

cxw-droid commented 2 years ago

Hi,

There is an error when I tried to train a new model for PGExplainer: $ /bin/bash ./models/train_gnns.sh:

AttributeError: 'GCNConv' object has no attribute '__explain__'

The error is from here https://github.com/divelab/DIG/blob/83eefb10fa0d5e690dfabd352ef197bdf249d229/dig/xgraph/PGExplainer/models/GCN.py#L56

Could you please take a look at this issue? Thanks.

Oceanusity commented 2 years ago

Could you provide your pytorch_geometric version? If your pyg version is higher than 1.6, the MessgaPassing class does not contain the __explain__ variable. For the main branch, they use pytorch_geometric==1.6.0.

cxw-droid commented 2 years ago

Thank you for your reply. I changed pyg to 1.6, it works. But when I ran pipeline.py, it output error here https://github.com/divelab/DIG/blob/dd0a905c3a3c337ee1781c582b14a1abd22c9e6e/dig/xgraph/PGExplainer/pipeline.py#L113 https://github.com/divelab/DIG/blob/dd0a905c3a3c337ee1781c582b14a1abd22c9e6e/dig/xgraph/PGExplainer/load_dataset.py#L237

AttributeError: Can't get attribute 'DataEdgeAttr' on <module 'torch_geometric.data.data'

It seems I need another pyg version then?

cxw-droid commented 2 years ago

I found the reason. pipeline.py and train_gnns.py use different datasets directories. After removing the BA_shapes/processed directory used by pipeline.py, which was generated by a different pyg package, the code pipeline.py works.

CM-BF commented 2 years ago

After removing the BA_shapes/processed directory used by pipeline.py, which was generated by a different pyg package, the code pipeline.py works.

The new PyG data structure is different to the older one, which causes many problems. I highly encourage you to use the dig-stable branch with PyG version 2.X.

And you may need to notice that PyG makes changes for its explanation parts frequently. It is a good idea to stick to a specific PyG version.

Please let me know if any questions!

cxw-droid commented 2 years ago

Thank you for the update. I used the main branch because I found PGExplainer code there.

Currently there is no instructions how to run the method/pgexplainer.py code in the dig-stable branch. Although I noticed there is pgexpainer.ipynb under examples, sometimes it would be helpful to run the py code directly. Thanks.