Class: Qoa::Layers::ConvolutionalLayer
- Defined in:
- lib/qoa/layers/convolutional_layer.rb
Instance Attribute Summary collapse
-
#kernel_size ⇒ Object
readonly
Returns the value of attribute kernel_size.
-
#stride ⇒ Object
readonly
Returns the value of attribute stride.
Attributes inherited from Layer
#input_size, #output_size, #weights
Instance Method Summary collapse
-
#initialize(input_size, output_size, kernel_size, stride = 1) ⇒ ConvolutionalLayer
constructor
A new instance of ConvolutionalLayer.
- #random_matrix(rows, cols) ⇒ Object
Constructor Details
#initialize(input_size, output_size, kernel_size, stride = 1) ⇒ ConvolutionalLayer
Returns a new instance of ConvolutionalLayer.
6 7 8 9 10 |
# File 'lib/qoa/layers/convolutional_layer.rb', line 6 def initialize(input_size, output_size, kernel_size, stride = 1) super(input_size, output_size) @kernel_size = kernel_size @stride = stride end |
Instance Attribute Details
#kernel_size ⇒ Object (readonly)
Returns the value of attribute kernel_size.
4 5 6 |
# File 'lib/qoa/layers/convolutional_layer.rb', line 4 def kernel_size @kernel_size end |
#stride ⇒ Object (readonly)
Returns the value of attribute stride.
4 5 6 |
# File 'lib/qoa/layers/convolutional_layer.rb', line 4 def stride @stride end |
Instance Method Details
#random_matrix(rows, cols) ⇒ Object
12 13 14 15 |
# File 'lib/qoa/layers/convolutional_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 |