Class: BackProp::Layer
- Inherits:
-
Object
- Object
- BackProp::Layer
- Defined in:
- lib/perceptron.rb
Instance Attribute Summary collapse
-
#neurons ⇒ Object
readonly
Returns the value of attribute neurons.
Instance Method Summary collapse
- #apply(x = 0) ⇒ Object
- #descend(step_size) ⇒ Object
-
#initialize(input_count, output_count, activation: :relu) ⇒ Layer
constructor
A new instance of Layer.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(input_count, output_count, activation: :relu) ⇒ Layer
Returns a new instance of Layer.
49 50 51 52 53 |
# File 'lib/perceptron.rb', line 49 def initialize(input_count, output_count, activation: :relu) @neurons = Array.new(output_count) { Neuron.new(input_count, activation: activation) } end |
Instance Attribute Details
#neurons ⇒ Object (readonly)
Returns the value of attribute neurons.
47 48 49 |
# File 'lib/perceptron.rb', line 47 def neurons @neurons end |
Instance Method Details
#apply(x = 0) ⇒ Object
55 56 57 |
# File 'lib/perceptron.rb', line 55 def apply(x = 0) @neurons.map { |n| n.apply(x) } end |
#descend(step_size) ⇒ Object
59 60 61 62 |
# File 'lib/perceptron.rb', line 59 def descend(step_size) @neurons.each { |n| n.descend(step_size) } self end |
#inspect ⇒ Object
68 69 70 |
# File 'lib/perceptron.rb', line 68 def inspect @neurons.map(&:inspect).join("\n") end |
#to_s ⇒ Object
64 65 66 |
# File 'lib/perceptron.rb', line 64 def to_s @neurons.join("\n") end |