divelab / DIG

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

Problem with subgraphx gnns calling find closest node result #95

Closed Hannnne closed 2 years ago

Hannnne commented 2 years ago

Hi,

When calling closest node result for metric score as suggest in example examples/xgraph/subgraphx.ipynb.

like this:

_, explanation_results, related_preds = \
        explainer(data.x, data.edge_index, node_idx=node_idx, max_nodes=max_nodes)

    explanation_results = explanation_results[prediction]
    explanation_results = explainer.read_from_MCTSInfo_list(explanation_results)
    result = find_closest_node_result(explanation_results, max_nodes=max_nodes)

I am getting following error

 results = sorted(results, key=lambda x: len(x.coalition))
AttributeError: 'dict' object has no attribute 'coalition'

I fixed it by offering an option for dictionaries, but I am still wondering why it happens. Can someone give me a hint, why that is happening?

Thank you Hanne

Oceanusity commented 2 years ago

Sorry for the late reply, and this problem surprises me too. From the code, the explanation_results save a list of dictionaries, and read_from_MCTSInfo_list loads the list of dictionaries to a list of MCTSNode. Therefore, the explanation_results passed to find_closest_node_result should be a list of MCTSNode. However, this error shows that this variable is a list of dictionaries, which is not expected.

Oceanusity commented 2 years ago

Welcome to reopen this issue if you still have this problem.