forked from arasharchor/cnn-speech-denoising
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
executable file
·100 lines (69 loc) · 2.46 KB
/
run.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
#!/usr/bin/env bash
### Define your parameters here:
DEFAULT_CAFFE_ROOT=~/scr/conv/caffe
if [ -z "${CAFFE_ROOT}" ]; then
CAFFE_ROOT=${DEFAULT_CAFFE_ROOT}
fi
DATASET=noisy_to_clean
LOGDIR=${CAFFE_ROOT}/project/cnn-speech-denoising/log
echo "Caffe root set to ${CAFFE_ROOT}"
### Helper functions
NET=$DATASET
DATAROOT=dataset/mfcc/conditions
MAXFILES=200
TIMESLICE=10
SCALE_MFCC=1
EXPTNAME=${DATASET}.${MAXFILES}
TRAINDIR=project/cnn-speech-denoising/${DATAROOT}/${EXPTNAME}/train/sampled
TESTDIR=project/cnn-speech-denoising/${DATAROOT}/${EXPTNAME}/dev/sampled
SPLITLOG=${LOGDIR}/${EXPTNAME}.split.log
SAMPLELOG=${LOGDIR}/${EXPTNAME}.sample.log
CAFFELOG=${LOGDIR}/${EXPTNAME}.caffe.log
STARTDIR=$PWD
fail() {
cd $STARTDIR
exit 1
}
success() {
cd $STARTDIR
exit 0
}
cd_proj() {
cd ${CAFFE_ROOT}/project/cnn-speech-denoising
}
cd_caffe() {
cd ${CAFFE_ROOT}
}
split() {
echo Splitting dataset to $SPLITLOG
cd_proj
# do a 70/30 split on the ${DATASET} dataset in to train and dev
python split_dataset.py $DATAROOT/${DATASET} $DATAROOT/$EXPTNAME --max_files_to_process $MAXFILES > $SPLITLOG || fail
}
sample() {
echo Sampling dataset to $SAMPLELOG
cd_proj
# sample the training data, normalize and dump the normalization params to disk
python patch_sampler.py $DATAROOT/${EXPTNAME}/train --x_len $TIMESLICE > $SAMPLELOG || fail
# sample the dev data, normalize using the normalization params dumped during training
python patch_sampler.py $DATAROOT/${EXPTNAME}/dev --x_len $TIMESLICE >> $SAMPLELOG || fail
}
train() {
echo Training caffe to $CAFFELOG
cd_caffe
cat project/cnn-speech-denoising/models/model0/${NET}.prototxt.template | \
python project/cnn-speech-denoising/replace.py "+TEST_DIR+",${TESTDIR} | \
python project/cnn-speech-denoising/replace.py "+TRAIN_DIR+",${TRAINDIR} > project/cnn-speech-denoising/models/model0/${EXPTNAME}.prototxt
cat project/cnn-speech-denoising/models/model0/${NET}_solver.prototxt.template | \
python project/cnn-speech-denoising/replace.py "+EXPT_NAME+",${EXPTNAME} > project/cnn-speech-denoising/models/model0/${EXPTNAME}_solver.prototxt
./build/tools/caffe train \
--solver=project/cnn-speech-denoising/models/model0/${EXPTNAME}_solver.prototxt > $CAFFELOG 2>&1 || fail
}
### Run what you want here:
mkdir -p $LOGDIR
# These two are destructive in that they are stochastic and will overwrite your splits and samples
split
sample
# This trains caffe
train
success