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

Jumping Knowledge support for Heterogeneous Graph Features #9355

Closed
m-atalla opened this issue May 24, 2024 · 1 comment · Fixed by #9380
Closed

Jumping Knowledge support for Heterogeneous Graph Features #9355

m-atalla opened this issue May 24, 2024 · 1 comment · Fixed by #9380
Labels

Comments

@m-atalla
Copy link
Contributor

🚀 The feature, motivation and pitch

Dear PyG Developers,

Currently the Jumping Knowledge module (JK) only supports homogeneous features input, that is inputs with the type signature List[Tensor]

This feature would promote JK as a potential drop-in improvement when experimenting on relevant heterogeneous tasks. I propose adding the class HeteroJK for heterogeneous inputs (for brevity's sake, I omitted comments/imports):

class HeteroJK(torch.nn.Module):
    def __init__(self, metadata: Metadata, **kwargs):
        super().__init__()
        self.jk = ModuleDict()
        for node_type in metadata[0]:
            self.jk[node_type] = JumpingKnowledge(**kwargs)

    def forward(self, dict_xs: Dict[str, List[Tensor]]) -> Dict[str, List[Tensor]]:
        out_dict = {}
        for node_type, xs in dict_xs.items():
            out_dict[node_type] = self.jk[node_type](xs)
        return out_dict

Alternatives

Modify the existing JumpingKnowledge module so that It'd also accept heterogeneous inputs, which would alter the type signature of the input to be Union[List[Tensor], Dict[str, List[Tensor]]], the return type would be changed similarly.

I'm happy to help implement either approach if this feature is a welcomed addition to PyG.

Thank you for your time and consideration.

Additional context

No response

@rusty1s
Copy link
Member

rusty1s commented May 27, 2024

This sounds like a good feature to me. Feel free to send a PR :)

@rusty1s rusty1s linked a pull request Jun 6, 2024 that will close this issue
rusty1s added a commit that referenced this issue Jun 6, 2024
Hi,

this PR implements #9355, please do let me know if any additional
changes or documentation is needed.
Thank you

---------

Co-authored-by: rusty1s <matthias.fey@tu-dortmund.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants