Class: CooCoo::CostFunctions::CrossEntropy

Inherits:
Base show all
Defined in:
lib/coo-coo/cost_functions.rb

Overview

Implements the log cross-entropy cost function that is used with ActivationFunctions::SoftMax and ActivationFunctions::ShiftedSoftMax. This calls Math.log on the network’s output and multiples that by the target. Therefore good target values are 0...1.

Direct Known Subclasses

SoftMaxCrossEntropy

Class Method Summary collapse

Class Method Details

.call(target, x) ⇒ Object



65
66
67
# File 'lib/coo-coo/cost_functions.rb', line 65

def self.call(target, x)
  -x.log * target
end

.derivative(target, x) ⇒ Object



69
70
71
# File 'lib/coo-coo/cost_functions.rb', line 69

def self.derivative(target, x)
  -target / x
end