Пример #1
0
    def __init__(self,
                 optimizer: str = 'AdamOptimizer',
                 clip_norm: float = None,
                 momentum: float = None,
                 **kwargs) -> None:
        TFModel.__init__(self, **kwargs)

        try:
            self._optimizer = cls_from_str(optimizer)
        except Exception:
            self._optimizer = getattr(tf.train, optimizer.split(':')[-1])
        if not issubclass(self._optimizer, tf.train.Optimizer):
            raise ConfigError("`optimizer` should be tensorflow.train.Optimizer subclass")
        self._clip_norm = clip_norm

        if (momentum is None) and\
                self._optimizer not in (tf.train.AdagradOptimizer,
                                        tf.train.AdagradOptimizer,
                                        tf.train.GradientDescentOptimizer,
                                        tf.train.ProximalGradientDescentOptimizer,
                                        tf.train.ProximalAdagradOptimizer):
            momentum = 0.9
        kwargs['momentum'] = momentum

        LRScheduledModel.__init__(self, **kwargs)
Пример #2
0
 def __init__(self, **kwargs):
     """
     Initialize model with given parameters
     Args:
         **kwargs: dictionary of parameters
     """
     self.opt = kwargs
     KerasModel.__init__(self, **kwargs)
     if not (isinstance(kwargs.get("learning_rate"), float)
             and isinstance(kwargs.get("learning_rate_decay"), float)):
         LRScheduledModel.__init__(self, **kwargs)
Пример #3
0
    def __init__(self,
                 optimizer: str = 'AdamOptimizer',
                 clip_norm: float = None,
                 momentum: float = None,
                 **kwargs) -> None:
        TFModel.__init__(self, **kwargs)

        try:
            self._optimizer = cls_from_str(optimizer)
        except Exception:
            self._optimizer = getattr(tf.train, optimizer.split(':')[-1])
        if not issubclass(self._optimizer, tf.train.Optimizer):
            raise ConfigError("`optimizer` should be tensorflow.train.Optimizer subclass")
        self._clip_norm = clip_norm

        LRScheduledModel.__init__(self, momentum=momentum, **kwargs)
Пример #4
0
 def process_event(self, *args, **kwargs):
     LRScheduledModel.process_event(self, *args, **kwargs)