def on_epoch_end(self, epoch, logs={}):
current = self.monitor(self.previous_weights, self.model.get_weights())
self.previous_weights = self.model.get_weights()
if current is None:
warnings.warn('Early stopping requires %s available!' %
(self.monitor), RuntimeWarning)
if np.less(current, self.threshold_value):
if current == 0:
self.model.stop_training = True
if self.verbose > 0:
print('Epoch %05d: early stopping: ratio weights = 0' % (epoch))
elif self.wait >= self.patience:
if self.verbose > 0:
print('Epoch %05d: early stopping: ratio weights below %.4f' % (epoch, self.threshold_value))
self.model.stop_training = True
self.wait += 1
else:
self.wait = 0
评论列表
文章目录