-
Notifications
You must be signed in to change notification settings - Fork 3
/
run_experiment.sh
executable file
·69 lines (65 loc) · 2.38 KB
/
run_experiment.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
gpu=$1
SOURCE=$2 # ro
TARGET=$3 # en
LANGPAIR=${SOURCE}-${TARGET}
DATA=/mnt/disk/afm/data/${LANGPAIR}
MODEL=/mnt/disk/afm/model/${LANGPAIR}
OPENNMT=/mnt/disk/afm/OpenNMT-py
SCRIPTS="`cd $(dirname $0);pwd`"
LOGS=${SCRIPTS}/logs
ATTN=$4 # softmax|sparsemax|csoftmax|csparsemax
cattn=$5 # 0|0.2
FERTTYPE=$6 # none|fixed|guided
FERTILITY=$7 # none|2|3
COVERAGE=$8 # true|false
LAMBDA_COVERAGE=$9 # 1
train=true
if [ "$ATTN" == "csparsemax" ]
then
TRANSFORM=constrained_sparsemax
elif [ "$ATTN" == "csoftmax" ]
then
TRANSFORM=constrained_softmax
else
TRANSFORM=${ATTN}
fi
cd ${OPENNMT}
mkdir -p ${MODEL}
mkdir -p ${LOGS}
if [ "$COVERAGE" == "true" ]
then
EXTRA_FLAGS="-coverage_attn -lambda_coverage ${LAMBDA_COVERAGE}"
EXTRA_NAME="_coverage-1_lambda-${LAMBDA_COVERAGE}"
else
EXTRA_FLAGS=""
EXTRA_NAME=""
fi
if $train
then
if [ "$ATTN" == "softmax" ] || [ "$ATTN" == "sparsemax" ]
then
# Note: Add a `-fertility 1` flag to use the sink token (the default is not to use it).
python -u train.py -data ${DATA}/preprocessed.align \
-save_model ${MODEL}/preprocessed_${ATTN}_cattn-${cattn}${EXTRA_NAME} \
-attn_transform ${TRANSFORM} \
-c_attn ${cattn} ${EXTRA_FLAGS} -seed 42 -gpuid ${gpu} &> \
${LOGS}/log_${LANGPAIR}_${ATTN}_cattn-${cattn}${EXTRA_NAME}.txt
elif [ "$FERTTYPE" == "fixed" ]
then
python -u train.py -data ${DATA}/preprocessed.sink.align \
-save_model ${MODEL}/preprocessed_${ATTN}_${FERTTYPE}-${FERTILITY}_cattn-${cattn}${EXTRA_NAME} \
-attn_transform ${TRANSFORM} \
-fertility ${FERTILITY} \
-fertility_type fixed \
-c_attn ${cattn} ${EXTRA_FLAGS} -seed 42 -gpuid ${gpu} &> \
${LOGS}/log_${LANGPAIR}_${ATTN}_${FERTTYPE}-${FERTILITY}_cattn-${cattn}${EXTRA_NAME}.txt
elif [ "$FERTTYPE" == "guided" ] || [ "$FERTTYPE" == "predicted" ] || [ "$FERTTYPE" == "actual" ]
then
python -u train.py -data ${DATA}/preprocessed.sink.align \
-save_model ${MODEL}/preprocessed_${ATTN}_${FERTTYPE}_cattn-${cattn}${EXTRA_NAME} \
-attn_transform ${TRANSFORM} \
-fertility_type ${FERTTYPE} \
-c_attn ${cattn} ${EXTRA_FLAGS} -seed 42 -gpuid ${gpu} &> \
${LOGS}/log_${LANGPAIR}_${ATTN}_${FERTTYPE}_cattn-${cattn}${EXTRA_NAME}.txt
fi
fi