-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsteer.sh
executable file
·137 lines (106 loc) · 3.84 KB
/
steer.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
#! /bin/bash
#
# USAGE: steer.sh <output directory>
#
# probably this script needs adaptation if the scan should be performed
# in different variables than listed here by default.
# the structure, however, can be used in the same way and should
# be self-explanatory.
# For large scale trainings, refer to the comment "COMMENT FOR LARGE SCALE TRAININGS"
# a few lines below the user options
## steering options
# selects the number of the GPU that will be filled with jobs first
# inclusive - meaning lowestGpuToUse=5 will start with GPU 5!
lowestGpuToUse=5
# selects the number of the GPU that will be filled with jobs last;
# inclusive - meaning highestGpuToUse=7 will also fill GPU 7 if needed!
highestGpuToUse=7
# list of different lambdas to scan
lmbs="30"
# list of different learning rates to scan
LRs="0.0005"
# list of different weights for the domain-adaptation loss to scan
weights="2"
# training option (run option in AdaptMeDelphes) that should be compared
# to the standard MC training or data training
compare='corrected_domain_adaptation'
# number of trainings to run for each configuration to estimate statistical
# fluctuations. if this parameter is changed, it will need to be changed in make_plot.py, too
ntrainings=5
# selects the number of processes that are run on a single GPU.
# default: 5 is optimised for the default GPU fraction in AdaptMeDelphes.py.
# this parameter should not need changes
nprocpergpu=5
outputdir=$1
echo $outputdir
if [[ -z $outputdir ]]
then
echo "specify output dir"
exit
fi
#next run with weight 2 but in same output dir
mkdir -p $outputdir
cp AdaptMeDelphes.py $outputdir/
cp make_samples.py $outputdir/
cp block_models.py $outputdir/
cp Layers.py $outputdir/
cp training_tools.py $outputdir/
ngpus=$(($highestGpuToUse-$lowestGpuToUse))
nprocstotal=$(($nprocpergpu*$ngpus))
nprocs=0
procpergpu=0
igpu=$lowestGpuToUse
# COMMENT FOR LARGE SCALE TRAININGS
# please refer to the occurence of these variables in case of large-scale trainings
# with constant data and MC training. Then it makes sense to just link the data/MC training
# output rather than repeating the training each time. The paths here are just an example
linkdata=/afs/cern.ch/user/j/jkiesele/work/DeepLearning/DomAdapt/delphes_domain_ada/stepwise3/0.0005/10/1/data_training
linkmc=/afs/cern.ch/user/j/jkiesele/work/DeepLearning/DomAdapt/delphes_domain_ada/stepwise3/0.0005/10/1/MC_training
for lmb in $lmbs; do
for LR in $LRs; do
for weight in $weights; do
jobout=$outputdir/$LR/$lmb/$weight
mkdir -p $jobout
# uncomment if data and MC training should only be linked and comment the corresponding
# parts in the following method loop in turn
#ln -s $linkdata $jobout/
#ln -s $linkmc $jobout/
for method in $compare 'MC_training' 'data_training'; do #'MC_training' 'data_training'
for i in $(seq $ntrainings); do
echo $jobout/$method/$i $method
python $outputdir/AdaptMeDelphes.py $jobout/$method/$i $method --weight $weight --lr $LR --lmb $lmb --gpu=$igpu --gpufraction=0.17 &> $jobout/$method.$i.log &
echo "gpu ${igpu}, proc: ${procpergpu}"
nprocs=$(($nprocs+1))
procpergpu=$(($procpergpu+1))
if [ $nprocpergpu -eq $procpergpu ]
then
if [ $igpu -eq $highestGpuToUse ]
then
igpu=$lowestGpuToUse
echo waiting
wait
else
igpu=$((igpu + 1))
fi
procpergpu=0
fi
done
#python compute_averages.py $jobout/$method
done
done
done
#python make_plots.py $jobout
done
echo waiting
wait
for lmb in $lmbs; do
for LR in $LRs; do
for weight in $weights; do
jobout=$outputdir/$LR/$lmb/$weight
for method in 'MC_training' 'data_training' $compare; do
python compute_averages.py $jobout/$method
done
python make_plots.py $jobout -c $compare
done
done
done