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
8a1dbbad
Commit
8a1dbbad
authored
Jun 10, 2020
by
Chen Chen
Committed by
A. Unique TensorFlower
Jun 10, 2020
Browse files
Fix get_config() of MaskedSoftmax.
PiperOrigin-RevId: 315767729
parent
4cd908ef
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
1 deletion
+13
-1
official/nlp/modeling/layers/masked_softmax.py
official/nlp/modeling/layers/masked_softmax.py
+4
-1
official/nlp/modeling/layers/masked_softmax_test.py
official/nlp/modeling/layers/masked_softmax_test.py
+9
-0
No files found.
official/nlp/modeling/layers/masked_softmax.py
View file @
8a1dbbad
...
...
@@ -64,6 +64,9 @@ class MaskedSoftmax(tf.keras.layers.Layer):
scores
,
axis
=
self
.
_normalization_axes
,
keepdims
=
True
))
def
get_config
(
self
):
config
=
{
'mask_expansion_axes'
:
self
.
_mask_expansion_axes
}
config
=
{
'mask_expansion_axes'
:
self
.
_mask_expansion_axes
,
'normalization_axes'
:
self
.
_normalization_axes
}
base_config
=
super
(
MaskedSoftmax
,
self
).
get_config
()
return
dict
(
list
(
base_config
.
items
())
+
list
(
config
.
items
()))
official/nlp/modeling/layers/masked_softmax_test.py
View file @
8a1dbbad
...
...
@@ -105,6 +105,15 @@ class MaskedSoftmaxLayerTest(keras_parameterized.TestCase):
is_zeros
=
np
.
greater
(
output_data
,
0
)
self
.
assertAllEqual
(
expected_zeros
,
is_zeros
)
def
test_serialize_deserialize
(
self
):
test_layer
=
masked_softmax
.
MaskedSoftmax
(
mask_expansion_axes
=
[
1
],
normalization_axes
=
[
6
,
7
])
new_layer
=
masked_softmax
.
MaskedSoftmax
.
from_config
(
test_layer
.
get_config
())
# If the serialization was successful, the new config should match the old.
self
.
assertAllEqual
(
test_layer
.
get_config
(),
new_layer
.
get_config
())
if
__name__
==
'__main__'
:
tf
.
test
.
main
()
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