forked from jet-universe/particle_transformer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
train_JetClass.sh
executable file
·91 lines (79 loc) · 3.4 KB
/
train_JetClass.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
#!/bin/bash
set -x
source env.sh
echo "args: $@"
# set the dataset dir via `DATADIR_JetClass`
DATADIR=${DATADIR_JetClass}
[[ -z $DATADIR ]] && DATADIR='./datasets/JetClass'
# set a comment via `COMMENT`
suffix=${COMMENT}
# set the number of gpus for DDP training via `DDP_NGPUS`
NGPUS=${DDP_NGPUS}
[[ -z $NGPUS ]] && NGPUS=1
if ((NGPUS > 1)); then
CMD="torchrun --standalone --nnodes=1 --nproc_per_node=$NGPUS $(which weaver) --backend nccl"
else
CMD="weaver"
fi
epochs=50
samples_per_epoch=$((10000 * 1024 / $NGPUS))
samples_per_epoch_val=$((10000 * 128))
dataopts="--num-workers 2 --fetch-step 0.01"
# PN, PFN, PCNN, ParT
model=$1
if [[ "$model" == "ParT" ]]; then
modelopts="networks/example_ParticleTransformer.py --use-amp"
batchopts="--batch-size 512 --start-lr 1e-3"
elif [[ "$model" == "PN" ]]; then
modelopts="networks/example_ParticleNet.py"
batchopts="--batch-size 512 --start-lr 1e-2"
elif [[ "$model" == "PFN" ]]; then
modelopts="networks/example_PFN.py"
batchopts="--batch-size 4096 --start-lr 2e-2"
elif [[ "$model" == "PCNN" ]]; then
modelopts="networks/example_PCNN.py"
batchopts="--batch-size 4096 --start-lr 2e-2"
else
echo "Invalid model $model!"
exit 1
fi
# "kin", "kinpid", "full"
FEATURE_TYPE=$2
[[ -z ${FEATURE_TYPE} ]] && FEATURE_TYPE="full"
if ! [[ "${FEATURE_TYPE}" =~ ^(full|kin|kinpid)$ ]]; then
echo "Invalid feature type ${FEATURE_TYPE}!"
exit 1
fi
# currently only Pythia
SAMPLE_TYPE=Pythia
$CMD \
--data-train \
"HToBB:${DATADIR}/${SAMPLE_TYPE}/train_100M/HToBB_*.root" \
"HToCC:${DATADIR}/${SAMPLE_TYPE}/train_100M/HToCC_*.root" \
"HToGG:${DATADIR}/${SAMPLE_TYPE}/train_100M/HToGG_*.root" \
"HToWW2Q1L:${DATADIR}/${SAMPLE_TYPE}/train_100M/HToWW2Q1L_*.root" \
"HToWW4Q:${DATADIR}/${SAMPLE_TYPE}/train_100M/HToWW4Q_*.root" \
"TTBar:${DATADIR}/${SAMPLE_TYPE}/train_100M/TTBar_*.root" \
"TTBarLep:${DATADIR}/${SAMPLE_TYPE}/train_100M/TTBarLep_*.root" \
"WToQQ:${DATADIR}/${SAMPLE_TYPE}/train_100M/WToQQ_*.root" \
"ZToQQ:${DATADIR}/${SAMPLE_TYPE}/train_100M/ZToQQ_*.root" \
"ZJetsToNuNu:${DATADIR}/${SAMPLE_TYPE}/train_100M/ZJetsToNuNu_*.root" \
--data-val "${DATADIR}/${SAMPLE_TYPE}/val_5M/*.root" \
--data-test \
"HToBB:${DATADIR}/${SAMPLE_TYPE}/test_20M/HToBB_*.root" \
"HToCC:${DATADIR}/${SAMPLE_TYPE}/test_20M/HToCC_*.root" \
"HToGG:${DATADIR}/${SAMPLE_TYPE}/test_20M/HToGG_*.root" \
"HToWW2Q1L:${DATADIR}/${SAMPLE_TYPE}/test_20M/HToWW2Q1L_*.root" \
"HToWW4Q:${DATADIR}/${SAMPLE_TYPE}/test_20M/HToWW4Q_*.root" \
"TTBar:${DATADIR}/${SAMPLE_TYPE}/test_20M/TTBar_*.root" \
"TTBarLep:${DATADIR}/${SAMPLE_TYPE}/test_20M/TTBarLep_*.root" \
"WToQQ:${DATADIR}/${SAMPLE_TYPE}/test_20M/WToQQ_*.root" \
"ZToQQ:${DATADIR}/${SAMPLE_TYPE}/test_20M/ZToQQ_*.root" \
"ZJetsToNuNu:${DATADIR}/${SAMPLE_TYPE}/test_20M/ZJetsToNuNu_*.root" \
--data-config data/JetClass/JetClass_${FEATURE_TYPE}.yaml --network-config $modelopts \
--model-prefix training/JetClass/${SAMPLE_TYPE}/${FEATURE_TYPE}/${model}/{auto}${suffix}/net \
$dataopts $batchopts \
--samples-per-epoch ${samples_per_epoch} --samples-per-epoch-val ${samples_per_epoch_val} --num-epochs $epochs --gpus 0 \
--optimizer ranger --log logs/JetClass_${SAMPLE_TYPE}_${FEATURE_TYPE}_${model}_{auto}${suffix}.log --predict-output pred.root \
--tensorboard JetClass_${SAMPLE_TYPE}_${FEATURE_TYPE}_${model}${suffix} \
"${@:3}"