diff options
author | Roman Grundkiewicz <rgrundkiewicz@gmail.com> | 2021-07-26 12:22:06 +0300 |
---|---|---|
committer | Roman Grundkiewicz <rgrundkiewicz@gmail.com> | 2021-07-26 12:22:06 +0300 |
commit | 4ec211ce0d3bf6c94b1d814958cef0db6f6cc0aa (patch) | |
tree | 4175164cad48fc267803b65b466bad3f462998f0 /tests/training/validation/test_early_stopping_on_1st.sh | |
parent | 2a6722b5059e5f1acce7f78b7a6c943b34e16178 (diff) | |
parent | 1afd4eb1014ac451c6a3d6f9b5d34c322902e624 (diff) |
Merge branch 'romang/early-stopping-on' into romang/merge-prs
Diffstat (limited to 'tests/training/validation/test_early_stopping_on_1st.sh')
-rw-r--r-- | tests/training/validation/test_early_stopping_on_1st.sh | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/training/validation/test_early_stopping_on_1st.sh b/tests/training/validation/test_early_stopping_on_1st.sh new file mode 100644 index 0000000..0ebe779 --- /dev/null +++ b/tests/training/validation/test_early_stopping_on_1st.sh @@ -0,0 +1,42 @@ +#!/bin/bash -x + +##################################################################### +# SUMMARY: Test early stopping after stalling on the first validation metric +# AUTHOR: snukky +# TAGS: valid valid-script +##################################################################### + +# Exit on error +set -e + +# Test code goes here +rm -rf stop_on_1st stop_on_1st.log stop_on_script.temp +mkdir -p stop_on_1st + +# Start training with a fully trained model so that validation metrics do not improve easily +cp $MRT_MODELS/wngt19/model.small.npz stop_on_1st/model.npz + +test -s devset.en || head -n 50 $MRT_MODELS/wngt19/newstest2014.en | sed -r 's/@@ //g' > devset.en +test -s devset.de || head -n 50 $MRT_MODELS/wngt19/newstest2014.de | sed -r 's/@@ //g' > devset.de + +# Training sides are intentionaly reversed to test early stopping +$MRT_MARIAN/marian \ + --seed 2222 --no-shuffle --clip-norm 1 --maxi-batch 1 --mini-batch 32 -w 2500 \ + -m stop_on_1st/model.npz -t $MRT_DATA/europarl.de-en/corpus.small.{de,en}.gz \ + -v $MRT_MODELS/wngt19/en-de.{spm,spm} \ + --disp-freq 5 --valid-freq 10 --after-batches 200 \ + --valid-metrics valid-script ce-mean-words \ + --valid-script-path ./stop_on_script.sh \ + --valid-sets devset.{en,de} \ + --valid-log stop_on_1st.log \ + --early-stopping 4 --early-stopping-on first + +test -e stop_on_1st/model.npz +test -e stop_on_1st/model.npz.yml +test -e stop_on_1st.log + +$MRT_TOOLS/strip-timestamps.sh < stop_on_1st.log | grep '\[valid\]' > stop_on_1st.out +$MRT_TOOLS/diff-nums.py stop_on_1st.out stop_on_1st.expected -p 0.2 -o stop_on_1st.diff + +# Exit with success code +exit 0 |