Class: DNN::Callbacks::EarlyStopping

Inherits:
Callback
  • Object
show all
Defined in:
lib/dnn/core/callbacks.rb

Overview

A callback to stop training the model early after test on batch.

Instance Attribute Summary

Attributes inherited from Callback

#model

Instance Method Summary collapse

Constructor Details

#initialize(trigger, tolerance) ⇒ EarlyStopping



50
51
52
53
# File 'lib/dnn/core/callbacks.rb', line 50

def initialize(trigger, tolerance)
  @trigger = trigger
  @tolerance = tolerance
end

Instance Method Details

#after_epochObject



59
60
61
# File 'lib/dnn/core/callbacks.rb', line 59

def after_epoch
  throw :stop, "Early stopped." if judge_early_stopping_test
end

#after_train_on_batchObject



55
56
57
# File 'lib/dnn/core/callbacks.rb', line 55

def after_train_on_batch
  throw :stop, "Early stopped." if judge_early_stopping_train
end