Module: Neuronet::Yin

Defined in:
lib/neuronet.rb

Overview

Yin is a network wich has its @yin layer initially mirroring @in.

Class Method Summary collapse

Class Method Details

.bless(myself) ⇒ Object

Yin.bless sets the bias of each @yin to 0.5, and the weight of pairing (@yin, @in) connections to one. This makes @yin initially mirror @in. The pairing is done starting with (@yin, @in). That is, starting with (@yin.first, @in.first).



488
489
490
491
492
493
494
495
496
497
498
499
500
# File 'lib/neuronet.rb', line 488

def self.bless(myself)
  yin = myself.yin
  if yin.length < (in_length = myself.in.length)
    raise "First hidden layer, yin, needs to have at least the same length as input"
  end
  # connections from yin[i] to in[i] are 1... mirroring to start.
  0.upto(in_length-1) do |index|
    node = yin[index]
    node.connections[index].weight = 1.0
    node.bias = -0.5
  end
  return myself
end