Class: DNN::Callbacks::CheckPoint

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

Overview

A callback that save the model at the after of the epoch.

Instance Attribute Summary

Attributes inherited from Callback

#model

Instance Method Summary collapse

Constructor Details

#initialize(base_file_name, include_model: true, interval: 1) ⇒ CheckPoint

Returns a new instance of CheckPoint.



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

def initialize(base_file_name, include_model: true, interval: 1)
  @base_file_name = base_file_name
  @include_model = include_model
  @interval = interval
end

Instance Method Details

#after_epochObject



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

def after_epoch
  saver = Savers::MarshalSaver.new(@model, include_model: @include_model)
  if @model.last_log[:epoch] % @interval == 0
    saver.save(@base_file_name + "_epoch#{model.last_log[:epoch]}.marshal")
  end
end