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

Returns a new instance of EarlyStopping.



69
70
71
72
# File 'lib/dnn/core/callbacks.rb', line 69

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

Instance Method Details

#after_epochObject



78
79
80
# File 'lib/dnn/core/callbacks.rb', line 78

def after_epoch
  @model.request_early_stop if judge_early_stopping_test
end

#after_train_on_batchObject



74
75
76
# File 'lib/dnn/core/callbacks.rb', line 74

def after_train_on_batch
  @model.request_early_stop if judge_early_stopping_train
end