pytorch_geometric icon indicating copy to clipboard operation
pytorch_geometric copied to clipboard

How to get new node's embedding

Open zll931041456 opened this issue 4 years ago • 5 comments

❓ Questions & Help

GraphSAGE is a inductive methods,Can I use trained model to get new node's embedding,how to do?

zll931041456 avatar Apr 29 '20 10:04 zll931041456

I am not sure if I fully understand your question. If you have a trained model, you can of course apply it to unseen graphs.

rusty1s avatar Apr 29 '20 20:04 rusty1s

@rusty1s What's the difference between SAGEConv and GraphSAGE? based on the provided example I expected that the output of GraphSAGE would be the same as SAGEConv which is a dictionary of key: x_dict and value: the embeddings calculated for them. However I found out that the output is tuple of [sourceEdge, type, targetEdge].

Is there any way to extend the provided example with GraphSAGE for link prediction?

shahinghasemi avatar Sep 02 '22 13:09 shahinghasemi

SAGEConv is the GNN operator which performs a single round of message passing. GraphSAGE refers to the full model that stacks the SAGEConv building blocks into a neural network architecture.

As such, the output of the encoder is indeed a dictionary that holds the node's embedding for every node type. Let me know if this clarifies things for you.

rusty1s avatar Sep 05 '22 06:09 rusty1s

Sorry but I'm confused a little bit. Are these two model the same?(num_layers is confusing)

# first
GraphSAGE(in_channels=(-1, -1), hidden_channels=32, num_layers=2, out_channels=32)

# second
SAGEConv((-1, -1), 32)
SAGEConv((-1, -1), 32)

shahinghasemi avatar Sep 05 '22 09:09 shahinghasemi

Nearly, the first one will also use a non-linearity between the two GNN layers.

rusty1s avatar Sep 06 '22 14:09 rusty1s