-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun_semisup_fullprecision.sh
92 lines (82 loc) · 2 KB
/
run_semisup_fullprecision.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env bash
set -x
set -e
base_dir='./'
exp_name='exp_semi_sup_fullprec_1'
dataset_path='path/to/imagenet/dataset'
train=True
linear=True
knn=True
if [ $train == True ]
then
CUDA_VISIBLE_DEVICES=0,1,2,3 python -m semi_supervised.train_pseudo_cmsf \
--base-dir $base_dir \
--exp $exp_name\
--learning_rate 0.05\
--batch_size 256\
--use_conf \
--conf_th 0.85\
--cache_sup\
--pseudo_lbl_epochs 10\
--pseudo_lbl_lr_schedule '15,30,40'\
--margin 0.3\
--dataset imagenet \
--cos \
--weak_strong \
--epochs 200 \
--arch resnet50 \
--mlp_xent mlp \
--topk 10 \
--momentum 0.99 \
--mem_bank_size 128000 \
--sup_mem_bank_size 128000 \
--save_freq 10\
--sup-split-file 'semi_supervised/imagenet_subsets/1p_10p/subsets/10percent.txt' \
$dataset_path
fi
exp="${base_dir}exp/semi_sup_cmsf/$exp_name"
ep=10
if [ $linear == True ]
then
CUDA_VISIBLE_DEVICES=0,1 python -m semi_supervised.eval_linear\
-j 16 \
--lr 0.001\
--lr_schedule '15,35,50'\
--epochs 20\
--fine-tune\
--arch 'resnet50'\
--load-epoch $ep\
--dataset imagenet\
--train-file 'semi_supervised/imagenet_subsets/1p_10p/subsets/10percent.txt'\
--weights $exp/checkpoints/ckpt_epoch_$ep.pth\
--save $exp/linear\
$dataset_path
echo $exp
echo 'epoch: '$ep
fi
if [ $knn == True ]
then
CUDA_VISIBLE_DEVICES=0,1 python -m semi_supervised.eval_knn\
--arch 'resnet50'\
--epoch $ep\
--dataset imagenet\
--batch-size 256\
-k 1\
--weights $exp/checkpoints/ckpt_epoch_$ep.pth\
--train-file 'semi_supervised/imagenet_subsets/1p_10p/subsets/10percent.txt'\
--save $exp/features \
--save-acc \
$dataset_path
echo $exp
echo 'epoch: '$ep
fi
res_dir="$exp/results"
mkdir "$res_dir"
if [ $linear == True ]
then
cp "$exp/linear/logs_ep_$ep" "$res_dir"
fi
if [ $knn == True ]
then
cp "$exp/features/nn_*_acc_epoch_$ep.txt" "$res_dir"
fi