DIG icon indicating copy to clipboard operation
DIG copied to clipboard

running the code example in Tutorial for GNN Explainability; error: ModuleNotFoundError: No module named 'dig.xgraph.utils.compatibility'

Open Oliver-0423 opened this issue 2 years ago • 11 comments

Oliver-0423 avatar Nov 22 '22 02:11 Oliver-0423

torch 1.10.1 torch_geometric 2.1.0 dig 0.1.2

Oliver-0423 avatar Nov 22 '22 02:11 Oliver-0423

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 ?

YANI-ALT avatar Nov 23 '22 03:11 YANI-ALT

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?

Oliver-0423 avatar Nov 23 '22 07:11 Oliver-0423

@YANI-ALT download from git , don't use pip install dive-into-graphs,

Oliver-0423 avatar Nov 25 '22 08:11 Oliver-0423

@YANI-ALT better don't use windows, This project is very Windows unfriendly

Oliver-0423 avatar Nov 25 '22 08:11 Oliver-0423

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 "", line 2, in File "", line 34, in File "C:\Users\yhl20\AppData\Local\Temp\pip-install-69uiodic\pyscf_b8c62cba3e4e4704af415c5acfeb55a5\setup.py", line 206, in blas_path_guess = [search_lib_path('lib'+x+so_ext, blas_lib_dir) File "C:\Users\yhl20\AppData\Local\Temp\pip-install-69uiodic\pyscf_b8c62cba3e4e4704af415c5acfeb55a5\setup.py", line 206, in blas_path_guess = [search_lib_path('lib'+x+so_ext, blas_lib_dir) File "C:\Users\yhl20\AppData\Local\Temp\pip-install-69uiodic\pyscf_b8c62cba3e4e4704af415c5acfeb55a5\setup.py", line 148, in search_lib_path paths = os.environ.get(LD_LIBRARY_PATH, '').split(os.pathsep) NameError: name 'LD_LIBRARY_PATH' is not defined [end of output]

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.

yhliu2022 avatar Nov 26 '22 22:11 yhliu2022

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 to find_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 by explanation_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.

timondesch avatar Nov 29 '22 01:11 timondesch

same problem.

frankwxu avatar Nov 29 '22 21:11 frankwxu

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.

CM-BF avatar Feb 20 '23 21:02 CM-BF

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.

citceae avatar Feb 20 '24 15:02 citceae

I also had the problem AttributeError: 'dict' object has no attribute 'coalition'

ZhongLIFR avatar Mar 11 '24 12:03 ZhongLIFR