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 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.
|
| |
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.
◆ 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_path | Path to an IDX3 (images) file, e.g. "data/MNIST/raw/train-images-idx3-ubyte". |
| labels_path | Path to an IDX1 (labels) file, e.g. "data/MNIST/raw/train-labels-idx1-ubyte". |
| backend | Backend to allocate image Tensors through. Not owned; must outlive the returned dataset's Tensors. |
| max_count | If >= 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_error | if 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: