-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtrain_VBF.sh
More file actions
executable file
·126 lines (110 loc) · 4.05 KB
/
train_VBF.sh
File metadata and controls
executable file
·126 lines (110 loc) · 4.05 KB
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
#!/bin/bash
# Example of usage
#./train_VBF.sh
#./train_VBF.sh -m mlp_pf -d VBF_features
#./train_VBF.sh -m deepak8_pf -d VBF_features
#./train_VBF.sh -m particlenet_pf -d VBF_points_features
#./train_VBF.sh -e "--batch-size 512 --num-n_epochs 3"
#./train_VBF.sh -p pred_all -o trainings/particlenet_pf/*VBF_points_features_epoch_10_cat012
set -x
echo "args: $@"
# Defining nominal variables
model="particlenet_pf"
data="VBF_points_features"
flag_test=""
n_gpus=""
n_epochs="1"
extra_name=""
inputdir="/eos/home-a/anmalara/Public/DNNInputs"
data_train_ref="${inputdir}/eventCategory_0/MC*M1[2][4-6]*UL1[6-7-8]*.root"
data_val_ref="${inputdir}/eventCategory_0/MC*M1[2][0]*UL1[6-7-8]*.root"
data_test_ref="${inputdir}/eventCategory_0/MC*M1[3][0]*UL1[6-7-8]*.root"
data_train="${data_train_ref}"
data_val="${data_val_ref}"
data_test="${data_test_ref}"
mode="train"
outputdir=""
while getopts m:d:f:t:v:x:g:e:n:p:o: flag
do
case "${flag}" in
m) model=${OPTARG};;
d) data=${OPTARG};;
f) flag_test=${OPTARG};;
t) data_train=${OPTARG};;
v) data_val=${OPTARG};;
x) data_test=${OPTARG};;
g) n_gpus=${OPTARG};;
e) n_epochs=${OPTARG};;
n) extra_name=${OPTARG};;
p) mode=${OPTARG};;
o) outputdir=${OPTARG};;
esac
done
if [[ ${extra_name} != "" ]]; then
extra_name="_"${extra_name}
fi
if [[ ${outputdir} == "" ]]; then
outputdir="trainings/${model}/{auto}_${data}${extra_name}"
fi
output_name="pred.root"
model_config="models/${model}.py"
data_config="data/${data}.yaml"
train_opts="--num-epochs "${n_epochs}
batch_opts="--batch-size 512 --start-lr 1e-3"
if [[ $flag_test == "test" ]]; then
data_train="${data_train_ref}"
data_val="${data_val_ref}"
data_test="${data_test_ref}"
fi
if [[ ${n_gpus} == "0" ]]; then
n_gpus=""
elif [[ ${n_gpus} == "1" ]]; then
n_gpus="0"
elif [[ ${n_gpus} == "2" ]]; then
n_gpus="0,1"
elif [[ ${n_gpus} == "3" ]]; then
n_gpus="0,1,2"
elif [[ ${n_gpus} == "4" ]]; then
n_gpus="0,1,2"
fi
if [[ ${mode} == "train" ]]; then
weaver \
--data-train "${data_train}" --data-val "${data_val}" --data-test "${data_test}" \
--data-config ${data_config} --network-config ${model_config} \
--model-prefix "${outputdir}/net" --log "${outputdir}/log.log" \
${train_opts} ${batch_opts} --gpus "${n_gpus}" \
--num-workers 4 --fetch-step 0.01 \
--optimizer ranger --predict-output ${output_name}\
--tensorboard "${model}_${data}${extra_name}"
elif [[ ${mode} == *"pred"* ]]; then
n_gpus="0"
nvidia-smi || n_gpus=""
data_train="${inputdir}/eventCategory_[0-2]/MC*M1[2][4-6]*UL1[6-7-8]*.root"
data_val="${inputdir}/eventCategory_[0-2]/MC*M1[2][0]*UL1[6-7-8]*.root"
data_test="${inputdir}/eventCategory_[0-2]/MC*M1[3][0]*UL1[6-7-8]*.root"
output_name="${mode}_test.root"
weaver \
--predict --data-test "${data_test}" \
--data-config ${data_config} --network-config ${model_config} \
--model-prefix "${outputdir}/net" --log "${outputdir}/log_predict.log" \
${batch_opts} --gpus "${n_gpus}" --num-workers 4 --fetch-step 0.0 \
--predict-output ${output_name}
output_name="${mode}_train.root"
weaver \
--predict --data-test "${data_train}" \
--data-config ${data_config} --network-config ${model_config} \
--model-prefix "${outputdir}/net" --log "${outputdir}/log_predict.log" \
${batch_opts} --gpus "${n_gpus}" --num-workers 4 --fetch-step 0.0 \
--predict-output ${output_name}
output_name="${mode}_val.root"
weaver \
--predict --data-test "${data_val}" \
--data-config ${data_config} --network-config ${model_config} \
--model-prefix "${outputdir}/net" --log "${outputdir}/log_predict.log" \
${batch_opts} --gpus "${n_gpus}" --num-workers 4 --fetch-step 0.0 \
--predict-output ${output_name}
fi
#--samples-per-epoch 100000 --samples-per-epoch-val 20000
#--tensorboard VBF_${suffix} \
#--in-memory --train-val-split 0.8889
# --num-workers 1 --fetch-by-files --fetch-step 10\