GraphSAINTNodeSampler
¶
GraphSAINTNodeSampler(
data: GraphData,
batch_size: int,
num_steps: int = 1,
sample_coverage: int = 0,
save_dir: Optional[str] = None,
)
Bases: GraphSAINTSampler
GraphSAINT node sampler: samples batch_size edges uniformly at
random and keeps their source nodes (so nodes are drawn proportionally to
their out-degree), then takes the induced subgraph.
See GraphSAINTSampler for the arguments and the batch content.
Example:
from mlx_graphs.loaders import GraphSAINTNodeSampler
loader = GraphSAINTNodeSampler(
data, batch_size=6000, num_steps=5, sample_coverage=100
)
for batch in loader:
out = model(batch.node_features, batch.edge_index)
loss = (batch.node_norm * loss_fn(out, batch.node_labels)).sum()
Source code in mlx_graphs/loaders/graph_saint.py
from mlx_graphs.loaders import GraphSAINTNodeSampler · mlx_graphs/loaders/graph_saint.py