-
Notifications
You must be signed in to change notification settings - Fork 33
/
train.sh
executable file
·130 lines (116 loc) · 3.13 KB
/
train.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
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
127
128
129
130
#!/bin/bash
# Copyright 2019.7 Nan LEE
set -euo pipefail
stage=0
nj=1
val_size=500
train_dir=data
test_dir=data/test
logdir=exp
tr_list=$train_dir/tr.list
cv_list=$train_dir/cv.list
test_list=$test_dir/test.list
save_dir=exp/dnn
# Data prepare
if [ $stage -le 0 ]; then
# Make TFRecords file
echo "Begin making TFRecords files ..."
if [ ! -d $logdir ]; then
mkdir -p $logdir || exit 1;
fi
# cv set
declare -i verbose=30
[ -d $train_dir/tfrecords ] && (rm -rf $train_dir/tfrecords || exit 1;)
mkdir -p $train_dir/tfrecords || exit 1;
TF_CPP_MIN_LOG_LEVEL=1 python io_funcs/make_setf.py --inputs=$train_dir/cv/inputs_feat.txt --name="cv"
echo "$train_dir/tfrecords/cv.tfrecords" > $cv_list
wait
date
TF_CPP_MIN_LOG_LEVEL=1 python io_funcs/make_setf.py --inputs=$train_dir/tr/inputs_feat.txt --name="tr"
echo "$train_dir/tfrecords/tr.tfrecords" > $tr_list
wait
date
[ -f $train_dir/batch_num.txt ] && rm $train_dir/batch_num.txt
echo "Make train TFRecords files sucessed."
echo ""
fi
#exit 0;
# Train model
if [ $stage -le 2 ]; then
echo "$(date): $(hostname)"
CUDA_VISIBLE_DEVICES="1,2,3" TF_CPP_MIN_LOG_LEVEL=2 \
python scripts/train_dnn.py \
--data_dir=$train_dir \
--tr_list_file=$tr_list \
--cv_list_file=$cv_list \
--g_type="res_rced" \
--save_dir=$save_dir \
--batch_size=64 \
--g_learning_rate=0.001 \
--keep_lr=2 \
--batch_norm=true \
--keep_prob=1 \
--l2_scale=0 \
--input_dim=257 \
--output_dim=257 \
--left_context=5 \
--right_context=5 \
--min_epoches=30 \
--max_epoches=35 \
--decay_factor=0.8 \
--start_halving_impr=0.01 \
--end_halving_impr=0.001 \
--num_threads=1 \
--num_gpu=1 || exit 1;
echo "Finished training successfully on $(date)"
echo ""
fi
# exit 0;
# Decode
if [ $stage -le 4 ]; then
echo "Prepare test data"
if [ -f $logdir/.test.error ]; then
rm -rf $logdir/.test.error || exit 1;
fi
declare -i verbose=30
# [ -d $test_dir/tfrecords ] && (rm -rf $test_dir/tfrecords || exit 1;)
# mkdir -p $test_dir/tfrecords || exit 1;
for datase in data/test/*;do
# for datase in data/simusi;do
rm -rf $datase/tfrecords
TF_CPP_MIN_LOG_LEVEL=1 python io_funcs/make_sete.py \
--inputs=$datase/inputs.txt \
--output_dir=$datase/tfrecords \
--name="test" || touch $logdir/.test.error &
echo "$datase/tfrecords/test.tfrecords" > $datase/test.list
# exit 0;
wait
done
fi
# Decode
if [ $stage -le 5 ]; then
echo "Start decoding test data"
for datase in data/test/*;do
# for datase in data/simusi;do
CUDA_VISIBLE_DEVICES="1" TF_CPP_MIN_LOG_LEVEL=2 python scripts/train_dnn.py \
--decode \
--data_dir=$train_dir \
--test_list_file=$datase/test.list \
--g_type="res_rced" \
--save_dir=$save_dir \
--g_learning_rate=0.001 \
--batch_norm=true \
--input_dim=257 \
--output_dim=257 \
--left_context=5 \
--right_context=5 \
--batch_size=1 \
--keep_prob=1 \
--l2_scale=0 \
--num_threads=1 \
--savetestdir=$datase || exit 1;
echo "Decoding done"
wait
done
fi
exit 0