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
73e05832
Commit
73e05832
authored
Sep 23, 2022
by
Chen Qian
Committed by
A. Unique TensorFlower
Sep 23, 2022
Browse files
Code changes to get ready for an incoming Keras optimizer migration.
PiperOrigin-RevId: 476479516
parent
c0525d49
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
3 deletions
+9
-3
official/core/base_trainer_test.py
official/core/base_trainer_test.py
+3
-1
official/modeling/fast_training/progressive/trainer_test.py
official/modeling/fast_training/progressive/trainer_test.py
+6
-2
No files found.
official/core/base_trainer_test.py
View file @
73e05832
...
...
@@ -319,7 +319,9 @@ class TrainerTest(tf.test.TestCase, parameterized.TestCase):
self
.
assertFalse
(
trainer
.
optimizer
.
dynamic
)
self
.
assertEqual
(
trainer
.
optimizer
.
initial_scale
,
loss_scale
)
else
:
self
.
assertIsInstance
(
trainer
.
optimizer
,
tf
.
keras
.
optimizers
.
SGD
)
self
.
assertIsInstance
(
trainer
.
optimizer
,
(
tf
.
keras
.
optimizers
.
SGD
,
tf
.
keras
.
optimizers
.
legacy
.
SGD
))
metrics
=
trainer
.
train
(
tf
.
convert_to_tensor
(
5
,
dtype
=
tf
.
int32
))
self
.
assertIn
(
'training_loss'
,
metrics
)
...
...
official/modeling/fast_training/progressive/trainer_test.py
View file @
73e05832
...
...
@@ -226,9 +226,13 @@ class TrainerWithMaskedLMTaskTest(tf.test.TestCase, parameterized.TestCase):
task
=
TestPolicy
(
None
,
config
.
task
)
trainer
=
trainer_lib
.
ProgressiveTrainer
(
config
,
task
,
self
.
get_temp_dir
())
if
mixed_precision_dtype
!=
'float16'
:
self
.
assertIsInstance
(
trainer
.
optimizer
,
tf
.
keras
.
optimizers
.
SGD
)
self
.
assertIsInstance
(
trainer
.
optimizer
,
(
tf
.
keras
.
optimizers
.
SGD
,
tf
.
keras
.
optimizers
.
legacy
.
SGD
))
elif
mixed_precision_dtype
==
'float16'
and
loss_scale
is
None
:
self
.
assertIsInstance
(
trainer
.
optimizer
,
tf
.
keras
.
optimizers
.
SGD
)
self
.
assertIsInstance
(
trainer
.
optimizer
,
(
tf
.
keras
.
optimizers
.
SGD
,
tf
.
keras
.
optimizers
.
legacy
.
SGD
))
metrics
=
trainer
.
train
(
tf
.
convert_to_tensor
(
5
,
dtype
=
tf
.
int32
))
self
.
assertIn
(
'training_loss'
,
metrics
)
...
...
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