Class: DNN::Callbacks::Logger
- Defined in:
- lib/dnn/core/callbacks.rb
Overview
A callback that save the log. The following logs will be recorded. epoch: Current epoch. train_loss: Batch training loss. test_loss: Mean test loss. test_accuracy: Test accuracy.
Instance Attribute Summary
Attributes inherited from Callback
Instance Method Summary collapse
- #after_epoch ⇒ Object
- #after_train_on_batch ⇒ Object
-
#get_log(tag) ⇒ Numo::NArray
Get a log.
-
#initialize ⇒ Logger
constructor
A new instance of Logger.
Constructor Details
#initialize ⇒ Logger
Returns a new instance of Logger.
107 108 109 110 111 112 113 114 |
# File 'lib/dnn/core/callbacks.rb', line 107 def initialize @log = { epoch: [], train_loss: [], test_loss: [], test_accuracy: [], } end |
Instance Method Details
#after_epoch ⇒ Object
116 117 118 |
# File 'lib/dnn/core/callbacks.rb', line 116 def after_epoch logging(:epoch, :test_loss, :test_accuracy) end |
#after_train_on_batch ⇒ Object
120 121 122 |
# File 'lib/dnn/core/callbacks.rb', line 120 def after_train_on_batch logging(:train_loss) end |
#get_log(tag) ⇒ Numo::NArray
Get a log.
127 128 129 130 131 132 133 134 |
# File 'lib/dnn/core/callbacks.rb', line 127 def get_log(tag) case tag when :epoch Numo::UInt32.cast(@log[tag]) else Numo::SFloat.cast(@log[tag]) end end |