API¶
Tinymesh exposes direct objects over tinygrad tensors. There is no model factory, trainer, or PyTorch compatibility layer.
Core¶
Graph
dataclass
¶
An immutable directed graph over ordinary tinygrad tensors.
Methods:
-
cartesian–Return the directed Cartesian product over left-major node pairs.
-
edge_values–Gather node values into original COO edge order.
-
in_degree–Return incoming degree on one device.
-
mean–Mean incoming values over node axis -2, with zero for empty rows.
-
softmax–Normalize scalar edge scores over each target's incoming edges.
-
sum–Sum incoming values over node axis -2 with optional shared edge weights.
-
sum_edges–Sum COO-ordered edge values at their target nodes over axis -2.
Source code in src/tinymesh/graph.py
cartesian
¶
Return the directed Cartesian product over left-major node pairs.
Left-factor edges precede right-factor edges in the returned COO order. The one-node edgeless graph is an exact identity. Products are associative as edge multisets; regrouping factors can permute COO edge order.
Source code in src/tinymesh/graph.py
edge_values
¶
Gather node values into original COO edge order.
Source code in src/tinymesh/graph.py
in_degree
¶
Return incoming degree on one device.
mean
¶
Mean incoming values over node axis -2, with zero for empty rows.
Source code in src/tinymesh/graph.py
softmax
¶
Normalize scalar edge scores over each target's incoming edges.
Source code in src/tinymesh/graph.py
sum
¶
Sum incoming values over node axis -2 with optional shared edge weights.
Source code in src/tinymesh/graph.py
sum_edges
¶
Sum COO-ordered edge values at their target nodes over axis -2.
Source code in src/tinymesh/graph.py
StaticGraphTemporalSignal
dataclass
¶
StaticGraphTemporalSignal(graph: Graph, node_ids: tuple[str, ...], x: Tensor, y: Tensor, edge_weight: Tensor | None = None)
Bases: Sequence[tuple[Tensor, Tensor]]
An ordered tensor signal over one immutable graph.
Methods:
-
batches–Yield causal sequence-to-one windows as [B, L, N, F] and [B, N, Y].
-
split–Split once along time, preserving order and topology.
batches
¶
Yield causal sequence-to-one windows as [B, L, N, F] and [B, N, Y].
Source code in src/tinymesh/temporal.py
split
¶
split(train_ratio: float) -> tuple[StaticGraphTemporalSignal, StaticGraphTemporalSignal]
Split once along time, preserving order and topology.
Source code in src/tinymesh/temporal.py
TemporalEdges
dataclass
¶
TemporalEdges(nodes: int, source: tuple[int, ...], target: tuple[int, ...], timestamp: tuple[int, ...])
Timestamped directed edges over one stable node universe.
Methods:
-
prefix–Return the events with timestamps strictly before
cutoff.
prefix
¶
prefix(cutoff: int) -> TemporalEdges
Return the events with timestamps strictly before cutoff.
Source code in src/tinymesh/temporal.py
Neural networks¶
SAGEConv
¶
Mean GraphSAGE over one homogeneous graph.
Source code in src/tinymesh/nn/__init__.py
GINEConv
¶
Edge-aware graph isomorphism convolution over shared edge features.
Source code in src/tinymesh/nn/__init__.py
GCNConv
¶
GATConv
¶
GATConv(in_features: int, out_features: int, heads: int = 1, negative_slope: float = 0.2, bias: bool = True)
Graph attention with independently normalized concatenated heads.
Source code in src/tinymesh/nn/__init__.py
ChebConv
¶
Chebyshev graph convolution for symmetric, loop-free unit edges.
Source code in src/tinymesh/nn/__init__.py
TGCN
¶
One temporal graph convolutional recurrent step.
Source code in src/tinymesh/nn/__init__.py
PeriodAttention
¶
A3TGCN
¶
Attention over T-GCN encodings of a fixed number of periods.
Source code in src/tinymesh/nn/__init__.py
GConvGRU
¶
One Chebyshev graph-convolutional recurrent step.
Source code in src/tinymesh/nn/__init__.py
DirectedDiffusion
¶
DirectedDiffusion(graph: Graph, affinity: Tensor)
Bidirectional propagation for caller-validated positive affinity.
Source code in src/tinymesh/nn/__init__.py
DiffusionGRU
¶
One gated recurrent step over bidirectional directed diffusion.
Source code in src/tinymesh/nn/__init__.py
Datasets¶
chickenpox
¶
chickenpox(path: str | Path | None = None, *, lags: int = 4, device: str | None = None) -> StaticGraphTemporalSignal
Load the PyG Temporal Hungary chickenpox signal.
Source code in src/tinymesh/datasets.py
MontevideoBus
dataclass
¶
MontevideoBus(signal: StaticGraphTemporalSignal, position: Tensor, road_distance: Tensor)
The aligned PyG Temporal Montevideo bus signal.
montevideo_bus
¶
montevideo_bus(path: str | Path | None = None, *, lags: int = 4, device: str | None = None) -> MontevideoBus
Load the PyG Temporal Montevideo bus signal without normalization.
Source code in src/tinymesh/datasets.py
METRLA
dataclass
¶
METRLA(graph: Graph, sensor_ids: tuple[str, ...], timestamps: tuple[datetime, ...], speed: Tensor, affinity: Tensor)
metr_la
¶
metr_la(path: str | Path | None = None, *, device: str | None = None) -> METRLA
Load raw METR-LA speed and reproduce the directed DCRNN affinity.
Source code in src/tinymesh/datasets.py
MUTAG
dataclass
¶
MUTAG(graphs: tuple[Graph, ...], node_labels: tuple[Tensor, ...], edge_labels: tuple[Tensor, ...], labels: tuple[int, ...])
MUTAG molecular graphs with categorical atom, bond, and graph labels.
mutag
¶
mutag(path: str | Path | None = None, *, device: str | None = None) -> MUTAG
Load the TU Dortmund MUTAG molecular graph collection.
Source code in src/tinymesh/datasets.py
CollegeMsg
dataclass
¶
CollegeMsg(events: TemporalEdges, node_ids: tuple[int, ...])
Directed private-message events with retained source node identities.
college_msg
¶
college_msg(path: str | Path | None = None) -> CollegeMsg
Load the checksum-pinned CollegeMsg temporal interaction stream.