-
Notifications
You must be signed in to change notification settings - Fork 3
/
run_sweep_clip.sh
executable file
·149 lines (126 loc) · 4.62 KB
/
run_sweep_clip.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/bin/bash
data_dir=./datasets/
base_output_dir=./checkpoints
launcher=slurm_launcher
setup=clip_resnet
clip_model=RN50 # RN50, ViT-B/32
algorithm_array=(CLIPPretrained SupCLIPBottleneckBase SupCLIPBottleneckCondCAD)
########### datasets except for DomainNet #########
dataset_array=(PACS VLCS OfficeHome TerraIncognita)
for dataset in ${dataset_array[@]}; do
for algorithm in ${algorithm_array[@]}; do
if [[ "$algorithm" == "CLIPPretrained" ]] || [[ "$algorithm" == "SupCLIPBottleneckBase" ]]
then
if [[ "$algorithm" == "CLIPPretrained" ]]
then
n_params=1
else
n_params=10
fi
subdir_name=base
group_name=${setup}_${dataset}_${algorithm}_${subdir_name}
subdir=${dataset}/${setup}/${algorithm}/${subdir_name}
python -m domainbed.scripts.sweep_clip delete_and_launch\
--data_dir=${data_dir}\
--output_dir=${base_output_dir}/${subdir}\
--command_launcher ${launcher}\
--algorithms ${algorithm}\
--datasets ${dataset}\
--n_hparams ${n_params}\
--n_trials 5\
--skip_confirmation\
--train_script domainbed.scripts.train_clip\
--single_test_envs\
--wandb_group ${group_name}\
--task 'domain_generalization'\
--hparams '{"clip_model":"'"${clip_model}"'","mlp_depth":2}'
elif [[ "$algorithm" == "SupCLIPBottleneckCondCAD" ]]
then
lambda=1e-2
subdir_name=lambda_${lambda}
group_name=${setup}_${dataset}_${algorithm}_${subdir_name}
subdir=${dataset}/${setup}/${algorithm}/${subdir_name}
python -m domainbed.scripts.sweep_clip delete_and_launch\
--data_dir=${data_dir}\
--output_dir=${base_output_dir}/${subdir}\
--command_launcher ${launcher}\
--algorithms ${algorithm}\
--datasets ${dataset}\
--n_hparams 10\
--n_trials 5\
--skip_confirmation\
--train_script domainbed.scripts.train_clip\
--single_test_envs\
--wandb_group ${group_name}\
--task 'domain_generalization'\
--hparams '{"lmbda":'"${lambda}"',"clip_model":"'"${clip_model}"'","mlp_depth":2}'
else
echo "Unknown algorithms: ${algorithm}"
exit
fi
done
done
########## special: DomainNet (refit with pytorch implemented classifier with minibatch training) #########
dataset_array=(DomainNet)
for dataset in ${dataset_array[@]}; do
for algorithm in ${algorithm_array[@]}; do
if [[ "$algorithm" == "CLIPPretrained" ]] || [[ "$algorithm" == "SupCLIPBottleneckBase" ]]
then
if [[ "$algorithm" == "CLIPPretrained" ]]
then
n_params=1
else
n_params=10
fi
subdir_name=base
group_name=${setup}_${dataset}_${algorithm}_${subdir_name}
subdir=${dataset}/${setup}/${algorithm}/${subdir_name}
python -m domainbed.scripts.sweep_clip delete_and_launch\
--data_dir=${data_dir}\
--output_dir=${base_output_dir}/${subdir}\
--command_launcher ${launcher}\
--algorithms ${algorithm}\
--datasets ${dataset}\
--n_hparams ${n_params}\
--n_trials 5\
--skip_confirmation\
--train_script domainbed.scripts.train_clip\
--single_test_envs\
--wandb_group ${group_name}\
--task 'domain_generalization'\
--hparams '{"clip_model":"'"${clip_model}"'","mlp_depth":2,"max_epoch": 200, "clf_type": "LogisticPT"}'
elif [[ "$algorithm" == "SupCLIPBottleneckCondCAD" ]]
then
if [[ "$clip_model" == "RN50" ]]
then
lambda=1
elif [[ "$clip_model" == "ViT-B/32" ]]
then
lambda=1e-1
else
echo "Unknown model: ${clip_model}"
exit
fi
subdir_name=lambda_${lambda}
group_name=${setup}_${dataset}_${algorithm}_${subdir_name}
subdir=${dataset}/${setup}/${algorithm}/${subdir_name}
python -m domainbed.scripts.sweep_clip delete_and_launch\
--data_dir=${data_dir}\
--output_dir=${base_output_dir}/${subdir}\
--command_launcher ${launcher}\
--algorithms ${algorithm}\
--datasets ${dataset}\
--n_hparams 10\
--n_trials 5\
--skip_confirmation\
--train_script domainbed.scripts.train_clip\
--single_test_envs\
--wandb_group ${group_name}\
--task 'domain_generalization'\
--hparams '{"lmbda":'"${lambda}"',"clip_model":"'"${clip_model}"'","mlp_depth":2,"max_epoch": 200, "clf_type": "LogisticPT"}'
else
echo "Unknown algorithms: ${algorithm}"
exit
fi
done
done