Skip to main content

Extended MNIST - Python Package

Project description


Extended MNIST - Python Package

The EMNIST Dataset

The EMNIST Dataset is an extension to the original MNIST dataset to also include letters. For more details, see the EMNIST web page and the paper associated with its release:

Cohen, G., Afshar, S., Tapson, J., & van Schaik, A. (2017). EMNIST: an extension of MNIST to handwritten letters. Retrieved from

The EMNIST Python Package

This package is a convenience wrapper around the EMNIST Dataset. The package provides functionality to automatically download and cache the dataset, and to load it as numpy arrays, minimizing the boilerplate necessary to make use of the dataset. (NOTE: The author of the Python package is not affiliated in any way with the authors of the dataset and the associated paper.)


To install the EMNIST Python package along with its dependencies, run the following command:

pip install emnist

The dataset itself is automatically downloaded and cached when needed. To preemptively download the data and avoid a delay later during the execution of your program, execute the following command after installation:

python -c "import emnist; emnist.ensure_cached_data()"

Alternately, if you have already downloaded the original IDX-formatted dataset from the EMNIST web page, copy or move it to ~/.cache/emnist/, where ~ is your home folder, and rename it from to The package will use the existing file rather than downloading it again.


Usage of the EMNIST Python package is designed to be very simple.

To get a listing of the available subsets:

  >>> from emnist import list_datasets
  >>> list_datasets()
  ['balanced', 'byclass', 'bymerge', 'digits', 'letters', 'mnist']

(See the EMNIST web page for details on each of these subsets.)

To load the training samples for the 'digits' subset:

  >>> from emnist import extract_training_samples
  >>> images, labels = extract_training_samples('digits')
  >>> images.shape
  (240000, 28, 28)
  >>> labels.shape

To load the test samples for the 'digits' subset:

  >>> from emnist import extract_test_samples
  >>> images, labels = extract_test_samples('digits')
  >>> images.shape
  (40000, 28, 28)
  >>> labels.shape

Data is extracted directly from the downloaded compressed file to minimize disk usage, and is returned as standard numpy arrays.

Project details

Release history Release notifications | RSS feed

This version


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

emnist-0.0.tar.gz (6.4 kB view hashes)

Uploaded source

Built Distribution

emnist-0.0-py3-none-any.whl (7.3 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page