klyn.math.datasets.MNIST.load
method
public static load<T extends AbstractFloat = Float>(folder as Path = null, trainLimit as Long = 0l, testLimit as Long = 0l, download as Boolean = true) as Tuple<NDArray<T>, NDArray<Int>, NDArray<T>, NDArray<Int>>
Description

Loads the train and t10k IDX image/label files, downloading missing files. Each filename ends in -images-idx3-ubyte or -labels-idx1-ubyte. Input is streamed into the returned tensors, without retaining another complete byte dataset. Reusable byte blocks are normalized directly into typed floating storage, without allocating an object per pixel. Loading all images uses about 105 MiB of FP16 or 210 MiB of FP32 image data. Missing files are fetched over HTTPS, verified and decompressed into the cache. Existing IDX files are reused without network access. Downloads use the curl executable; decompression uses Klyn's own DEFLATE implementation. Interactive downloads show a live progress bar on standard error; cached loads are silent and redirected output uses plain status messages.

Parameters
ParameterDescription
<T>Float16, Float or Double image storage; labels remain Int.
folderIDX directory; null selects ~/datasets/mnist.
trainLimitLeading training samples; zero selects the whole split.
testLimitLeading test samples; zero selects the whole split.
downloadAllow retrieval of missing files; false requires local IDX files.
Returns

(xTrain, yTrain, xTest, yTest), in that exact order.

Throws
  • IOException for unavailable files, network or integrity failures.
  • ValueException for invalid IDX data or limits.
Example

xTrain, yTrain, xTest, yTest = MNIST.load(trainLimit=2000, testLimit=1000)