Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
ResNet50_tensorflow
Commits
7fdde945
Commit
7fdde945
authored
May 14, 2022
by
Frederick Liu
Committed by
A. Unique TensorFlower
May 14, 2022
Browse files
[efficient] Make ReLU numeric stable.
PiperOrigin-RevId: 448695305
parent
fa268452
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
1 deletion
+4
-1
official/nlp/modeling/layers/kernel_attention.py
official/nlp/modeling/layers/kernel_attention.py
+4
-1
No files found.
official/nlp/modeling/layers/kernel_attention.py
View file @
7fdde945
...
@@ -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
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment