williamleif / GraphSAGE

Representation learning on large graphs using stochastic graph convolutions.
Other
3.41k stars 841 forks source link

how sage train the node that only have 1 top neighbors? #178

Open banbsyip opened 2 years ago

banbsyip commented 2 years ago

if a node only have 1 top neighbors,should i have to remove the node before i train the sage model? or the model just train the node only use the 1 top neighbors?

sam-lev commented 2 years ago

I'm going to assume you mean one-hop neighbors (correct me if I'm wrong) but this may cause issues as the number of layers determines the aggregation. With graphsage one potential adaption you could make is to reduce the number of aggregation layers, in their tensorflow implementation this is defined as layers_info when the model is instantiated.

layer_infos = [SAGEInfo("node", sampler, FLAGS.samples_1, FLAGS.dim_1), SAGEInfo("node", sampler, FLAGS.samples_2, FLAGS.dim_2)]

Something you will also want to take into account is the number of neighbors being sampled per layer. You won't want to sample more than neighbors available although I think they will do re-sampling if you do. In the tensorflow implementation, this is defined as 'degree_l1,_l2, ... on line 221.

Out of curiosity, graphsage is good for inductive learning on large graphs. How dense is your graph?

sam-lev commented 2 years ago

I misunderstood your question/problem setting. No, you don't need to remove nodes with only 1 neighbor. If the degree of a node is less than the max degree then graphsage will perform random sampling when building the adjacency matrix.

banbsyip commented 2 years ago

I misunderstood your question/problem setting. No, you don't need to remove nodes with only 1 neighbor. If the degree of a node is less than the max degree then graphsage will perform random sampling when building the adjacency matrix.

I mean that if one node named A,the A node only have 1 degree of nodes, or the A node have no neighbor, but I set the degree to 2, how the graphsage train the A node?