-
Notifications
You must be signed in to change notification settings - Fork 0
/
fine-tune.sh
56 lines (52 loc) · 1.64 KB
/
fine-tune.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
CV=""
if [[ -z "${BS}" ]]; then
MY_BS=8
else
MY_BS=${BS}
fi
export ARCHIVE_PATH="$1/model_epoch_${2}.tar.gz"
if [[ -z "${FT_SCRIPT}" ]]; then
FT_SCRIPT="fine-tune.jsonnet"
else
FT_SCRIPT=${FT_SCRIPT}
fi
if [ ! -f $_PATH ];
then
python3 utils/make_archive.py -s $1 -n $2 -m training_config/model.json || exit 1;
fi
if grep -w $3 data/ensemble_langs.txt;
then
for file in $UD_ROOT${3}_*-*-*-train.conllu;
do
echo $file
CV_NUM=$(echo $(basename $file) | awk -F'-' '{print $2}')
echo $CV_NUM
MY_BS=$MY_BS CV="_*-$CV_NUM-" NUM_EPOCHS=$4 FT_LANG=$3 RUN_NAME=$1_$2_$3_$5 python -W ignore run.py train training_config/$FT_SCRIPT --include-package src -s $1_$2_$3_cv${CV_NUM}_$5
BASE_MODEL=$1 python3 utils/make_full_model.py -s $1_$2_$3_cv${CV_NUM}_$5 || exit 1;
done
else
MY_BS=$MY_BS CV="" NUM_EPOCHS=$4 FT_LANG=$3 RUN_NAME=$1_$2_$3_$5 python -W ignore run.py train training_config/$FT_SCRIPT --include-package src -s $1_$2_$3_$5
BASE_MODEL=$1 python3 utils/make_full_model.py -s $1_$2_$3_$5 || exit 1;
fi
if grep -w $3 data/ensemble_langs.txt;
then
for file in $UD_ROOT${3}_*-*-*-train.conllu;
do
echo $file
CV_NUM=$(echo $(basename $file) | awk -F'-' '{print $2}')
echo $CV_NUM
bash test.sh $1_$2_$3_cv${CV_NUM}_$5 $3 8
done
python3 tools/make_ens_config.py "$1_$2_$3_cv*_$5/" $1_$2_$3_ens_$5
ENSEMBLE="1" bash test.sh $1_$2_$3_ens_$5 $3 8
for file in $UD_ROOT${3}_*-*-*-train.conllu;
do
echo $file
CV_NUM=$(echo $(basename $file) | awk -F'-' '{print $2}')
echo $CV_NUM
rm $1_$2_$3_cv${CV_NUM}_$5/training_state_epoch_*.th
done
else
bash test.sh $1_$2_$3_$5 $3 8
rm $1_$2_$3_$5/*.th
fi