MNIST

Various functions for accessing the MNIST dataset.

dynn.data.mnist.download_mnist(path='.', force=False)

Downloads MNIST from “http://yann.lecun.com/exdb/mnist/

Parameters:
  • path (str, optional) – Local folder (defaults to “.”)
  • force (bool, optional) – Force the redownload even if the files are already at path
dynn.data.mnist.load_mnist(path)

Loads the MNIST dataset

Returns MNIST as a dictionary.

Example:

mnist = load_mnist(".")
# Train images and labels
train_imgs, train_labels = mnist["train"]
# Test images and labels
test_imgs, test_labels = mnist["test"]

The images are represented as numpy arrays and the labels as integers.

Parameters:path (str) – Path to the folder containing the *-ubyte.gz files
Returns:MNIST dataset
Return type:dict
dynn.data.mnist.read_mnist(split, path)

Iterates over the MNIST dataset

Example:

for image in read_mnist("train", "/path/to/mnist"):
    train(image)
Parameters:
  • split (str) – Either "training" or "test"
  • path (str) – Path to the folder containing the *-ubyte files
Returns:

image, label

Return type:

tuple