From d80c555766318cbf285d663172bf4852d4871b46 Mon Sep 17 00:00:00 2001 From: Rico Sennrich Date: Fri, 4 Jul 2014 08:35:07 +0100 Subject: allow premultiplication during initialization --- src/neuralLM.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/neuralLM.h b/src/neuralLM.h index 104b2cc..ffe6ae7 100644 --- a/src/neuralLM.h +++ b/src/neuralLM.h @@ -28,13 +28,15 @@ class neuralLMShared { vocabulary input_vocab, output_vocab; model nn; - explicit neuralLMShared(const std::string &filename) { + explicit neuralLMShared(const std::string &filename, bool premultiply = false) { std::vector input_words, output_words; nn.read(filename, input_words, output_words); input_vocab = vocabulary(input_words); output_vocab = vocabulary(output_words); // this is faster but takes more memory - //nn.premultiply(); + if (premultiply) { + nn.premultiply(); + } } }; @@ -63,8 +65,8 @@ class neuralLM int start, null; public: - neuralLM(const std::string &filename) - : shared(new neuralLMShared(filename)), + neuralLM(const std::string &filename, bool premultiply = false) + : shared(new neuralLMShared(filename, premultiply)), ngram_size(shared->nn.ngram_size), normalization(false), weight(1.), -- cgit v1.2.3