NeighborSampler for k-hop sampling
See original GitHub issue❓ Questions & Help
I have a hard time understanding NeighborSampler
even with small examples. It doesn’t make sense in most cases.
l = np.array([[0, 1], [1, 4], [1, 5], [1, 6], [0, 2], [2, 7], [0, 3], [3, 8], [3, 9], [3, 10], [3, 11]]).transpose()
r = np.array([l[1, :], l[0, :]])
edge_index = torch.from_numpy(r)
train_loader = NeighborSampler(edge_index,
sizes=[2, 2], batch_size=1)
for batch_size, n_id, adjs in train_loader:
print("###")
for edge_ind, e_id, size in adjs:
print(e_id)
gives me:
tensor([ 4, 0, 10, 8, 3, 1])
tensor([6, 0])
It looks like it jumps over edges?
How can I use it for k-hop sampling?
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
NeighborSampler — DGL 0.9.1post1 documentation
Sampler that builds computational dependency of node representations via neighbor sampling for multilayer GNN. This sampler will make every node gather messages ...
Read more >torch_geometric.loader — pytorch_geometric documentation
A data loader that performs mini-batch sampling from node information, ... The neighbor sampler from the "Inductive Representation Learning on Large Graphs" ...
Read more >NeighborSampler for k-hop sampling · Issue #1391 - GitHub
The NeighborSampler example looks correct to me. It samples two edges in the last layer for node 0: to nodes 1 and 3....
Read more >How to use the dgl.contrib.sampling.NeighborSampler ... - Snyk
To help you get started, we've selected a few dgl.contrib.sampling.NeighborSampler examples, based on popular ways it is used in public projects.
Read more >Region or Global? A Principle for Negative Sampling in Graph ...
Neighbor Sampler S. It is necessary to sample neigh- bors for the central node to apply GNN for ... and the items outside...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The NeighborSampler example looks correct to me. It samples two edges in the last layer for node 0: to nodes 1 and 3. in the first layer, it samples 6 edges for nodes 0, 1 and 3: to nodes 1, 4, 6, 2, 9, 11.
Regarding your second issue: You pass in two edges, but 3 edge features. So that‘s an expected crash and isn‘t related to symmetric adjacencies.
Edge 0 and Edge 4 are sampled for node 0 in layer 1. The NeighborSampler will recursively sample neighbors/edges for all nodes encountered in all previous layers, e.g., for applying skip-connections.