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
OpenDAS
apex
Commits
1c464b48
Commit
1c464b48
authored
Apr 23, 2019
by
ptrblck
Committed by
mcarilli
Apr 23, 2019
Browse files
move and fix check_optimizers (#268)
parent
28097c99
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
3 deletions
+4
-3
apex/amp/_initialize.py
apex/amp/_initialize.py
+4
-3
No files found.
apex/amp/_initialize.py
View file @
1c464b48
...
...
@@ -111,7 +111,7 @@ def check_optimizers(optimizers):
if
isinstance
(
optim
,
FP16_Optimizer_for_fused
):
bad_optim_type
=
"apex.optimizers.FP16_Optimizer"
if
bad_optim_type
is
not
None
:
raise
RuntimeError
(
"An incoming optimizer is an instance of {}. "
.
format
(
optim_type
)
+
raise
RuntimeError
(
"An incoming optimizer is an instance of {}. "
.
format
(
bad_
optim_type
)
+
"The optimizer(s) passed to amp.initialize() must be bare
\n
"
"instances of either ordinary Pytorch optimizers, or Apex fused
\n
"
"optimizers (currently just FusedAdam, but FusedSGD will be added
\n
"
...
...
@@ -148,7 +148,9 @@ def _initialize(models, optimizers, properties, num_losses=1, cast_model_outputs
optimizers
=
[]
elif
isinstance
(
optimizers
,
list
):
optimizers_was_list
=
True
check_optimizers
(
optimizers
)
else
:
check_optimizers
([
optimizers
])
raise
TypeError
(
"optimizers must be either a single optimizer or a list of optimizers."
)
if
isinstance
(
models
,
torch
.
nn
.
Module
):
...
...
@@ -164,7 +166,6 @@ def _initialize(models, optimizers, properties, num_losses=1, cast_model_outputs
if
not
_amp_state
.
allow_incoming_model_not_fp32
:
check_params_fp32
(
models
)
check_optimizers
(
optimizers
)
# In the future, when FP16_Optimizer can be deprecated and master weights can
# become an attribute, remember to stash master weights before casting the model.
...
...
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