Class: Qoa::Layers::ConvolutionalLayer

Inherits:
Layer
  • Object
show all
Defined in:
lib/qoa/layers/convolutional_layer.rb

Instance Attribute Summary collapse

Attributes inherited from Layer

#input_size, #output_size, #weights

Instance Method Summary collapse

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_sizeObject (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

#strideObject (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