Class: Micrograd::Layer
- Inherits:
-
Object
- Object
- Micrograd::Layer
- Defined in:
- lib/micrograd/layer.rb
Instance Attribute Summary collapse
-
#neurons ⇒ Object
readonly
Returns the value of attribute neurons.
Instance Method Summary collapse
- #call(xs) ⇒ Object
-
#initialize(inputs, outputs) ⇒ Layer
constructor
A new instance of Layer.
- #parameters ⇒ Object
Constructor Details
#initialize(inputs, outputs) ⇒ Layer
Returns a new instance of Layer.
5 6 7 |
# File 'lib/micrograd/layer.rb', line 5 def initialize(inputs, outputs) @neurons = Array.new(outputs) { Neuron.new(inputs) } end |
Instance Attribute Details
#neurons ⇒ Object (readonly)
Returns the value of attribute neurons.
9 10 11 |
# File 'lib/micrograd/layer.rb', line 9 def neurons @neurons end |
Instance Method Details
#call(xs) ⇒ Object
11 12 13 |
# File 'lib/micrograd/layer.rb', line 11 def call(xs) @neurons.map { |n| n.call(xs) } end |
#parameters ⇒ Object
15 |
# File 'lib/micrograd/layer.rb', line 15 def parameters = neurons.flat_map(&:parameters) |