-
Notifications
You must be signed in to change notification settings - Fork 2
/
train_mmt.sh
82 lines (70 loc) · 2.07 KB
/
train_mmt.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
#! /usr/bin/bash
set -e
device=0
task=multi30k-en2de
image_feat=clip #vit_tiny_patch16_384
date=$(date '+%m%d%H%M')
save_dir=checkpoints/$task/$image_feat/${date}_0.5klmulti_32_sd_ran0+0.1beforeimgotlossvishal_release
if [ ! -d $save_dir ]; then
mkdir -p $save_dir
fi
if [ $task == 'multi30k-en2de' ]; then
src_lang=en
tgt_lang=de
data_dir=multi30k.en-de
elif [ $task == 'multi30k-en2fr' ]; then
src_lang=en
tgt_lang=fr
data_dir=multi30k.en-fr
elif [ $task == 'multi30k-en2cs' ]; then
src_lang=en
tgt_lang=cs
data_dir=multi30k.en-cs
elif [ $task == 'msctd' ]; then
src_lang=en
tgt_lang=de
data_dir=msctd.en-de
fi
criterion=label_smoothed_cross_entropy
fp16=0
lr=0.005
warmup=2000
max_tokens=2048
update_freq=4
keep_last_epochs=10
patience=10
max_update=9500
dropout=0.3
arch=multimodal_transformer_sammt
image_dropout=0.1
if [ $image_feat == "clip" ]; then
synth_feat_path=data/$image_feat/synth_
authe_feat_path=data/$image_feat/authe_
image_feat_len=1
image_feat_dim=512
fi
cp ${BASH_SOURCE[0]} $save_dir/train.sh
gpu_num=`echo "$device" | awk '{split($0,arr,",");print length(arr)}'`
cmd="fairseq-train data-bin/$data_dir
--save-dir $save_dir
--distributed-world-size $gpu_num -s $src_lang -t $tgt_lang
--arch $arch
--dropout $dropout
--criterion $criterion --label-smoothing 0.1
--task image_mmt --synth-feat-path $synth_feat_path --image-feat-dim $image_feat_dim --image-feat-len $image_feat_len
--authe-feat-path $authe_feat_path
--optimizer adam --adam-betas '(0.9, 0.98)'
--lr $lr --min-lr 1e-09 --lr-scheduler inverse_sqrt --warmup-init-lr 1e-07 --warmup-updates $warmup
--max-tokens $max_tokens --update-freq $update_freq
--find-unused-parameters --share-all-embeddings
--max-update $max_update --keep-last-epochs $keep_last_epochs"
if [ $fp16 -eq 1 ]; then
cmd=${cmd}" --fp16 "
fi
if [ -n "$image_dropout" ]; then
cmd=${cmd}" --image-dropout "${image_dropout}
fi
export CUDA_VISIBLE_DEVICES=$device
cmd="nohup "${cmd}" > $save_dir/train.log 2>&1 &"
eval $cmd
tail -f $save_dir/train.log