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
-
#initialize(input_count, output_count, activation: :relu) ⇒ Layer
constructor
A new instance of Layer.
- #inspect ⇒ Object
- #parameters ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(input_count, output_count, activation: :relu) ⇒ Layer
Returns a new instance of Layer.
46 47 48 49 50 |
# File 'lib/perceptron.rb', line 46 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.
44 45 46 |
# File 'lib/perceptron.rb', line 44 def neurons @neurons end |
Instance Method Details
#apply(x = 0) ⇒ Object
52 53 54 |
# File 'lib/perceptron.rb', line 52 def apply(x = 0) @neurons.map { |n| n.apply(x) } end |
#inspect ⇒ Object
64 65 66 |
# File 'lib/perceptron.rb', line 64 def inspect @neurons.map(&:inspect).join("\n") end |
#parameters ⇒ Object
56 57 58 |
# File 'lib/perceptron.rb', line 56 def parameters @neurons.map { |n| n.parameters }.flatten end |
#to_s ⇒ Object
60 61 62 |
# File 'lib/perceptron.rb', line 60 def to_s @neurons.join("\n") end |