Commit d2d32f46 authored by A. Unique TensorFlower's avatar A. Unique TensorFlower
Browse files

convert Dimension to int to avoid "TypeError: unsupported operand type(s) for...

convert Dimension to int to avoid "TypeError: unsupported operand type(s) for /: float and Dimension"

PiperOrigin-RevId: 358988747
parent ad77aed9
......@@ -202,7 +202,7 @@ class TransformerDecoderBlock(tf.keras.layers.Layer):
raise ValueError(
"The hidden size (%d) is not a multiple of the number of attention "
"heads (%d)" % (hidden_size, self.num_attention_heads))
self.attention_head_size = int(hidden_size / self.num_attention_heads)
self.attention_head_size = int(hidden_size) // self.num_attention_heads
common_kwargs = dict(
bias_initializer=self._bias_initializer,
kernel_regularizer=self._kernel_regularizer,
......
......@@ -591,5 +591,6 @@ class TransformerDecoder(tf.keras.layers.Layer):
def attention_initializer(hidden_size):
"""Initializer for attention layers in Seq2SeqTransformer."""
hidden_size = int(hidden_size)
limit = math.sqrt(6.0 / (hidden_size + hidden_size))
return tf.keras.initializers.RandomUniform(minval=-limit, maxval=limit)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment