divelab / DIG

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

the methods in xgraph can only explain model in dig.xgraph.models #184

Open Oliver-0423 opened 1 year ago

Oliver-0423 commented 1 year ago

the methods in xgraph can only explain model in dig.xgraph.models,i try to use it to explain my model which is built by PYG, get the error:

KeyError: 'explain_message'

this is my model:

from torch_geometric.nn import GCNConv
class Net(torch.nn.Module):
    def __init__(self):
        super().__init__()
        self.conv1 = GCNConv(dataset.num_features, 16, normalize=False)
        self.conv2 = GCNConv(16, dataset.num_classes, normalize=False)
    def forward(self, x, edge_index):
        x = F.relu(self.conv1(x, edge_index))
        x = F.dropout(x, training=self.training)
        x = self.conv2(x, edge_index)
        return F.log_softmax(x, dim=1)
Oliver-0423 commented 1 year ago

pyg version 2.1.0, dig version 1.0.0 torch 1.13.0

Oceanusity commented 1 year ago

Please refer to the model defined in https://github.com/divelab/DIG/blob/dig-stable/dig/xgraph/models/models.py

chriswu99aaa commented 1 year ago

@Oceanusity So we can only explain models defined in the models.py file? Can we explain models that are built as the combinations from models from the file? For example, if I define a model which combines GCN_3l and GCN_2l, we the explaining methods work as well?

Oceanusity commented 1 year ago

I think so, if the new GNN is the subclass of GNNBasic.