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

test_word_weighting_with_twos.sh « data-weighting « features « training « tests - github.com/marian-nmt/marian-regression-tests.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 81bc3e5053f5b82cfa563ef7b5d4be498c68841a (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
#!/bin/bash

#####################################################################
# SUMMARY:
# TAGS: dataweights
#####################################################################

# Exit on error
set -e


# Test with data-weighting as command-line arguments
rm -rf word_twos word_twos.{log,out,diff}
mkdir -p word_twos

# Generate a file with weights that each word has a weight 2
cat $MRT_DATA/europarl.de-en/toy.bpe.en | sed -r 's/[^ ]+/2/g' > word_twos.weights.txt

# Train with word weighting
$MRT_MARIAN/marian \
    --seed 1111 --no-shuffle --dim-emb 128 --dim-rnn 256 --optimizer sgd \
    -m word_twos/model.npz -t $MRT_DATA/europarl.de-en/toy.bpe.{de,en} -v vocab.{de,en}.yml \
    --log word_twos.log --disp-freq 5 -e 2 \
    --data-weighting word_twos.weights.txt --data-weighting-type word

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

# Compare costs with the expected values
cat word_twos.log | $MRT_TOOLS/strip-timestamps.sh | grep "Ep\. " | sed -r 's/ Time.*//' > word_twos.out
$MRT_TOOLS/diff-nums.py word_twos.out word_twos.expected -p 0.1 -o word_twos.diff


# Test with data-weighting via config file
rm -rf word_twos_cfg word_twos_cfg.{log,out,diff}
mkdir -p word_twos_cfg

# Generate config file
echo "data-weighting: word_twos.weights.txt" > word_twos.config.yml
echo "data-weighting-type: word" >> word_twos.config.yml

# Train with word weighting
$MRT_MARIAN/marian \
    --seed 1111 --no-shuffle --dim-emb 128 --dim-rnn 256 --optimizer sgd \
    -m word_twos_cfg/model.npz -t $MRT_DATA/europarl.de-en/toy.bpe.{de,en} -v vocab.{de,en}.yml \
    --log word_twos_cfg.log --disp-freq 5 -e 2 \
    -c word_twos.config.yml

# Compare costs with the same expected values as previously
cat word_twos_cfg.log | $MRT_TOOLS/strip-timestamps.sh | grep "Ep\. " | sed -r 's/ Time.*//' > word_twos_cfg.out
$MRT_TOOLS/diff-nums.py word_twos_cfg.out word_twos.expected -p 0.1 -o word_twos_cfg.diff


# Exit with success code
exit 0