DIG
DIG copied to clipboard
running the code example in Tutorial for GNN Explainability; error: ModuleNotFoundError: No module named 'dig.xgraph.utils.compatibility'
torch 1.10.1 torch_geometric 2.1.0 dig 0.1.2
Hello,
Thank you for such a wonderful library ! I too am facing the same issue when trying to import from dig.xgraph.utils.compatibility Any way to fix this ?
another bug: running: result = find_closest_node_result(explanation_results[prediction], max_nodes=max_nodes)
error: AttributeError: 'dict' object has no attribute 'coalition'
Has anyone run this tutorial successfully?
@YANI-ALT download from git , don't use pip install dive-into-graphs,
@YANI-ALT better don't use windows, This project is very Windows unfriendly
I tried to install through git: git clone https://github.com/divelab/DIG.git cd DIG pip install .
but got the following error:
Preparing metadata (setup.py) ... error error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [10 lines of output]
Traceback (most recent call last):
File "
note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed
× Encountered error while generating package metadata. ╰─> See above for output.
note: This is an issue with the package mentioned above, not pip. hint: See above for details.
I had the same error importing compatible_state_dict
from dig.xgraph.utils.compatibility
. It seems to be a compatibility issue, and I fixed it by downgrading my python version to 3.7 (from 3.10.8).
However, I am still having the same error as @Oliver-0423 describes:
another bug: running: result = find_closest_node_result(explanation_results[prediction], max_nodes=max_nodes)
error: AttributeError: 'dict' object has no attribute 'coalition'
It seems to me that there are a few issues with this tutorial, starting with the fact that the version on readthedocs is not up to date with the latest one on github.
From the Github version, here are the problems I noted:
- Missing import statement for Data (from torch_geometric.data)
- The
explanation_results
variable needs to be made into a MCTS tree before being fed tofind_closest_node_result
- The links for the SubgraphX and MCTS classes are not redirecting properly
- It seems like the
visualization
function does not take (anymore?) the prediction as an input parameter, thus we need to remove it and replace our newly MCTS'ed explanation_results byexplanation_results[prediction]
- For the quantitative explanation, the
explanation_results
again have to be MCTS'ed
Additionally for the quantitative explanation part, the related_preds
consist of {'masked', 'maskout', 'origin', 'sparsity'}, and I'm not sure how the fidelity metric is derived from those in the tutorial. I get the same value for the sparsity, but calculating the fidelity+ or fidelity- metrics (presented in https://arxiv.org/abs/2012.15445) gives me very different results from the .1384 of the tutorial.
I'm new to the library and unsure about my conclusions, would it be possible to have a confirmation from @Oceanusity, @CM-BF or maybe @mengliu1998 (sorry for the ping) ? If confirmed, I can fix those issues and submit a PR.
same problem.
This compatibility module is only available on dig-stable branch. For different dig, you may refer to the different tutorials. If you are unsure about the version you are using, I would recommend using the examples in <Project_root>/examples/xgraph/ to start. The examples and the code are one-to-one corresponding.
another bug: running: result = find_closest_node_result(explanation_results[prediction], max_nodes=max_nodes)
error: AttributeError: 'dict' object has no attribute 'coalition'
Has anyone run this tutorial successfully?
It can be repaired by adding the following code at the beginning of the function find_closest_node_result in .../dig/xgraph/method/subgraphx.py
if isinstance(results[0], dict):
results = [MCTSNode(device='cpu').load_info(node_info) for node_info in results]
It looks like the example code mixes list of MCTSNode and list of dict.
I also had the problem
AttributeError: 'dict' object has no attribute 'coalition'