Blame view

egs/ptb/s5/local/rnnlm/tuning/run_tdnn_a.sh 2.04 KB
8dcb6dfcb   Yannick Estève   first commit
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
  #!/bin/bash
  
  # To be run from the directory egs/ptb/s5.
  # This is to be done after local/prepare_rnnlm_data.sh.
  
  # some of the output follows.
  
  # rnnlm/train_rnnlm.sh: best iteration (out of 8) was 3, linking it to final iteration.
  # Train objf: -92.38 -5.01 -4.70 -4.48 -4.30 -4.14 -4.01 -3.81
  # Dev objf:   -9.21 -5.29 -5.05 -4.96 -4.97 -5.02 -5.09 -5.16
  
  
  set -e
  embedding_dim=400
  dir=exp/rnnlm_tdnn_a
  stage=0
  train_stage=0
  
  . utils/parse_options.sh   # parse options-- mainly for the --stage parameter.
  
  for f in data/vocab/words.txt data/text/ptb.txt; do
    [ ! -f ] && echo "$0: expected file $f to exist" && exit 1
  done
  
  if [ $stage -le 0 ]; then
    mkdir -p $dir/config
    cp data/vocab/words.txt $dir/config/
  
    cat > $dir/config/data_weights.txt <<EOF
  ptb   1   1.0
  EOF
  
    echo "<unk>" >$dir/config/oov.txt  # not really necessary as OOVs were previously
                                # converted to <unk>, but doesn't hurt.
  
  
    # we need the unigram probs to get the unigram features.
    rnnlm/get_unigram_probs.py --vocab-file=data/vocab/words.txt \
                               --data-weights-file=$dir/config/data_weights.txt \
                               data/text >$dir/config/unigram_probs.txt
  
  
    # choose features
    rnnlm/choose_features.py --unigram-probs=$dir/config/unigram_probs.txt \
                             --use-constant-feature=true \
                             --special-words='<s>,</s>,<brk>,<unk>' \
                             data/vocab/words.txt > $dir/config/features.txt
  
    cat >$dir/config/xconfig <<EOF
  input dim=$embedding_dim name=input
  relu-renorm-layer name=tdnn1 dim=400 input=Append(0, IfDefined(-1))
  relu-renorm-layer name=tdnn2 dim=400 input=Append(0, IfDefined(-1))
  relu-renorm-layer name=tdnn3 dim=400 input=Append(0, IfDefined(-2))
  output-layer name=output include-log-softmax=false dim=$embedding_dim
  EOF
  
    rnnlm/validate_config_dir.sh data/text $dir/config
  fi
  
  
  if [ $stage -le 1 ]; then
    rnnlm/prepare_rnnlm_dir.sh data/text $dir/config $dir
  fi
  
  if [ $stage -le 2 ]; then
    rnnlm/train_rnnlm.sh --num-epochs 40 --cmd "queue.pl" $dir
  fi