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.



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

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

Instance Attribute Details

#distributionObject

Returns the value of attribute distribution.



422
423
424
# File 'lib/neuronet.rb', line 422

def distribution
  @distribution
end

Instance Method Details

#inputObject



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

def input
  @distribution.unmapped_input(super)
end

#outputObject



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

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.



444
445
446
447
# File 'lib/neuronet.rb', line 444

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

#set(inputs) ⇒ Object

Parameters:

  • values (List of Float)


434
435
436
# File 'lib/neuronet.rb', line 434

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

#train!(targets) ⇒ Object



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

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