Commit 7fdde945 authored by Frederick Liu's avatar Frederick Liu Committed by A. Unique TensorFlower
Browse files

[efficient] Make ReLU numeric stable.

PiperOrigin-RevId: 448695305
parent fa268452
...@@ -117,7 +117,10 @@ _TRANSFORM_MAP = { ...@@ -117,7 +117,10 @@ _TRANSFORM_MAP = {
h=lambda x: 1), h=lambda x: 1),
"relu": "relu":
functools.partial( functools.partial(
_generalized_kernel, f=tf.keras.activations.relu, h=lambda x: 1), _generalized_kernel,
# Improve numerical stability and avoid NaNs in some cases by adding
# a tiny epsilon.
f=lambda x: tf.keras.activations.relu(x) + 1e-3, h=lambda x: 1),
"square": "square":
functools.partial( functools.partial(
_generalized_kernel, f=tf.math.square, h=lambda x: 1), _generalized_kernel, f=tf.math.square, h=lambda x: 1),
......
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