Class: Neuronet::ScaledNetwork

Inherits:
FeedForward show all
Defined in:
lib/neuronet.rb

Overview

ScaledNetwork is a subclass of FeedForwardNetwork. It automatically scales the problem given to it by using a Scale type instance set in @distribution. The attribute, @distribution, is set to Neuronet::Gausian.new by default, but one can change this to Scale, LogNormal, or one’s own custom mapper.

Instance Attribute Summary collapse

Attributes inherited from FeedForward

#in, #learning, #out, #yang, #yin

Instance Method Summary collapse

Methods inherited from FeedForward

#exemplar, #mu, #muk, #num, #update

Constructor Details

#initialize(layers) ⇒ ScaledNetwork

Returns a new instance of ScaledNetwork.



427
428
429
430
# File 'lib/neuronet.rb', line 427

def initialize(layers)
  super(layers)
  @distribution = Gaussian.new
end

Instance Attribute Details

#distributionObject

Returns the value of attribute distribution.



425
426
427
# File 'lib/neuronet.rb', line 425

def distribution
  @distribution
end

Instance Method Details

#inputObject



456
457
458
# File 'lib/neuronet.rb', line 456

def input
  @distribution.unmapped_input(super)
end

#outputObject



452
453
454
# File 'lib/neuronet.rb', line 452

def output
  @distribution.unmapped_output(super)
end

#reset(inputs) ⇒ Object

ScaledNetwork#reset works just like FeedForwardNetwork’s set method, but calls distribution.set( values ) first. Sometimes you’ll want to set the distribution with the entire data set and the use set, and then there will be times you’ll want to set the distribution with each input and use reset.



447
448
449
450
# File 'lib/neuronet.rb', line 447

def reset(inputs)
  @distribution.set(inputs)
  set(inputs)
end

#set(inputs) ⇒ Object

Parameters:

  • values (List of Float)


437
438
439
# File 'lib/neuronet.rb', line 437

def set(inputs)
  super(@distribution.mapped_input(inputs))
end

#train!(targets) ⇒ Object



432
433
434
# File 'lib/neuronet.rb', line 432

def train!(targets)
  super(@distribution.mapped_output(targets))
end