FakeDataset
¶
FakeDataset(
num_graphs: int = 1,
avg_num_nodes: int = 1000,
avg_degree: float = 10.0,
num_channels: int = 64,
edge_dim: int = 0,
num_classes: int = 10,
task: FAKE_TASKS = "auto",
is_undirected: bool = True,
seed: Optional[int] = None,
pre_transform: Optional[Callable] = None,
transform: Optional[Callable] = None,
**kwargs: Union[int, tuple[int, ...]],
)
Bases: Dataset
A fake dataset that returns randomly generated
GraphData objects, useful to test models and
pipelines without downloading anything.
Node features are standard normal samples shifted by the (node or graph)
label, so that the classification task is learnable. Graphs are generated
once at construction and are deterministic for a given seed.
This dataset follows the implementation of PyG,
with an additional seed argument. The random values differ from PyG's
since they are drawn from NumPy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_graphs
|
int
|
The number of graphs. Default: |
1
|
avg_num_nodes
|
int
|
The average number of nodes in a graph; the number of
nodes of each graph is drawn uniformly in
|
1000
|
avg_degree
|
float
|
The average degree per node. Default: |
10.0
|
num_channels
|
int
|
The number of node features. If |
64
|
edge_dim
|
int
|
The number of edge features. If |
0
|
num_classes
|
int
|
The number of classes in the dataset. Default: |
10
|
task
|
FAKE_TASKS
|
Whether to return node-level ( |
'auto'
|
is_undirected
|
bool
|
Whether the graphs are undirected. Default: |
True
|
seed
|
Optional[int]
|
Seed of the random number generator. Default: |
None
|
pre_transform
|
Optional[Callable]
|
A function/transform applied to each graph once, after generation. |
None
|
transform
|
Optional[Callable]
|
A function/transform applied to the graph at every access. |
None
|
**kwargs
|
Union[int, tuple[int, ...]]
|
Additional graph attributes and their shapes, e.g.
|
{}
|
Example:
from mlx_graphs.datasets import FakeDataset
dataset = FakeDataset(num_graphs=4, avg_num_nodes=20, seed=0)
>>> fake(num_graphs=4)
dataset[0]
>>> GraphData(
edge_index(shape=(2, 316), int32)
node_features(shape=(24, 64), float32)
graph_labels(shape=(1,), int32))
Source code in mlx_graphs/datasets/fake.py
from mlx_graphs.datasets import FakeDataset · mlx_graphs/datasets/fake.py