Class: DNN::Layers::GlobalAvgPool2D

Inherits:
Layer
  • Object
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

Constructor Details

This class inherits a constructor from DNN::Layers::Layer

Instance Method Details

#build(input_shape) ⇒ Object



396
397
398
399
400
401
# File 'lib/dnn/core/layers/cnn_layers.rb', line 396

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
end

#forward(x) ⇒ Object



403
404
405
# File 'lib/dnn/core/layers/cnn_layers.rb', line 403

def forward(x)
  Flatten.(AvgPool2D.(x, input_shape[0..1]))
end