Sign inSign up

alikhil/mnist

By alikhil

Updated over 7 years ago

Image
0

280

alikhil/mnist repository overview

PyTorch MNIST for Docker

A simple CNN model for MNIST using PyTorch framework in a Docker container based on official PyTorch tutorial.

Pull

Pull image from DockerHub with:

docker pull alikhil/mnist:latest

Running

MNIST model supports three modes:

  • fit – fitting a new model
  • predict – making an inference on a valid input
  • eval – evaluating a model on a valid input with labels

Note: prediction and evaluation can only run after the fit.

The general command for running the image is:

docker run -t --rm \
    -v volume-mnist:/app/state \
    -v "$(pwd)"/data:/app/data \
    alikhil/mnist:latest \
    --mode [running mode (default: fit)] \
    --batch-size [(optinal) training batch_size] \
    --epochs [(optinal) number of training epochs] \
    --model-path [(optinal) path to save the model]

Model parameters are saved at /app/state inside a container. To use the same model across multiple runs, option -v volume-mnist:/app/state is necessary.

To use own train or test data, create a directory data with files inside your current working directory and use -v "$(pwd)"/data:/app/data with docker run.

fit
  • To train a model on original MNIST train data use:
docker run -t --rm -v volume-mnist:/app/state alikhil/mnist:latest --mode fit
  • To train a model on your own data X_train.npy and y_train.npy, add files to directory ./data on your host machine and use:
docker run -t --rm \
    -v volume-mnist:/app/state \
    -v "$(pwd)"/data:/app/data \
    alikhil/mnist:latest --mode fit

Note: If input files X_train.npy and y_train.npy are not found or invalid, original MNIST train data will be used.

predict
  • Assuming, you have trained a model, run a model inference on MNIST test data with:
docker run -t --rm \
    -v volume-mnist:/app/state \
    alikhil/mnist:latest --mode predict
  • To make predictions on your own data X_test.npy, add file to directory ./data on your host machine and use::
docker run -t --rm \
    -v volume-mnist:/app/state -v "$(pwd)"/data:/app/data \
    alikhil/mnist:latest --mode predict

Inference results will be saved at data/y_pred.npy.

Note: if input file X_test.npy is not found or invalid, original MNIST test data will be used.

eval
  • Assuming, you have trained a model, run a model evaluation on MNIST test data with:
docker run -t --rm \
    -v volume-mnist:/app/state \
    alikhil/mnist:latest --mode eval
  • To make evaluation on your own data X_test.npy and y_test.npy, add these files to directory ./data on your host machine and use::
docker run -t --rm \
    -v volume-mnist:/app/state -v "$(pwd)"/data:/app/data \
    alikhil/mnist:latest --mode eval

Note: If input files X_test.npy and y_test.npy are not found or invalid, original MNIST test data will be used.

Tag summary

Content type

Image

Digest

Size

222 MB

Last updated

over 7 years ago

docker pull alikhil/mnist