diff --git a/config.py b/config.py index d2cda400dc2eaefe7ca11f3a9e0397436e7d61b7..b85bd66d2cccdb136b41fadc1440e398fafd61fe 100644 --- a/config.py +++ b/config.py @@ -87,7 +87,7 @@ class Config(object): USE_MINI_MASK = True MINI_MASK_SHAPE = (56, 56) # (height, width) of the mini-mask - # Input image resing + # Input image resizing # Images are resized such that the smallest side is >= IMAGE_MIN_DIM and # the longest side is <= IMAGE_MAX_DIM. In case both conditions can't # be satisfied together the IMAGE_MAX_DIM is enforced. @@ -148,6 +148,9 @@ class Config(object): # train the RPN. USE_RPN_ROIS = True + # Gradient norm clipping + GRADIENT_CLIP_NORM = 5.0 + def __init__(self): """Set values of computed attributes.""" # Effective batch size diff --git a/model.py b/model.py index d9d2df80273609f331b300c6fb9f0d73be2d423d..1307b0b7ce7abd8aacebfe0cf7dd8d4875c33830 100644 --- a/model.py +++ b/model.py @@ -2063,7 +2063,7 @@ class MaskRCNN(): """ # Optimizer object optimizer = keras.optimizers.SGD(lr=learning_rate, momentum=momentum, - clipnorm=5.0) + clipnorm=self.config.GRADIENT_CLIP_NORM) # Add Losses # First, clear previously set losses to avoid duplication self.keras_model._losses = []