class CooCoo::LinearLayer

Attributes

activation_function[RW]
size[R]

Public Class Methods

from_hash(h, network = nil) click to toggle source
# File lib/coo-coo/linear_layer.rb, line 55
def self.from_hash(h, network = nil)
  new(h[:size], ActivationFunctions.from_name(h[:f]))
end
new(size, activation_function = CooCoo::ActivationFunctions::Identity.instance) click to toggle source
# File lib/coo-coo/linear_layer.rb, line 12
def initialize(size, activation_function = CooCoo::ActivationFunctions::Identity.instance)
  @size = size
  @activation_function = activation_function
end

Public Instance Methods

==(other) click to toggle source
# File lib/coo-coo/linear_layer.rb, line 41
def ==(other)
  other.kind_of?(self.class) &&
    num_inputs == other.num_inputs &&
    size == other.size &&
    activation_function == other.activation_function
end
adjust_weights!(deltas) click to toggle source
# File lib/coo-coo/linear_layer.rb, line 33
def adjust_weights!(deltas)
  self
end
backprop(input, output, errors, hidden_state) click to toggle source
# File lib/coo-coo/linear_layer.rb, line 25
def backprop(input, output, errors, hidden_state)
  [ errors * @activation_function.derivative(input, output), hidden_state ]
end
forward(input, hidden_state) click to toggle source
# File lib/coo-coo/linear_layer.rb, line 21
def forward(input, hidden_state)
  [ @activation_function.call(input), hidden_state ]
end
num_inputs() click to toggle source
# File lib/coo-coo/linear_layer.rb, line 17
def num_inputs
  size
end
to_hash(network = nil) click to toggle source
# File lib/coo-coo/linear_layer.rb, line 48
def to_hash(network = nil)
  { type: self.class.name,
    size: size,
    f: @activation_function.name
  }
end
transfer_error(deltas) click to toggle source
# File lib/coo-coo/linear_layer.rb, line 29
def transfer_error(deltas)
  deltas
end
weight_deltas(inputs, deltas) click to toggle source
# File lib/coo-coo/linear_layer.rb, line 37
def weight_deltas(inputs, deltas)
  deltas
end