train_lenet_on_mnist.sh 1.18 KB
Newer Older
1
2
#!/bin/bash
#
3
4
5
6
# This script performs the following operations:
# 1. Downloads the MNIST dataset
# 2. Trains a LeNet model on the MNIST training set.
# 3. Evaluates the model on the MNIST testing set.
7
8
#
# Usage:
9
# cd slim
10
# ./slim/scripts/train_lenet_on_mnist.sh
Matt Rickard's avatar
Matt Rickard committed
11
set -e
12
13
14
15

# Where the checkpoint and logs will be saved to.
TRAIN_DIR=/tmp/lenet-model

16
# Where the dataset is saved to.
17
18
DATASET_DIR=/tmp/mnist

19
20
21
22
23
# Download the dataset
python download_and_convert_data.py \
  --dataset_name=mnist \
  --dataset_dir=${DATASET_DIR}

24
# Run training.
25
python train_image_classifier.py \
26
27
28
29
30
31
32
  --train_dir=${TRAIN_DIR} \
  --dataset_name=mnist \
  --dataset_split_name=train \
  --dataset_dir=${DATASET_DIR} \
  --model_name=lenet \
  --preprocessing_name=lenet \
  --max_number_of_steps=20000 \
33
  --batch_size=50 \
34
35
36
  --learning_rate=0.01 \
  --save_interval_secs=60 \
  --save_summaries_secs=60 \
37
  --log_every_n_steps=100 \
38
  --optimizer=sgd \
39
  --learning_rate_decay_type=fixed \
40
41
42
  --weight_decay=0

# Run evaluation.
43
python eval_image_classifier.py \
44
45
46
47
48
49
  --checkpoint_path=${TRAIN_DIR} \
  --eval_dir=${TRAIN_DIR} \
  --dataset_name=mnist \
  --dataset_split_name=test \
  --dataset_dir=${DATASET_DIR} \
  --model_name=lenet