train_lenet_on_mnist.sh 1.17 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
11
12
13
14
# ./slim/scripts/train_lenet_on_mnist.sh

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

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

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

23
# Run training.
24
python train_image_classifier.py \
25
26
27
28
29
30
31
  --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 \
32
  --batch_size=50 \
33
34
35
  --learning_rate=0.01 \
  --save_interval_secs=60 \
  --save_summaries_secs=60 \
36
  --log_every_n_steps=100 \
37
  --optimizer=sgd \
38
  --learning_rate_decay_type=fixed \
39
40
41
  --weight_decay=0

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