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
MMCV
Commits
34127b9f
Unverified
Commit
34127b9f
authored
Sep 27, 2020
by
Wenwei Zhang
Committed by
GitHub
Sep 27, 2020
Browse files
[enhance]: show grad norm in fp16 optimizer hook (#584)
parent
71952ff3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
1 deletion
+5
-1
mmcv/runner/hooks/optimizer.py
mmcv/runner/hooks/optimizer.py
+5
-1
No files found.
mmcv/runner/hooks/optimizer.py
View file @
34127b9f
...
...
@@ -113,7 +113,11 @@ class Fp16OptimizerHook(OptimizerHook):
if
param
.
grad
is
not
None
:
param
.
grad
.
div_
(
self
.
loss_scale
)
if
self
.
grad_clip
is
not
None
:
self
.
clip_grads
(
fp32_weights
)
grad_norm
=
self
.
clip_grads
(
fp32_weights
)
if
grad_norm
is
not
None
:
# Add grad norm to the logger
runner
.
log_buffer
.
update
({
'grad_norm'
:
float
(
grad_norm
)},
runner
.
outputs
[
'num_samples'
])
# update fp32 params
runner
.
optimizer
.
step
()
# copy fp32 params to the fp16 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