Class: Neuronet::Perceptron
- Inherits:
-
Object
- Object
- Neuronet::Perceptron
- Includes:
- Arrayable, Exportable, NetworkStats, Trainable
- Defined in:
- lib/neuronet/perceptron.rb
Overview
Perceptron
Instance Attribute Summary collapse
-
#input_layer ⇒ Object
readonly
Returns the value of attribute input_layer.
-
#output_layer ⇒ Object
readonly
Returns the value of attribute output_layer.
Instance Method Summary collapse
- #*(other) ⇒ Object
-
#initialize(input_size, output_size, input_neuron: InputNeuron, output_neuron: OutputNeuron) ⇒ Perceptron
constructor
A new instance of Perceptron.
- #set(values) ⇒ Object
- #to_a ⇒ Object
- #values ⇒ Object
Methods included from Arrayable
#[], #each, #each_with_index, #map, #reverse, #size
Methods included from Trainable
Methods included from Exportable
#export, #export_to_file, #import, #import_from_file
Methods included from NetworkStats
#expected_nju, #expected_nju!, #njus
Constructor Details
#initialize(input_size, output_size, input_neuron: InputNeuron, output_neuron: OutputNeuron) ⇒ Perceptron
Returns a new instance of Perceptron.
11 12 13 14 15 16 |
# File 'lib/neuronet/perceptron.rb', line 11 def initialize(input_size, output_size, input_neuron: InputNeuron, output_neuron: OutputNeuron) @input_layer = InputLayer.new(input_size, input_neuron:) @output_layer = OutputLayer.new(output_size, output_neuron:) @output_layer.connect(@input_layer) end |
Instance Attribute Details
#input_layer ⇒ Object (readonly)
Returns the value of attribute input_layer.
18 19 20 |
# File 'lib/neuronet/perceptron.rb', line 18 def input_layer @input_layer end |
#output_layer ⇒ Object (readonly)
Returns the value of attribute output_layer.
18 19 20 |
# File 'lib/neuronet/perceptron.rb', line 18 def output_layer @output_layer end |
Instance Method Details
#*(other) ⇒ Object
28 29 30 31 |
# File 'lib/neuronet/perceptron.rb', line 28 def *(other) set(other) values end |
#set(values) ⇒ Object
20 21 22 |
# File 'lib/neuronet/perceptron.rb', line 20 def set(values) @input_layer.set(values) end |
#to_a ⇒ Object
33 |
# File 'lib/neuronet/perceptron.rb', line 33 def to_a = [@input_layer, @output_layer] |
#values ⇒ Object
24 25 26 |
# File 'lib/neuronet/perceptron.rb', line 24 def values @output_layer.values end |