TemporalNeighborSampler๏
- class dgl.graphbolt.TemporalNeighborSampler(datapipe, graph, fanouts, replace=False, prob_name=None, node_timestamp_attr_name=None, edge_timestamp_attr_name=None)[source]๏
Bases:
TemporalNeighborSamplerImpl
Temporally sample neighbor edges from a graph and return sampled subgraphs.
Functional name:
temporal_sample_neighbor
.Neighbor sampler is responsible for sampling a subgraph from given data. It returns an induced subgraph along with compacted information. In the context of a node classification task, the neighbor sampler directly utilizes the nodes provided as seed nodes. However, in scenarios involving link prediction, the process needs another pre-peocess operation. That is, gathering unique nodes from the given node pairs, encompassing both positive and negative node pairs, and employs these nodes as the seed nodes for subsequent steps.
- Parameters:
datapipe (DataPipe) โ The datapipe.
graph (FusedCSCSamplingGraph) โ The graph on which to perform subgraph sampling.
fanouts (list[torch.Tensor] or list[int]) โ The number of edges to be sampled for each node with or without considering edge types. The length of this parameter implicitly signifies the layer of sampling being conducted. Note: The fanout order is from the outermost layer to innermost layer. For example, the fanout โ[15, 10, 5]โ means that 15 to the outermost layer, 10 to the intermediate layer and 5 corresponds to the innermost layer.
replace (bool) โ Boolean indicating whether the sample is preformed with or without replacement. If True, a value can be selected multiple times. Otherwise, each value can be selected only once.
prob_name (str, optional) โ The name of an edge attribute used as the weights of sampling for each node. This attribute tensor should contain (unnormalized) probabilities corresponding to each neighboring edge of a node. It must be a 1D floating-point or boolean tensor, with the number of elements equalling the total number of edges.
node_timestamp_attr_name (str, optional) โ The name of an node attribute used as the timestamps of nodes. It must be a 1D integer tensor, with the number of elements equalling the total number of nodes.
edge_timestamp_attr_name (str, optional) โ The name of an edge attribute used as the timestamps of edges. It must be a 1D integer tensor, with the number of elements equalling the total number of edges.
Examples
TODO(zhenkun) : Add an example after the API to pass timestamps is finalized.