-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfinetune_resnet_v1_101_on_cancer.sh
77 lines (68 loc) · 2.24 KB
/
finetune_resnet_v1_101_on_cancer.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/bash
#
# This script performs the following operations:
# 1. Fine-tunes a ResNetV1-101 model on the Breast Cancer (Malignant) training set.
# 2. Evaluates the model on the Breast Cancer (Malignant) validation set.
#
# Usage:
# ./scripts/finetune_ResNetV1_101_on_cancer.sh
# Where the pre-trained ResNetV1-101 checkpoint is saved to.
PRETRAINED_CHECKPOINT_DIR=/Desktop/checkpoints
# Where the training (fine-tuned) checkpoint and logs will be saved to.
TRAIN_DIR=/Desktop/BC_malignant_data/resnet_v1_101
# Where the dataset is saved to.
DATASET_DIR=/Desktop/BC_malignant_data
# Fine-tune only the new layers for 3000 steps.
cd ~/Desktop/TFslim_fine_tune
python train_image_classifier.py \
--train_dir=${TRAIN_DIR} \
--dataset_name=cancers \
--dataset_split_name=train \
--dataset_dir=${DATASET_DIR} \
--model_name=resnet_v1_101 \
--checkpoint_path=${PRETRAINED_CHECKPOINT_DIR}/resnet_v1_101.ckpt \
--checkpoint_exclude_scopes=resnet_v1_101/logits \
--trainable_scopes=resnet_v1_101/logits \
--max_number_of_steps=3000 \
--batch_size=32 \
--learning_rate=0.01 \
--save_interval_secs=60 \
--save_summaries_secs=60 \
--log_every_n_steps=100 \
--optimizer=rmsprop \
--weight_decay=0.00004
# Run evaluation.
cd ~/Desktop/TFslim_fine_tune
python eval_image_classifier.py \
--checkpoint_path=${TRAIN_DIR} \
--eval_dir=${TRAIN_DIR} \
--dataset_name=cancers \
--dataset_split_name=validation \
--dataset_dir=${DATASET_DIR} \
--model_name=resnet_v1_101
# Fine-tune all the new layers for 3000 steps.
cd ~/Desktop/TFslim_fine_tune
python train_image_classifier.py \
--train_dir=${TRAIN_DIR}/all \
--dataset_name=cancers \
--dataset_split_name=train \
--dataset_dir=${DATASET_DIR} \
--checkpoint_path=${TRAIN_DIR} \
--model_name=resnet_v1_101 \
--max_number_of_steps=3000 \
--batch_size=32 \
--learning_rate=0.001 \
--save_interval_secs=60 \
--save_summaries_secs=60 \
--log_every_n_steps=100 \
--optimizer=rmsprop \
--weight_decay=0.00004
# Run evaluation.
cd ~/Desktop/TFslim_fine_tune
python eval_image_classifier.py \
--checkpoint_path=${TRAIN_DIR}/all \
--eval_dir=${TRAIN_DIR}/all \
--dataset_name=cancers \
--dataset_split_name=validation \
--dataset_dir=${DATASET_DIR} \
--model_name=resnet_v1_101