syna.datasets.mnist module

MNIST dataset

class syna.datasets.mnist.MNIST(root: str | None = None, train: bool = True, download: bool = True, transform: Callable | None = None, target_transform: Callable | None = None, flatten: bool = True, normalize: bool = True)[source]

Bases: Sequence

Minimal MNIST dataset.

Args:

root: base directory to store/download MNIST files (defaults to ~/.syna/datasets) train: True for training split, False for test split download: whether to attempt download when files are missing transform: optional callable applied to images (receives numpy array HxW) target_transform: optional callable applied to labels flatten: whether to flatten images to (H*W,) vectors. If False, returns (1,H,W). normalize: if True, convert uint8 [0,255] to float32 [0,1]

syna.datasets.mnist.load_mnist(root: str | None = None, train: bool = True, download: bool = True) MNIST[source]

Convenience factory for MNIST dataset.