Class: DNN::Callbacks::CheckPoint
- 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
Instance Method Summary collapse
- #after_epoch ⇒ Object
-
#initialize(base_file_name, include_model: true, interval: 1) ⇒ CheckPoint
constructor
A new instance of CheckPoint.
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_epoch ⇒ Object
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 |