Skip to contents

digits contains 5000 images from the MNIST dataset of all digits, consisting of 500 images per digit class from 0 to 9. Each digit image is represented as an \((28\times 28)\) matrix that sums to 1. Normalization makes intensities into probability masses and discards the original total intensity of each image.

Usage

data(digits)

Format

a named list "digits" containing

image

length-5000 list of \((28\times 28)\) image matrices.

label

length-5000 vector of class labels from 0 to 9.

Source

MNIST Database of Handwritten Digits, by Yann LeCun, Corinna Cortes, and Christopher J.C. Burges, http://yann.lecun.com/exdb/mnist/. The retained preparation fragment uses dslabs::read_mnist(), samples 500 training images per class without replacement, reshapes each row with matrix(pixel_vector, nrow = 28)[, 28:1], and normalizes total mass. Its original random seed, selected MNIST row indices, and dslabs version were not recorded. See the installed DATA_PROVENANCE for checksums, transformations, and limits of the dataset-specific licensing evidence.

References

LeCun, Y., Bottou, L., Bengio, Y., and Haffner, P. (1998). Gradient-based learning applied to document recognition. Proceedings of the IEEE, 86(11), 2278–2324. doi:10.1109/5.726791 .

Examples

## LOAD THE DATA
data(digits)

## SHOW A FEW
#  Select 9 random images
subimgs = digits$image[sample(1:5000, 9)]

opar <- par(no.readonly=TRUE)
par(mfrow=c(3,3), pty="s")
for (i in 1:9){
  image(subimgs[[i]])
}

par(opar)