Class: CooCoo::CostFunctions::Base Abstract

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

Overview

This class is abstract.

Defines and documents the cost functions’ interface.

Be sure to call CostFunctions.register inside your subclass.

Direct Known Subclasses

CrossEntropy, MeanSquare

Class Method Summary collapse

Class Method Details

.call(target, x) ⇒ Vector

Returns the cost between the target output and actual output.

Parameters:

  • target (Vector)

    Desired value

  • x (Vector)

    A network’s actual output

Returns:

  • (Vector)

    The cost of the target for this output

Raises:

  • (NotImplementedError)


26
27
28
# File 'lib/coo-coo/cost_functions.rb', line 26

def self.call(target, x)
  raise NotImplementedError.new
end

.derivative(target, x, y = nil) ⇒ Vector

Returns the derivative of the cost function, #call. This is what gets fed into the network to determine the changes.

Parameters:

  • target (Vector)

    Desired value

  • x (Vector)

    A network’s actual output

  • y (Vector) (defaults to: nil)

    The results from a previous #call

Returns:

Raises:

  • (NotImplementedError)


37
38
39
# File 'lib/coo-coo/cost_functions.rb', line 37

def self.derivative(target, x, y = nil)
  raise NotImplementedError.new
end