divelab / DIG

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

'GNNExplainer' object has no attribute 'node_idx' with BA_shapes #243

Open scottdd204 opened 5 months ago

scottdd204 commented 5 months ago

I have tried working back through the problem but more issues crop up, this is only the case with BA_shapes @Oceanusity

~/DIG$ DATASETS=ba_shapes

~/DIG$ HYDRA_FULL_ERROR=1 python -m benchmarks.xgraph.gnn_explainer datasets=$DATASETS explainers=gnn_explainer record_filename=/home/scott/DIG/benchmarks/xgraph/results/GNNExplainer /home/scott/DIG/benchmarks/xgraph/gnn_explainer.py:18: UserWarning: The version_base parameter is not specified. Please specify a compatability version level, or None. Will assume defaults for version 1.1 @hydra.main(config_path="config", config_name="config") /home/scott/.local/lib/python3.8/site-packages/hydra/_internal/defaults_list.py:251: UserWarning: In 'config': Defaults list is missing _self_. See https://hydra.cc/docs/1.2/upgrades/1.0_to_1.1/default_composition_order for more information warnings.warn(msg, UserWarning) /home/scott/.local/lib/python3.8/site-packages/hydra/_internal/hydra.py:119: UserWarning: Future Hydra versions will no longer change working directory at job runtime by default. See https://hydra.cc/docs/1.2/upgrades/1.1_to_1.2/changes_to_job_working_dir/ for more information. ret = run_job( models: gnn_saving_dir: /home/scott/DIG/benchmarks/xgraph/checkpoints gnn_name: gcn param: learning_rate: 0.05 weight_decay: 0.0005 milestones: None gamma: None batch_size: 1 num_epochs: 400 num_early_stop: 0 gnn_latent_dim:

/home/scott/miniconda3/envs/DIG/lib/python3.8/site-packages/torch_geometric/data/in_memory_dataset.py:300: UserWarning: It is not recommended to directly access the internal storage format data of an 'InMemoryDataset'. If you are absolutely certain what you are doing, access the internal storage via InMemoryDataset._data instead to suppress this warning. Alternatively, you can access stacked individual attributes of every graph via dataset.{attr_name}. warnings.warn(msg) Error executing job with overrides: ['datasets=ba_shapes', 'explainers=gnn_explainer', 'record_filename=/home/scott/DIG/benchmarks/xgraph/results/GNNExplainer', 'explainers=gnn_explainer', 'datasets.dataset_root=/home/scott/DIG/benchmarks/xgraph/datasets', 'models.gnn_saving_dir=/home/scott/DIG/benchmarks/xgraph/checkpoints', 'explainers.explanation_result_dir=/home/scott/DIG/benchmarks/xgraph/results', 'record_filename=/home/scott/DIG/benchmarks/xgraph/result_jsons'] Traceback (most recent call last): File "/home/scott/miniconda3/envs/DIG/lib/python3.8/runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "/home/scott/miniconda3/envs/DIG/lib/python3.8/runpy.py", line 87, in _run_code exec(code, run_globals) File "/home/scott/DIG/benchmarks/xgraph/gnn_explainer.py", line 216, in pipeline() File "/home/scott/.local/lib/python3.8/site-packages/hydra/main.py", line 94, in decorated_main _run_hydra( File "/home/scott/.local/lib/python3.8/site-packages/hydra/_internal/utils.py", line 394, in _run_hydra _run_app( File "/home/scott/.local/lib/python3.8/site-packages/hydra/_internal/utils.py", line 457, in _run_app run_and_report( File "/home/scott/.local/lib/python3.8/site-packages/hydra/_internal/utils.py", line 223, in run_and_report raise ex File "/home/scott/.local/lib/python3.8/site-packages/hydra/_internal/utils.py", line 220, in run_and_report return func() File "/home/scott/.local/lib/python3.8/site-packages/hydra/_internal/utils.py", line 458, in lambda: hydra.run( File "/home/scott/.local/lib/python3.8/site-packages/hydra/internal/hydra.py", line 132, in run = ret.return_value File "/home/scott/.local/lib/python3.8/site-packages/hydra/core/utils.py", line 260, in return_value raise self._return_value File "/home/scott/.local/lib/python3.8/site-packages/hydra/core/utils.py", line 186, in run_job ret.return_value = task_function(task_cfg) File "/home/scott/DIG/benchmarks/xgraph/gnn_explainer.py", line 138, in pipeline gnn_explainer(data.x, data.edge_index, File "/home/scott/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1511, in _wrapped_call_impl return self._call_impl(*args, *kwargs) File "/home/scott/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1520, in _call_impl return forward_call(args, **kwargs) File "/home/scott/DIG/dig/xgraph/method/gnnexplainer.py", line 159, in forward edge_mask = self.gnn_explainer_alg(x, edge_index, ex_label).sigmoid() File "/home/scott/DIG/dig/xgraph/method/gnnexplainer.py", line 96, in gnn_explainer_alg loss = self.loss(raw_preds, ex_label) File "/home/scott/DIG/dig/xgraph/method/gnnexplainer.py", line 58, in loss loss = cross_entropy_with_logit(raw_preds[self.node_idx].reshape(1, -1), x_label) File "/home/scott/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1688, in getattr raise AttributeError(f"'{type(self).name}' object has no attribute '{name}'") AttributeError: 'GNNExplainer' object has no attribute 'node_idx'