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

github.com/marian-nmt/marian-regression-tests.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAlham Fikri Aji <afaji321@gmail.com>2020-11-11 09:14:34 +0300
committerAlham Fikri Aji <afaji321@gmail.com>2020-11-11 09:14:34 +0300
commit5fc2bab7c77e55410717c1f7229f97170353d20d (patch)
treebf5bfeccc5eda4efb027e8727d9ed0108157cf99 /tests
parentfdd7493cd2f922e65b6bb08b7ef84b711cf730da (diff)
test the resulting model, make sure it is quantized
Diffstat (limited to 'tests')
-rw-r--r--tests/training/features/quantized-model/model_centers.expected51
-rw-r--r--tests/training/features/quantized-model/test_quant_centers.sh31
2 files changed, 82 insertions, 0 deletions
diff --git a/tests/training/features/quantized-model/model_centers.expected b/tests/training/features/quantized-model/model_centers.expected
new file mode 100644
index 0000000..57380ae
--- /dev/null
+++ b/tests/training/features/quantized-model/model_centers.expected
@@ -0,0 +1,51 @@
+Tensor decoder_W_comb_att unique centers: [-0.17677179 -0.11784786 -0.05892393 -0. 0.05892393 0.11784786
+ 0.17677179]
+Tensor decoder_Wc_att unique centers: [-0.15336949 -0.10224632 -0.05112316 -0. 0.05112316 0.10224632
+ 0.15336949]
+Tensor Wemb_dec unique centers: [-0.32046145 -0.21364096 -0.10682048 0. 0.10682048 0.21364096
+ 0.32046145]
+Tensor decoder_U unique centers: [-0.17687811 -0.11791874 -0.05895937 -0. 0.05895937 0.11791874
+ 0.17687811]
+Tensor decoder_Ux unique centers: [-0.21770547 -0.14513698 -0.07256849 0. 0.07256849 0.14513698
+ 0.21770547]
+Tensor decoder_W unique centers: [-0.19397542 -0.12931694 -0.06465847 -0. 0.06465847 0.12931694
+ 0.19397542]
+Tensor decoder_Wx unique centers: [-0.25329626 -0.16886416 -0.08443208 -0. 0.08443208 0.16886416
+ 0.25329626]
+Tensor decoder_U_nl unique centers: [-0.17696194 -0.11797463 -0.05898732 0. 0.05898732 0.11797463
+ 0.17696194]
+Tensor decoder_Ux_nl unique centers: [-0.21896881 -0.14597921 -0.07298961 0. 0.07298961 0.14597921
+ 0.21896881]
+Tensor decoder_Wc unique centers: [-0.15324192 -0.10216128 -0.05108064 0. 0.05108064 0.10216128
+ 0.15324192]
+Tensor decoder_Wcx unique centers: [-0.18192002 -0.12128001 -0.06064001 -0. 0.06064001 0.12128001
+ 0.18192002]
+Tensor ff_logit_prev_W unique centers: [-0.32183957 -0.2145597 -0.10727985 -0. 0.10727985 0.2145597
+ 0.32183957]
+Tensor ff_logit_lstm_W unique centers: [-0.25455362 -0.16970241 -0.08485121 0. 0.08485121 0.16970241
+ 0.25455362]
+Tensor ff_logit_ctx_W unique centers: [-0.19867198 -0.13244799 -0.06622399 -0. 0.06622399 0.13244799
+ 0.19867198]
+Tensor decoder_ff_logit_l2_Wt unique centers: [-0.36124557 -0.24083039 -0.1204152 0. 0.1204152 0.24083039
+ 0.36124557]
+Tensor ff_state_W unique centers: [-0.17704961 -0.11803307 -0.05901653 0. 0.05901653 0.11803307
+ 0.17704961]
+Tensor Wemb unique centers: [-0.31208774 -0.20805849 -0.10402925 0. 0.10402925 0.20805849
+ 0.31208774]
+Tensor encoder_U unique centers: [-0.17686225 -0.11790817 -0.05895409 0. 0.05895409 0.11790817
+ 0.17686225]
+Tensor encoder_Ux unique centers: [-0.21824732 -0.14549822 -0.07274911 0. 0.07274911 0.14549822
+ 0.21824732]
+Tensor encoder_W unique centers: [-0.19403435 -0.12935624 -0.06467812 0. 0.06467812 0.12935624
+ 0.19403435]
+Tensor encoder_Wx unique centers: [-0.25213736 -0.16809157 -0.08404578 -0. 0.08404578 0.16809157
+ 0.25213736]
+Tensor encoder_r_U unique centers: [-0.17699143 -0.11799429 -0.05899715 0. 0.05899715 0.11799429
+ 0.17699143]
+Tensor encoder_r_Ux unique centers: [-0.21971346 -0.14647564 -0.07323782 -0. 0.07323782 0.14647564
+ 0.21971346]
+Tensor encoder_r_W unique centers: [-0.19410282 -0.12940188 -0.06470094 0. 0.06470094 0.12940188
+ 0.19410282]
+Tensor encoder_r_Wx unique centers: [-0.25225359 -0.16816907 -0.08408453 -0. 0.08408453 0.16816907
+ 0.25225359]
+Tensor decoder_c_tt unique centers: []
diff --git a/tests/training/features/quantized-model/test_quant_centers.sh b/tests/training/features/quantized-model/test_quant_centers.sh
new file mode 100644
index 0000000..22dd863
--- /dev/null
+++ b/tests/training/features/quantized-model/test_quant_centers.sh
@@ -0,0 +1,31 @@
+#!/bin/bash -x
+
+#####################################################################
+# SUMMARY: Make sure that the resulting model is in quantized form
+# AUTHOR: afaji
+#####################################################################
+
+# Exit on error
+set -e
+
+PREFIX=test-center
+
+# Remove old artifacts and create working directory
+rm -rf train
+mkdir -p train
+
+# Train an 8-bits model
+$MRT_MARIAN/marian \
+ --no-shuffle --seed 1111 --dim-emb 32 --dim-rnn 64 --mini-batch 32 --maxi-batch 1 --maxi-batch-sort none --learn-rate 0.1 --optimizer sgd \
+ -m train/model.npz -t $MRT_DATA/europarl.de-en/corpus.bpe.{en,de} -v train/vocab.en.yml train/vocab.de.yml \
+ --cost-type cross-entropy --sync-sgd --after-batches 10 --disp-freq 2 --quantize-bits 3
+
+# Check if files exist
+test -e train/model.npz
+
+# make sure that the resulting model has no more than 256 different values (i.e. quantized)
+$MRT_TOOLS/check-model-unique-vals.py train/model.npz -b 3 --print_centers -o model_centers.out
+$MRT_TOOLS/diff-nums.py model_centers.out model_centers.expected -o model_centers.diff --numpy
+
+# Exit with success code
+exit 0