Utilities for working with the MNIST dataset of handwritten images.
Examples
// require the mnist-data module
var mnist = require('mnist-data');
// retrieve a slice of the first 100 objects from the training set
var training_data = mnist.training(100);
training_data.labels.values[0]; // the label 0-9 of the first handwritten digit in the slice
training_data.images.values[0]; // the matrix of 0-255 greyscale values for each pixel of the 28x28 image
// retrieve a slice of the first 100 objects from the testing set
var testing_data = mnist.testing(100);
// the label 0-9 of the first handwritten digit in the slice
testing_data.labels.values[0];
// the matrix of 0-255 greyscale values for each pixel of the 28x28 image
testing_data.images.values[0];
Methods
(static) testing(n, m) → {object}
Retrieve a slice (n,m) from the `t10k-images-idx3-ubyte` and `t10k-labels-idx1-ubyte` files.
Parameters:
Name | Type | Description |
---|---|---|
n |
number | start index of training labels and images to retrieve. if m is undefined, n becomes the end index, while the start index becomes 0. |
m |
number | (optional) end index of training labels and images to retrieve. |
Returns:
images: data about the images, labels: data about the labels
- Type
- object
(static) training(n, m) → {object}
Retrieve a slice (n,m) from the `train-images-idx3-ubyte` and `train-labels-idx1-ubyte` files.
Parameters:
Name | Type | Description |
---|---|---|
n |
number | start index of training labels and images to retrieve. if m is undefined, n becomes the end index, while the start index becomes 0. |
m |
number | (optional) end index of training labels and images to retrieve. |
Returns:
images: data about the images, labels: data about the labels
- Type
- object