class DNN::Callbacks::Logger
A callback that save the log. The following logs will be recorded. epoch: Current epoch. step: Current step in epoch. train_loss: Batch training loss. test_loss: Mean test loss. test_accuracy: Test accuracy.
Public Class Methods
new()
click to toggle source
# File lib/dnn/core/callbacks.rb, line 112 def initialize @log = { epoch: [], step: [], train_loss: [], test_loss: [], test_accuracy: [], } end
Public Instance Methods
after_epoch()
click to toggle source
# File lib/dnn/core/callbacks.rb, line 122 def after_epoch logging(:epoch, :test_loss, :test_accuracy) end
after_train_on_batch()
click to toggle source
# File lib/dnn/core/callbacks.rb, line 126 def after_train_on_batch logging(:train_loss, :step) end
get_log(tag)
click to toggle source
Get a log. @param [Symbol] tag Tag indicating the type of Log. @return [Numo::NArray] Return the recorded log.
# File lib/dnn/core/callbacks.rb, line 133 def get_log(tag) case tag when :epoch, :step Xumo::UInt32.cast(@log[tag]) else Xumo::SFloat.cast(@log[tag]) end end
Private Instance Methods
logging(*tags)
click to toggle source
# File lib/dnn/core/callbacks.rb, line 142 def logging(*tags) tags.each do |tag| @log[tag] ||= [] @log[tag] << model.last_log[tag] end end