dgl.dataloading.MultiLayerFullNeighborSampler¶
-
class
dgl.dataloading.
MultiLayerFullNeighborSampler
(num_layers, **kwargs)[source]¶ Sampler that builds computational dependency of node representations by taking messages from all neighbors for multilayer GNN.
This sampler will make every node gather messages from every single neighbor per edge type.
- Parameters
n_layers (int) – The number of GNN layers to sample.
kwargs – Passed to
dgl.dataloading.NeighborSampler
.
Examples
To train a 3-layer GNN for node classification on a set of nodes
train_nid
on a homogeneous graph where each node takes messages from all neighbors for the first, second, and third layer respectively (assuming the backend is PyTorch):>>> sampler = dgl.dataloading.MultiLayerFullNeighborSampler(3) >>> dataloader = dgl.dataloading.DataLoader( ... g, train_nid, sampler, ... batch_size=1024, shuffle=True, drop_last=False, num_workers=4) >>> for input_nodes, output_nodes, blocks in dataloader: ... train_on(blocks)
Notes
For the concept of MFGs, please refer to User Guide Section 6 and Minibatch Training Tutorials.
-
__init__
(num_layers, **kwargs)[source]¶ Initialize self. See help(type(self)) for accurate signature.
Methods
__init__
(num_layers, **kwargs)Initialize self.
assign_lazy_features
(result)Assign lazy features for prefetching.
sample
(g, seed_nodes[, exclude_eids])Sample a list of blocks from the given seed nodes.
sample_blocks
(g, seed_nodes[, exclude_eids])Generates a list of blocks from the given seed nodes.