Skip to content

Quick Start

nickcdryan edited this page Mar 29, 2018 · 2 revisions

MNIST Classification

As a quick introduction to the Nearist platform, we will run through a provided source code example which performs k-Nearest Neighbors classification of the MNIST hand written digit dataset.

Obtaining Access

In order to access a Nearist appliance server you will need the following items, which are provided by speaking with a Nearist representative:

  1. An API key.
  2. A reservation time. Your API key will only work during an active reservation.
  3. The IP address of your reserved appliance.

Installing the API

You can install the client libraries with pip:

pip install nearist

or by cloning the repository and adding the /python/src/ directory to your PYTHONPATH.

Obtaining the Dataset

We have already generated the dataset for this example by applying a Convolutional Neural Network to extract 1,024 component feature vectors for all 65,000 images in the MNIST dataset.

The dataset consists of four files in HDF5 format, all of which can be downloaded directly from here:

File Dimensions Component Size Size Description
X_train_uint8.h5 55000 x 1024 float 56.3 MB Extracted feature vectors for training images.
y_train.h5 55000 x 1 int 0.2 MB Labels (0 - 9) for training images.
X_test_uint8.h5 10000 x 1024 float 10.2 MB Extracted feature vectors for test images.
y_test.h5 10000 x 1 int 0.1 MB Labels (0 - 9) for test images.

The training vectors are what we will be performing the k-NN search on, so these are the vectors which must be loaded into the Nearist appliance. The file 'X_train_uint8.h5' is already stored on the hard disk of your reserved Nearist appliance, so you do not need to download it to your own computer.

The other three files need to be downloaded to your computer and stored in /nearist/python/examples/data/

Running the Example

The /python/examples/MNIST/ directory contains instructions and code for running the k-Nearest Neighbors Classifier on Nearist hardware.

  1. Update the script run_classification.py with your API key and the provided IP address.
  2. Run python run_classification.py

This will return the elapsed time and accuracy of the k-NN Classifier using Nearist hardware.