From 4ff79ac5bd74a30abfbbdf72e951fae4db67774a Mon Sep 17 00:00:00 2001 From: Jindrich Libovicky Date: Wed, 7 Mar 2018 15:30:24 +0100 Subject: [PATCH] rename transformer dimension so it does not collide --- neuralmonkey/decoders/transformer.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/neuralmonkey/decoders/transformer.py b/neuralmonkey/decoders/transformer.py index d6cf99fd0..6ac42c5b6 100644 --- a/neuralmonkey/decoders/transformer.py +++ b/neuralmonkey/decoders/transformer.py @@ -107,9 +107,9 @@ def __init__(self, self.encoder_states = get_attention_states(self.encoder) self.encoder_mask = get_attention_mask(self.encoder) - self.dimension = self.encoder_states.get_shape()[2].value + self.model_dimension = self.encoder_states.get_shape()[2].value - if self.embedding_size != self.dimension: + if self.embedding_size != self.model_dimension: raise ValueError("Model dimension and input embedding size" "do not match") @@ -120,12 +120,12 @@ def __init__(self, @property def output_dimension(self) -> int: - return self.dimension + return self.model_dimension def embed_inputs(self, inputs: tf.Tensor) -> tf.Tensor: embedded = tf.nn.embedding_lookup(self.embedding_matrix, inputs) length = tf.shape(inputs)[1] - return embedded + position_signal(self.dimension, length) + return embedded + position_signal(self.model_dimension, length) @tensor def embedded_train_inputs(self) -> tf.Tensor: @@ -216,7 +216,8 @@ def layer(self, level: int, inputs: tf.Tensor, # Feed-forward output projection + dropout ff_output = tf.layers.dense( - ff_hidden_drop, self.dimension, name="ff_out_{}".format(level)) + ff_hidden_drop, self.model_dimension, + name="ff_out_{}".format(level)) ff_output = dropout(ff_output, self.dropout_keep_prob, self.train_mode) # Residual connections + layer normalization