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

test_valid_reset_stalled.sh « validation « restoring « training « tests - github.com/marian-nmt/marian-regression-tests.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c2c7d4b156389b309612ba406822613d5e437606 (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
53
54
55
56
57
58
59
#!/bin/bash -x

#####################################################################
# SUMMARY: Test the option for resetting stalled validations after the training is resumed
# AUTHOR: snukky
# TAGS: restore valid validscript validreset
#####################################################################

# Exit on error
set -e

# Test code goes here
rm -rf valid_reset_stalled valid_reset_stalled_?.*log valid_script_?.temp
mkdir -p valid_reset_stalled

test -s valid.mini.bpe.en || head -n 8 $MRT_DATA/europarl.de-en/toy.bpe.en > valid.mini.bpe.en
test -s valid.mini.bpe.de || head -n 8 $MRT_DATA/europarl.de-en/toy.bpe.de > valid.mini.bpe.de

extra_opts="--no-shuffle --seed 2222 --maxi-batch 1 --maxi-batch-sort none --quiet-translation"
extra_opts="$extra_opts --dim-emb 64 --dim-rnn 128 --mini-batch 16 --optimizer sgd"
extra_opts="$extra_opts --cost-type ce-mean --disp-label-counts false"


# Train a model for a while and stop
$MRT_MARIAN/marian $extra_opts \
    -m valid_reset_stalled/model.npz -t $MRT_DATA/europarl.de-en/toy.bpe.{en,de} -v vocab.en.yml vocab.de.yml \
    --disp-freq 10 --valid-freq 20 --after-batches 140 --early-stopping 5 \
    --valid-metrics translation valid-script cross-entropy --valid-script-path ./valid_script_ab.sh \
    --valid-sets valid.mini.bpe.{de,en} \
    --overwrite --keep-best --clip-norm 0 \
    --log valid_reset_stalled_1.log

test -e valid_reset_stalled/model.npz
test -e valid_reset_stalled/model.npz.yml
test -e valid_reset_stalled_1.log

cat valid_reset_stalled_1.log | $MRT_TOOLS/strip-timestamps.sh | grep -P "\[valid\]" > valid_reset_stalled.out


# Restart training with --valid-reset-stalled
$MRT_MARIAN/marian $extra_opts \
    -m valid_reset_stalled/model.npz -t $MRT_DATA/europarl.de-en/toy.bpe.{en,de} -v vocab.en.yml vocab.de.yml \
    --disp-freq 10 --valid-freq 20 --after-batches 200 --early-stopping 5 --valid-reset-stalled \
    --valid-metrics translation valid-script cross-entropy --valid-script-path ./valid_script_ab.sh \
    --valid-sets valid.mini.bpe.{de,en} \
    --overwrite --keep-best --clip-norm 0 \
    --log valid_reset_stalled_2.log

test -e valid_reset_stalled/model.npz
test -e valid_reset_stalled_2.log

cat valid_reset_stalled_2.log | $MRT_TOOLS/strip-timestamps.sh | grep -P "\[valid\]" >> valid_reset_stalled.out


# Compare with the expected output
$MRT_TOOLS/diff.sh valid_reset_stalled.out valid_reset_stalled.expected > valid_reset_stalled.diff

# Exit with success code
exit 0