tkipf / gcn

Implementation of Graph Convolutional Networks in TensorFlow
MIT License
7.12k stars 2k forks source link

What is the model architectural difference between transductive GCN and inductive GraphSAGE? #168

Open guotong1988 opened 4 years ago

guotong1988 commented 4 years ago

Difference of the model design.

It seems the difference is that GraphSAGE sample the data.

But what is the difference in model architecture.

Thank you very much.

@tkipf

tkipf commented 4 years ago

The main novelty of GraphSAGE is a neighborhood sampling step (but this is independent of whether these models are used inductively or transductively). You can think of GraphSAGE as GCN with subsampled neighbors.

In practice, both can be used inductively and transductively.

The title of the GraphSAGE paper ("Inductive representation learning") is unfortunately a bit misleading in that regard. The main benefit of the sampling step of GraphSAGE is scalability (but at the cost of higher variance gradients).

guotong1988 commented 4 years ago

Thank you very much.

tkipf commented 4 years ago

No worries :) I'll leave this open since this question seems to appear quite frequently (so others can more easily find it).

steveazzolin commented 2 years ago

I have a followup question.

I noticed that, despite what said above by @tkipf, Pytorch Geometric has a different implementation for GraphSAGE and GCN. To the best of my knowledge the neighbors subsampling is implemented by NeighborLoader (an 'external' DataLoader), so I haven't understood why keeping two separate implementations.

In addition, by looking at the PyG documentation:

image

image

So, it seems that the difference between the two is that GraphSAGE runs a simple mean of nearby embeddings, while GCN applies a weighted mean, with weights the normalization coefficients.

Is this the right architectural difference or is just a PyG implementation difference?

Thanks