Skip to main content

Simple MNIST and EMNIST data parser written in pure Python

Project description

Simple MNIST data parser written in pure Python.

MNIST is a database of handwritten digits available on http://yann.lecun.com/exdb/mnist/.

Requirements

  • Python 2 or Python 3

Usage

  • git clone https://github.com/sorki/python-mnist

  • cd python-mnist

  • Get MNIST data:

    ./get_data.sh
  • Check preview with:

    PYTHONPATH=. ./bin/mnist_preview

Installation

Get the package from PyPi:

pip install python-mnist

or install with setup.py:

python setup.py install

Code sample:

from mnist import MNIST
mndata = MNIST('./dir_with_mnist_data_files')
images, labels = mndata.load_training()

To enable loading of gzip-ed files use:

mndata.gz = True

EMNIST

Supports EMNIST dataset as well https://www.nist.gov/itl/iad/image-group/emnist-dataset

  • Get EMNIST data:

    ./get_emnist_data.sh
  • Check preview with:

    PYTHONPATH=. ./bin/emnist_preview

To use EMNIST datasets you need to call:

mndata.select_emnist('digits')

Where digits is one of the available EMNIST datasets. You can choose from

  • balanced

  • byclass

  • bymerge

  • digits

  • letters

  • mnist

EMNIST loader uses gziped files by default, this can be disabled by by setting:

mndata.gz = False

You also need to unpack EMNIST files as get_emnist_data.sh script won’t do it for you. EMNIST loader also needs to mirror and rotate images so it is a bit slower (If this is an issue for you, you should repack the data to avoid mirroring and rotation on each load).

Project details


Download files

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

Source Distribution

python-mnist-0.4.tar.gz (9.8 kB view details)

Uploaded Source

File details

Details for the file python-mnist-0.4.tar.gz.

File metadata

  • Download URL: python-mnist-0.4.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for python-mnist-0.4.tar.gz
Algorithm Hash digest
SHA256 c56da1a2548249589c19cb7f42a19a596aeeea882389e1c59874f0a08a1c6614
MD5 59442f30965fabaf04923efbdc937f78
BLAKE2b-256 ca08715f8172fc60a5fcc046e193ddc6cd0fb6e1986e42660945294f0ad2cdc6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page