Skip to content

message passing for multiple feature arrays #166

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

Closed
YichengDWu opened this issue May 17, 2022 · 5 comments
Closed

message passing for multiple feature arrays #166

YichengDWu opened this issue May 17, 2022 · 5 comments

Comments

@YichengDWu
Copy link
Contributor

Hello and thank you for your excellent work!

If I have multiple feature arrays, how should I define a customized message function? I want to have something like

message(xi,xj,ui,uj) = xxx

This feature is available in torch_geometric. However, it seems like by design it is not possible in GraphNeuralNetworks.jl but we have to concatenate x and u?

@CarloLucibello
Copy link
Member

CarloLucibello commented May 18, 2022

You just put all your features inside a named tuple:

ndata = (a = rand(3, num_nodes), b = rand(3, num_nodes))

message(xi, xj, e)= xi.a .+ xj.b

propagate(message, g, +,  xi=ndata, xj=ndata)

Conversely, message functions can return named tuples as well.

@YichengDWu
Copy link
Contributor Author

YichengDWu commented May 18, 2022

You just put all your features inside a named tuple:

ndata = (x = rand(3, num_nodes), b = rand(3, num_nodes))

message(xi, xj, e)= xi.x .+ xj.b

propagate(message, g, +,  x=ndata)

Conversely, message functions can return named tuples as well.

Sorry, I'm still confused about how it works. What is the keyword argument x here? I couldn't find its definiton in the source code.

@YichengDWu
Copy link
Contributor Author

By the way, I found a typo in the doc:

xj: As xj, but to be materialized on edges' sources.

Should it be

xj: As xi, but to be materialized on edges' sources.

@CarloLucibello
Copy link
Member

Sorry, I'm still confused about how it works. What is the keyword argument x here? I couldn't find its definiton in the source code.

sorry, I thought we had that shortcut. I edited the comment.

By the way, I found a typo in the doc

thanks, fixed now!

@YichengDWu
Copy link
Contributor Author

I see. I honestly think it would be a good idea if we have

propagate(message, g, +,  x=ndata)==propagate(message, g, +,  xi=ndata, xj=ndata)

since quite often we indeed have x=xi=xj

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