dmlc / dgl

Python package built to ease deep learning on graph, on top of existing DL frameworks.
http://dgl.ai
Apache License 2.0
13.51k stars 3.02k forks source link

Where is Inductive codes for GraphSAGE? #1408

Closed zhaohan-xi closed 2 years ago

zhaohan-xi commented 4 years ago

Hi all, a simple question about GraphSAGE samples, I run the train_full.py but seems like that one is transductive learning. Any inductive graph learning sample codes about GraphSAGE?

BarclayII commented 4 years ago

Hi,

Sorry for the extremely late reply. There is currently no existing code for inductive learning with GraphSAGE. However, the only difference between inductive learning and transductive learning (in terms of definition in GraphSAGE's paper) is that the training graph and the testing graph are different: the training graph only consists of the nodes in the training and validation set, while the testing graph also includes the test set nodes.

One can simply train the GraphSAGE model on the subgraph by replacing the graph with g.subgraph(torch.cat([train_node_ids, val_node_ids])).

Please feel free to follow up. Thanks.

snash4 commented 4 years ago

Hi Barclayll, I didn't understand your answer, could you please explain it more, thanks.

In inductive learning, the objective is to get an embedding of an unseen node(a new node in graph) from a trained model. By this definition, the model doesn't need to be re-trained. Correct me if I am wrong.

HongHuangNeu commented 4 years ago

@BarclayII Correct me if I am wrong: What you do to deal with unseen node is: (1)add the initial embedding of the unseen nodes to the node tensor (2)add edges intrioduced by these unseen nodes to the original trainging graph (3)feed the new node tensor and new graph constructed in step (1) and (2) into the model and get the resulting tensor. The vector at the corresponding position of the resulting tensor should be the embedding vector for the unseen nodes

Am I correct?

github-actions[bot] commented 2 years ago

This issue has been automatically marked as stale due to lack of activity. It will be closed if no further activity occurs. Thank you

github-actions[bot] commented 2 years ago

This issue is closed due to lack of activity. Feel free to reopen it if you still have questions.