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
cfb628ba
Commit
cfb628ba
authored
May 15, 2019
by
Michael Glass
Committed by
mcarilli
May 15, 2019
Browse files
use verbose parameter to control print of grad overflow (#300)
parent
a3169768
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
2 deletions
+4
-2
apex/optimizers/fp16_optimizer.py
apex/optimizers/fp16_optimizer.py
+4
-2
No files found.
apex/optimizers/fp16_optimizer.py
View file @
cfb628ba
...
...
@@ -83,6 +83,7 @@ class FP16_Optimizer(object):
self
.
dynamic_loss_scale
=
False
self
.
cur_iter
=
0
self
.
cur_scale
=
static_loss_scale
self
.
verbose
=
verbose
def
zero_grad
(
self
,
set_grads_to_None
=
True
):
"""
...
...
@@ -173,8 +174,9 @@ class FP16_Optimizer(object):
def
_update_scale
(
self
,
skip
):
if
self
.
dynamic_loss_scale
:
if
skip
:
print
(
"
\n
Grad overflow on iteration"
,
self
.
cur_iter
)
print
(
"Using dynamic loss scale of"
,
self
.
cur_scale
)
if
self
.
verbose
:
print
(
"
\n
Grad overflow on iteration"
,
self
.
cur_iter
)
print
(
"Using dynamic loss scale of"
,
self
.
cur_scale
)
self
.
cur_scale
=
max
(
self
.
cur_scale
/
self
.
scale_factor
,
1
)
self
.
last_overflow_iter
=
self
.
cur_iter
else
:
...
...
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