Class: Qoa::Layers::Layer
- Inherits:
-
Object
- Object
- Qoa::Layers::Layer
- Defined in:
- lib/qoa/layers/layer.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#input_size ⇒ Object
readonly
Returns the value of attribute input_size.
-
#output_size ⇒ Object
readonly
Returns the value of attribute output_size.
-
#weights ⇒ Object
Returns the value of attribute weights.
Instance Method Summary collapse
-
#initialize(input_size, output_size) ⇒ Layer
constructor
A new instance of Layer.
- #random_matrix(rows, cols) ⇒ Object
Constructor Details
#initialize(input_size, output_size) ⇒ Layer
6 7 8 9 10 |
# File 'lib/qoa/layers/layer.rb', line 6 def initialize(input_size, output_size) @input_size = input_size @output_size = output_size @weights = random_matrix(output_size, input_size) end |
Instance Attribute Details
#input_size ⇒ Object (readonly)
Returns the value of attribute input_size.
4 5 6 |
# File 'lib/qoa/layers/layer.rb', line 4 def input_size @input_size end |
#output_size ⇒ Object (readonly)
Returns the value of attribute output_size.
4 5 6 |
# File 'lib/qoa/layers/layer.rb', line 4 def output_size @output_size end |
#weights ⇒ Object
Returns the value of attribute weights.
4 5 6 |
# File 'lib/qoa/layers/layer.rb', line 4 def weights @weights end |
Instance Method Details
#random_matrix(rows, cols) ⇒ Object
12 13 14 15 |
# File 'lib/qoa/layers/layer.rb', line 12 def random_matrix(rows, cols) limit = Math.sqrt(6.0 / (rows + cols)) Array.new(rows) { Array.new(cols) { rand(-limit..limit) } } end |