Procs
proc load_mnist(cache: static bool = true; fashion_mnist: static bool = false): Mnist
-
Loads the MNIST dataset into a tuple with fields:
- train_images
- train_labels
- test_images
- test_labels
If fashion_mnist = true is provided, the Fashion MNIST dataset will be loaded instead.
Use the cache argument (bool) as false to cleanup the files each time.
The cache by default will be in ~/.cache/arraymancer on Unix and %USERNAME%/.cache/arraymancer on Windows, this can be changed with the XDG_CACHE_HOME environment variable.
This proc will:
- download the files if necessary
- unzip them
- load into a tuple
- delete the downloaded files if cache is false
proc read_mnist_images(imgsPath: string): Tensor[uint8] {.noinit, ...raises: [IOError, OSError], tags: [ReadDirEffect, WriteIOEffect, ReadIOEffect], forbids: [].}
-
Load MNIST images into a Tensor[uint8] Input:
- A path to a MNIST images file
Returns:
- A tensor of images with shape (N, H, W)
- N, number of images
- H, height
- W, width
MNIST data can be downloaded here: http://yann.lecun.com/exdb/mnist/
Fashion MNIST data can be downloaded here: http://fashion-mnist.s3-website.eu-central-1.amazonaws.com/
Source Edit proc read_mnist_labels(labelsPath: string): Tensor[uint8] {.noinit, ...raises: [IOError, OSError], tags: [ReadDirEffect, WriteIOEffect, ReadIOEffect], forbids: [].}
-
Load MNIST labels into a Tensor[uint8] from a file Input:
- A path to a MNIST labels file
Returns:
- A tensor of labels with shape (N)
- N, number of images
MNIST data can be downloaded here: http://yann.lecun.com/exdb/mnist/
Fashion MNIST data can be downloaded here: http://fashion-mnist.s3-website.eu-central-1.amazonaws.com/
Source Edit proc read_mnist_labels(stream: Stream): Tensor[uint8] {.noinit, ...raises: [IOError, OSError], tags: [WriteIOEffect, ReadIOEffect], forbids: [].}
-
Load MNIST labels into a Tensor[uint8] from a file Input:
- A stream of MNIST labels data
Returns:
- A tensor of labels with shape (N)
- N, number of images