diff options
author | Pedro Coelho <pedrodiascoelho97@gmail.com> | 2021-03-01 13:46:19 +0300 |
---|---|---|
committer | Pedro Coelho <pedrodiascoelho97@gmail.com> | 2021-03-01 13:46:19 +0300 |
commit | e3101c328812b526f35072c1c5266cad16a14f99 (patch) | |
tree | dd8ad9d10c54fcc9894d232c184f92d7bcc37351 | |
parent | c923a4c69676b0829324ac4b03acbfbecf3b3a63 (diff) |
add test for transformer model with factors
-rw-r--r-- | tests/factors/factors_transformer.expected | 44 | ||||
-rw-r--r-- | tests/factors/test_factors_transformer.sh | 36 |
2 files changed, 80 insertions, 0 deletions
diff --git a/tests/factors/factors_transformer.expected b/tests/factors/factors_transformer.expected new file mode 100644 index 0000000..4af1f23 --- /dev/null +++ b/tests/factors/factors_transformer.expected @@ -0,0 +1,44 @@ +11.04951191 +10.68020153 +10.54591465 +10.48460102 +10.40533352 +10.38826847 +10.27533150 +10.21229267 +10.19135952 +10.08994102 +10.01051331 +9.97128105 +9.95058727 +9.93437099 +9.94428539 +9.83870697 +9.83070374 +9.81238365 +9.75304127 +9.67127991 +9.65575886 +9.66312313 +9.66796112 +9.63431263 +9.56104946 +9.57750225 +9.53895378 +9.45394707 +9.41851521 +9.39714527 +9.39997673 +9.40844250 +9.36143589 +9.29904747 +9.33303452 +9.25019360 +9.18587208 +9.15645790 +9.13850403 +9.13868427 +9.14638233 +9.09624672 +9.03522873 +9.06501865 diff --git a/tests/factors/test_factors_transformer.sh b/tests/factors/test_factors_transformer.sh new file mode 100644 index 0000000..36cc15f --- /dev/null +++ b/tests/factors/test_factors_transformer.sh @@ -0,0 +1,36 @@ +#!/bin/bash -x + +##################################################################### +# SUMMARY: Training a factored model +# AUTHOR: pedrodiascoelho +# TAGS: factors +##################################################################### + +# Exit on error +set -e + +# Remove old artifacts and create working directory +rm -rf factors_transformer factors_transformer.{log,out,diff} +mkdir -p factors_transformer + +# Run marian command +$MRT_MARIAN/marian \ + --no-shuffle --seed 1111 --dim-emb 32 --dim-rnn 64 --maxi-batch 1 --maxi-batch-sort none --clip-norm 0 \ + --type transformer -m factors_transformer/model.npz -t toy.bpe.fact.{en,de} -v $MRT_MODELS/factors/vocab.{en,de}.fsv \ + --disp-freq 5 -e 5 \ + --log factors_transformer.log + +# Check if files exist +test -e factors_transformer/model.npz +test -e factors_transformer.log + +#Checks factor usage +grep -q "Factored embeddings enabled" factors_transformer.log +grep -q "Factored outputs enabled" factors_transformer.log + +# Compare the current output with the expected output +cat factors_transformer.log | $MRT_TOOLS/extract-costs.sh > factors_transformer.out +$MRT_TOOLS/diff-nums.py factors_transformer.out factors_transformer.expected -o factors_transformer.diff + +# Exit with success code +exit 0 |