Class: DNN::Layers::GlobalAvgPool2D
- Inherits:
-
Layer
- Object
- Layer
- DNN::Layers::GlobalAvgPool2D
show all
- Defined in:
- lib/dnn/core/layers/cnn_layers.rb
Instance Attribute Summary
Attributes inherited from Layer
#input_shape
Instance Method Summary
collapse
Methods inherited from Layer
#built?, call, #call, #clean, from_hash, #initialize, #load_hash, #output_shape, #to_hash
Instance Method Details
#backward(dy) ⇒ Object
405
406
407
408
|
# File 'lib/dnn/core/layers/cnn_layers.rb', line 405
def backward(dy)
dy = @flatten.backward(dy)
@avg_pool2d.backward(dy)
end
|
#build(input_shape) ⇒ Object
389
390
391
392
393
394
395
396
397
398
|
# File 'lib/dnn/core/layers/cnn_layers.rb', line 389
def build(input_shape)
unless input_shape.length == 3
raise DNN_ShapeError, "Input shape is #{input_shape}. But input shape must be 3 dimensional."
end
super
@avg_pool2d = AvgPool2D.new(input_shape[0..1])
@avg_pool2d.build(input_shape)
@flatten = Flatten.new
@flatten.build([1, 1, input_shape[2]])
end
|
#forward(x) ⇒ Object
400
401
402
403
|
# File 'lib/dnn/core/layers/cnn_layers.rb', line 400
def forward(x)
y = @avg_pool2d.forward(x)
@flatten.forward(y)
end
|