-
Notifications
You must be signed in to change notification settings - Fork 1
/
run_imagenet_subset_entropy.sh
50 lines (42 loc) · 1.46 KB
/
run_imagenet_subset_entropy.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
#!/usr/bin/bash
#
# Copyright (c) 2023-present, Royal Bank of Canada.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
mkdir -p ./log
ARCH=resnet34
LOSS=sat_entropy
DATASET=imagenet_subset
PRETRAIN=150
MOM=0.9
seed=42
epochs=500
nClasses=150
batch_size=64
entropy=0.01
# Parsing arguments
while getopts ":s:n:e:" flag; do
case "${flag}" in
s) seed=${OPTARG};;
n) nClasses=${OPTARG};;
e) entropy=${OPTARG};;
:) # If expected argument omitted:
echo "Error: -${OPTARG} requires an argument."
exit_abnormal;; # Exit abnormally.
*) # If unknown (any other) option:
exit_abnormal;; # Exit abnormally.
esac
done
SAVE_DIR='./log/'
### train
python -u train.py --arch ${ARCH} --pretrain ${PRETRAIN} --sat-momentum ${MOM} \
--loss ${LOSS} --manualSeed ${seed} --entropy ${entropy}\
--dataset ${DATASET} --save ${SAVE_DIR} --epochs ${epochs} --num_classes ${nClasses} --train-batch ${batch_size}\
2>&1 | tee -a ${SAVE_DIR}.log
### eval
python -u train.py --arch ${ARCH} --manualSeed ${seed}\
--loss ${LOSS} --dataset ${DATASET} --entropy ${entropy}\
--save ${SAVE_DIR} --evaluate --epochs ${epochs} --num_classes ${nClasses} --train-batch ${batch_size}\
2>&1 | tee -a ${SAVE_DIR}.log