Skip to content

Commit 26faeb5

Browse files
tensorflower-gardeneraman2930
authored andcommitted
Use mixed precision for gelu intermediate activation in BERT SQuAD model
PiperOrigin-RevId: 303407939
1 parent e8c32e8 commit 26faeb5

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

official/nlp/modeling/layers/transformer.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,8 @@ def build(self, input_shape):
142142
kernel_constraint=self._kernel_constraint,
143143
bias_constraint=self._bias_constraint,
144144
name="intermediate")
145-
# Use float32 in intermediate gelu activation for numeric stability.
146-
# TODO(b/149117297): investigate gelu numeric stability.
147145
self._intermediate_activation_layer = tf.keras.layers.Activation(
148-
self._intermediate_activation, dtype=tf.float32)
146+
self._intermediate_activation)
149147
self._output_dense = dense_einsum.DenseEinsum(
150148
output_shape=hidden_size,
151149
kernel_initializer=self._kernel_initializer,

0 commit comments

Comments
 (0)