Fork me on GitHub
Arraymancer Technical reference Tutorial Spellbook (How-To's) Under the hood

mnist

Procs

proc read_mnist_images(imgsPath: string): Tensor[uint8] {...}{.noInit,
    raises: [IOError, OSError, Exception], tags: [ReadDirEffect, ReadIOEffect].}
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/

  Source Edit
proc read_mnist_labels(stream: Stream): Tensor[uint8] {...}{.noInit,
    raises: [Exception, IOError], tags: [ReadIOEffect].}
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
  Source Edit
proc read_mnist_labels(labelsPath: string): Tensor[uint8] {...}{.noInit,
    raises: [IOError, OSError, Exception], tags: [ReadDirEffect, ReadIOEffect].}
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/

  Source Edit
proc load_mnist(cache: static bool = true): Mnist
Loads the MNIST dataset into a tuple with fields:
  • train_images
  • train_labels
  • test_images
  • test_labels

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, yhis 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
  Source Edit