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
33082d2b
Commit
33082d2b
authored
Feb 05, 2020
by
Kexin Yu
Browse files
fix attribute name mismatch in state_dict() and load_state_dict()
parent
858d7899
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
2 deletions
+2
-2
apex/contrib/optimizers/fp16_optimizer.py
apex/contrib/optimizers/fp16_optimizer.py
+2
-2
No files found.
apex/contrib/optimizers/fp16_optimizer.py
View file @
33082d2b
...
...
@@ -196,7 +196,7 @@ class FP16_Optimizer(object):
state_dict
[
'scale_factor'
]
=
self
.
scale_factor
state_dict
[
'scale_window'
]
=
self
.
scale_window
state_dict
[
'optimizer_state_dict'
]
=
self
.
optimizer
.
state_dict
()
state_dict
[
'fp32_groups
_flat
'
]
=
self
.
fp32_groups
_flat
state_dict
[
'fp32_groups'
]
=
self
.
fp32_groups
return
state_dict
def
load_state_dict
(
self
,
state_dict
):
...
...
@@ -238,5 +238,5 @@ class FP16_Optimizer(object):
# the current optimizer instance. In our case, as long as the current FP16_Optimizer has been
# constructed in the same way as the one whose state_dict we are loading, the same master params
# are guaranteed to exist, so we can just copy_() from the saved master params.
for
current
,
saved
in
zip
(
self
.
fp32_groups
_flat
,
state_dict
[
'fp32_groups
_flat
'
]):
for
current
,
saved
in
zip
(
self
.
fp32_groups
,
state_dict
[
'fp32_groups'
]):
current
.
data
.
copy_
(
saved
.
data
)
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