tf-keras-skeleton.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:LIE 作者: EmbraceLife 项目源码 文件源码
def __init__(self,
                   monitor='val_loss',
                   min_delta=0,
                   patience=0,
                   verbose=0,
                   mode='auto'):
        super(EarlyStopping, self).__init__()

        self.monitor = monitor
        self.patience = patience
        self.verbose = verbose
        self.min_delta = min_delta
        self.wait = 0
        self.stopped_epoch = 0

        if mode not in ['auto', 'min', 'max']:
          logging.warning('EarlyStopping mode %s is unknown, '
                          'fallback to auto mode.' % (self.mode))
          mode = 'auto'

        if mode == 'min':
          self.monitor_op = np.less
        elif mode == 'max':
          self.monitor_op = np.greater
        else:
          if 'acc' in self.monitor or self.monitor.startswith('fmeasure'):
            self.monitor_op = np.greater
          else:
            self.monitor_op = np.less

        if self.monitor_op == np.greater:
          self.min_delta *= 1
        else:
          self.min_delta *= -1
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号