Sampler that builds computational dependency of node representations via labor sampling for multilayer GNN from the NeurIPS 2023 paper `Layer-Neighbor Sampling -- Defusing Neighborhood Explosion in GNNs `__ This sampler will make every node gather m
(
g,
nodes,
fanout,
edge_dir="in",
prob=None,
importance_sampling=0,
random_seed=None,
seed2_contribution=0,
copy_ndata=True,
copy_edata=True,
exclude_edges=None,
output_device=None,
)
| 30 | |
| 31 | |
| 32 | def sample_labors( |
| 33 | g, |
| 34 | nodes, |
| 35 | fanout, |
| 36 | edge_dir="in", |
| 37 | prob=None, |
| 38 | importance_sampling=0, |
| 39 | random_seed=None, |
| 40 | seed2_contribution=0, |
| 41 | copy_ndata=True, |
| 42 | copy_edata=True, |
| 43 | exclude_edges=None, |
| 44 | output_device=None, |
| 45 | ): |
| 46 | """Sampler that builds computational dependency of node representations via |
| 47 | labor sampling for multilayer GNN from the NeurIPS 2023 paper |
| 48 | `Layer-Neighbor Sampling -- Defusing Neighborhood Explosion in GNNs |
| 49 | <https://arxiv.org/abs/2210.13339>`__ |
| 50 | |
| 51 | This sampler will make every node gather messages from a fixed number of neighbors |
| 52 | per edge type. The neighbors are picked uniformly with default parameters. For every vertex t |
| 53 | that will be considered to be sampled, there will be a single random variate r_t. |
| 54 | |
| 55 | For each node, a number of inbound (or outbound when ``edge_dir == 'out'``) edges |
| 56 | will be randomly chosen. The graph returned will then contain all the nodes in the |
| 57 | original graph, but only the sampled edges. |
| 58 | |
| 59 | Node/edge features are not preserved. The original IDs of |
| 60 | the sampled edges are stored as the `dgl.EID` feature in the returned graph. |
| 61 | |
| 62 | Parameters |
| 63 | ---------- |
| 64 | g : DGLGraph |
| 65 | The graph, allowed to have multiple node or edge types. Can be either on CPU or GPU. |
| 66 | nodes : tensor or dict |
| 67 | Node IDs to sample neighbors from. |
| 68 | |
| 69 | This argument can take a single ID tensor or a dictionary of node types and ID tensors. |
| 70 | If a single tensor is given, the graph must only have one type of nodes. |
| 71 | fanout : int or dict[etype, int] |
| 72 | The number of edges to be sampled for each node on each edge type. |
| 73 | |
| 74 | This argument can take a single int or a dictionary of edge types and ints. |
| 75 | If a single int is given, DGL will sample this number of edges for each node for |
| 76 | every edge type. |
| 77 | |
| 78 | If -1 is given for a single edge type, all the neighboring edges with that edge |
| 79 | type will be selected. |
| 80 | edge_dir : str, optional |
| 81 | Determines whether to sample inbound or outbound edges. |
| 82 | |
| 83 | Can take either ``in`` for inbound edges or ``out`` for outbound edges. |
| 84 | prob : str, optional |
| 85 | Feature name used as the (unnormalized) probabilities associated with each |
| 86 | neighboring edge of a node. The feature must have only one element for each |
| 87 | edge. |
| 88 | |
| 89 | The features must be non-negative floats, and the sum of the features of |
nothing calls this directly
no test coverage detected