Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can it be used with HeteroConv? #2

Open
huaizhenkou opened this issue Jul 15, 2024 · 2 comments
Open

Can it be used with HeteroConv? #2

huaizhenkou opened this issue Jul 15, 2024 · 2 comments

Comments

@huaizhenkou
Copy link

This is a great job! I tried to use it with HeteroConv, but it failed. Can the author offer any advice?

@Ryanfzhang
Copy link
Owner

This is a great job! I tried to use it with HeteroConv, but it failed. Can the author offer any advice?

Can you provide some details about the errors?

@huaizhenkou
Copy link
Author

It seems the issue lies within my code. I encountered an error similar to the one discussed in pyg-team/pytorch_geometric#5652. I built a model as shown below, but neither ChebConv nor kanChebConv supports handling heterogeneous graphs. They require the input x to be a tensor, not a tuple. Do you know how to resolve this issue? I would greatly appreciate your help.

class HeteroCheb(nn.Module):
    def __init__(self, edge_types, in_channels, hidden_channels, out_channels, dropout=0.5):
        super(HeteroCheb, self).__init__()

        self.conv1 = HeteroConv({
            edge_type: ChebConv(in_channels, hidden_channels, K=2)
            for edge_type in edge_types
        }, aggr='sum')

        self.conv2 = HeteroConv({
            edge_type: ChebConv(hidden_channels, out_channels, K=2)
            for edge_type in edge_types
        }, aggr='sum')

        self.dropout = dropout
        self.name = 'HeteroGCN_without_pooling'

    def forward(self, x_dict, edge_index_dict):
        x_dict = self.conv1(x_dict, edge_index_dict)
        x_dict = {key: x.relu() for key, x in x_dict.items()}
        x_dict = {key: F.dropout(x, p=self.dropout, training=self.training) for key, x in x_dict.items()}
        x_dict = self.conv2(x_dict, edge_index_dict)
        return x_dict

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants