Welcome to mirror list, hosted at ThFree Co, Russian Federation.

test_expsmooth_sync.sh « exp-smoothing « features « training « tests - github.com/marian-nmt/marian-regression-tests.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3bab8ee3a691b3d754134d3672589009eceb4a68 (plain)
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
#!/bin/bash -x

# Exit on error
set -e

if (( $MRT_NUM_DEVICES < 2 )); then
    echo "Too few devices available"
    exit 100
fi

# Test code goes here
rm -rf expsmooth_sync expsmooth_sync*.log
mkdir -p expsmooth_sync


opts="--no-shuffle --seed 777 --mini-batch 4 --maxi-batch 1 --maxi-batch-sort none --dim-rnn 64 --dim-emb 32 --optimizer adam --learn-rate 0.0001 --valid-sets valid.bpe.en valid.bpe.de --valid-metrics cross-entropy --valid-mini-batch 32 --devices 0 1 --sync-sgd"

# No exponential smoothing
$MRT_MARIAN/marian \
    -m expsmooth_sync/model.noexp.npz -t $MRT_DATA/europarl.de-en/corpus.bpe.{en,de} -v vocab.en.yml vocab.de.yml --clip-norm 0 --cost-type ce-mean-words \
    --disp-freq 20 --valid-freq 20 --after-batches 200 $opts \
    --log expsmooth_sync_0.log

test -e expsmooth_sync/model.noexp.npz
test -e expsmooth_sync_0.log

cat expsmooth_sync_0.log | $MRT_TOOLS/strip-timestamps.sh | grep "Ep\. " | grep -v 'valid' | sed 's/ : Time.*//' > noexpsmooth_sync.out
#cat expsmooth_sync_0.log | $MRT_TOOLS/strip-timestamps.sh | grep "Ep\. " | grep 'valid' | sed 's/ : Time.*//' > noexpsmooth_sync.valid.out


# With exponential smoothing
$MRT_MARIAN/marian \
    -m expsmooth_sync/model.npz -t $MRT_DATA/europarl.de-en/corpus.bpe.{en,de} -v vocab.en.yml vocab.de.yml --clip-norm 0 --cost-type ce-mean-words \
    --disp-freq 20 --valid-freq 20 --after-batches 200 --exponential-smoothing 0.0001 $opts \
    --log expsmooth_sync.log

test -e expsmooth_sync/model.npz
test -e expsmooth_sync.log

cat expsmooth_sync.log | $MRT_TOOLS/strip-timestamps.sh | grep "Ep\. " | grep -v 'valid' | sed 's/ : Time.*//' > expsmooth_sync.out
cat expsmooth_sync.log | $MRT_TOOLS/strip-timestamps.sh | grep "Ep\. " | grep 'valid' | sed 's/ : Time.*//' > expsmooth_sync.valid.out


$MRT_TOOLS/diff-nums.py -p 0.0001 expsmooth_sync.out expsmooth_sync.expected -o expsmooth_sync.diff
$MRT_TOOLS/diff-nums.py -p 0.0001 expsmooth_sync.valid.out expsmooth_sync.valid.expected -o expsmooth_sync.valid.diff

# There should be no difference in costs between training w/ and w/o exponential smoothing
$MRT_TOOLS/diff-nums.py -p 0.0001 expsmooth_sync.out noexpsmooth_sync.out -o noexpsmooth_sync.diff


# Exit with success code
exit 0