Commit cfb628ba authored by Michael Glass's avatar Michael Glass Committed by mcarilli
Browse files

use verbose parameter to control print of grad overflow (#300)

parent a3169768
...@@ -83,6 +83,7 @@ class FP16_Optimizer(object): ...@@ -83,6 +83,7 @@ class FP16_Optimizer(object):
self.dynamic_loss_scale = False self.dynamic_loss_scale = False
self.cur_iter = 0 self.cur_iter = 0
self.cur_scale = static_loss_scale self.cur_scale = static_loss_scale
self.verbose = verbose
def zero_grad(self, set_grads_to_None=True): def zero_grad(self, set_grads_to_None=True):
""" """
...@@ -173,6 +174,7 @@ class FP16_Optimizer(object): ...@@ -173,6 +174,7 @@ class FP16_Optimizer(object):
def _update_scale(self, skip): def _update_scale(self, skip):
if self.dynamic_loss_scale: if self.dynamic_loss_scale:
if skip: if skip:
if self.verbose:
print("\nGrad overflow on iteration", self.cur_iter) print("\nGrad overflow on iteration", self.cur_iter)
print("Using dynamic loss scale of", self.cur_scale) print("Using dynamic loss scale of", self.cur_scale)
self.cur_scale = max(self.cur_scale/self.scale_factor, 1) self.cur_scale = max(self.cur_scale/self.scale_factor, 1)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment