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
fc227c3b
Commit
fc227c3b
authored
Mar 25, 2021
by
Austin Myers
Committed by
TF Object Detection Team
Mar 25, 2021
Browse files
Fix Keras hyperparams get_regularizer_weight() to return float.
PiperOrigin-RevId: 365177695
parent
81e456dd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
3 deletions
+5
-3
research/object_detection/builders/hyperparams_builder.py
research/object_detection/builders/hyperparams_builder.py
+2
-2
research/object_detection/builders/hyperparams_builder_test.py
...rch/object_detection/builders/hyperparams_builder_test.py
+3
-1
No files found.
research/object_detection/builders/hyperparams_builder.py
View file @
fc227c3b
...
...
@@ -176,9 +176,9 @@ class KerasLayerHyperparams(object):
"""
regularizer
=
self
.
_op_params
[
'kernel_regularizer'
]
if
hasattr
(
regularizer
,
'l1'
):
return
regularizer
.
l1
return
float
(
regularizer
.
l1
)
elif
hasattr
(
regularizer
,
'l2'
):
return
regularizer
.
l2
return
float
(
regularizer
.
l2
)
else
:
return
None
...
...
research/object_detection/builders/hyperparams_builder_test.py
View file @
fc227c3b
...
...
@@ -558,7 +558,7 @@ class KerasHyperparamsBuilderTest(tf.test.TestCase):
result
=
regularizer
(
tf
.
constant
(
weights
)).
numpy
()
self
.
assertAllClose
(
np
.
abs
(
weights
).
sum
()
*
0.5
,
result
)
def
test_return_l2_regularize
r
_weights_keras
(
self
):
def
test_return_l2_regularize
d
_weights_keras
(
self
):
conv_hyperparams_text_proto
=
"""
regularizer {
l2_regularizer {
...
...
@@ -598,6 +598,7 @@ class KerasHyperparamsBuilderTest(tf.test.TestCase):
conv_hyperparams_proto
)
regularizer_weight
=
keras_config
.
get_regularizer_weight
()
self
.
assertIsInstance
(
regularizer_weight
,
float
)
self
.
assertAlmostEqual
(
regularizer_weight
,
0.5
)
def
test_return_l2_regularizer_weight_keras
(
self
):
...
...
@@ -618,6 +619,7 @@ class KerasHyperparamsBuilderTest(tf.test.TestCase):
conv_hyperparams_proto
)
regularizer_weight
=
keras_config
.
get_regularizer_weight
()
self
.
assertIsInstance
(
regularizer_weight
,
float
)
self
.
assertAlmostEqual
(
regularizer_weight
,
0.25
)
def
test_return_undefined_regularizer_weight_keras
(
self
):
...
...
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