pulsatrix
Loading...
Searching...
No Matches
pulsatrix::MnistIdxLoader Class Reference

Reads MNIST's original IDX-format files directly – no format conversion, no generic Dataset abstraction. MNIST-specific by deliberate scope decision (see plan_mnist_classification_training_example.md's Recon); if a future mission needs a second real dataset, generalize then. More...

#include <mnist_loader.hpp>

Static Public Member Functions

static MnistDataset Load (const std::string &images_path, const std::string &labels_path, DeviceBackend *backend, int64_t max_count=-1)
 Loads one images/labels IDX file pair.
 

Detailed Description

Reads MNIST's original IDX-format files directly – no format conversion, no generic Dataset abstraction. MNIST-specific by deliberate scope decision (see plan_mnist_classification_training_example.md's Recon); if a future mission needs a second real dataset, generalize then.

Note
Files are fetched once via tools/fetch_mnist.py to data/MNIST/raw/ (gitignored, not part of this repo's tracked source) – callers/tests must handle their absence gracefully (GTEST_SKIP() in tests), not assume they exist.

Member Function Documentation

◆ Load()

static MnistDataset pulsatrix::MnistIdxLoader::Load ( const std::string &  images_path,
const std::string &  labels_path,
DeviceBackend *  backend,
int64_t  max_count = -1 
)
static

Loads one images/labels IDX file pair.

Parameters
images_pathPath to an IDX3 (images) file, e.g. "data/MNIST/raw/train-images-idx3-ubyte".
labels_pathPath to an IDX1 (labels) file, e.g. "data/MNIST/raw/train-labels-idx1-ubyte".
backendBackend to allocate image Tensors through. Not owned; must outlive the returned dataset's Tensors.
max_countIf >= 0, load at most this many images/labels (from the start of the file) rather than the full file – for sizing a training subset without a separate truncation step. -1 (default) loads everything.
Returns
The parsed dataset.
Exceptions
std::runtime_errorif a file can't be opened, its IDX magic number doesn't match the expected type, or it's shorter than its own header claims – external boundary (file content, not an internal invariant).

The documentation for this class was generated from the following file: