Class: Chainer::Functions::Pooling::AveragePooling2D
- Inherits:
-
Pooling2D
- Object
- Chainer::FunctionNode
- Pooling2D
- Chainer::Functions::Pooling::AveragePooling2D
- Defined in:
- lib/chainer/functions/pooling/average_pooling_2d.rb
Instance Attribute Summary collapse
-
#in_dtype ⇒ Object
readonly
Returns the value of attribute in_dtype.
-
#in_shape ⇒ Object
readonly
Returns the value of attribute in_shape.
Attributes inherited from Pooling2D
#cover_all, #kh, #kw, #ph, #pw, #sx, #sy
Attributes inherited from Chainer::FunctionNode
Class Method Summary collapse
-
.average_pooling_2d(x, ksize, stride: nil, pad: 0) ⇒ Chainer::Variable
Spatial average pooling function.
Instance Method Summary collapse
- #backward(indexes, gy) ⇒ Object
-
#forward(x) ⇒ Object
Average pooling over a set of 2d planes.
Methods inherited from Pooling2D
Methods inherited from Chainer::FunctionNode
#apply, #backward_accumulate, #forward_cpu, #get_retained_inputs, #get_retained_outputs, #initialize, #label, #output_data, #retain_inputs, #retain_outputs, #unchain
Constructor Details
This class inherits a constructor from Chainer::Functions::Pooling::Pooling2D
Instance Attribute Details
#in_dtype ⇒ Object (readonly)
Returns the value of attribute in_dtype.
5 6 7 |
# File 'lib/chainer/functions/pooling/average_pooling_2d.rb', line 5 def in_dtype @in_dtype end |
#in_shape ⇒ Object (readonly)
Returns the value of attribute in_shape.
5 6 7 |
# File 'lib/chainer/functions/pooling/average_pooling_2d.rb', line 5 def in_shape @in_shape end |
Class Method Details
.average_pooling_2d(x, ksize, stride: nil, pad: 0) ⇒ Chainer::Variable
Spatial average pooling function.
This function acts similarly to :class:‘Convolution2D`, but it computes the average of input spatial patch for each channel without any parameter instead of computing the inner products.
18 19 20 |
# File 'lib/chainer/functions/pooling/average_pooling_2d.rb', line 18 def self.average_pooling_2d(x, ksize, stride: nil, pad: 0) self.new(ksize, stride: stride, pad: pad, cover_all: false).apply([x])[0] end |
Instance Method Details
#backward(indexes, gy) ⇒ Object
33 34 35 |
# File 'lib/chainer/functions/pooling/average_pooling_2d.rb', line 33 def backward(indexes, gy) AveragePooling2DGrad.new(self).apply(gy) end |
#forward(x) ⇒ Object
Average pooling over a set of 2d planes.
23 24 25 26 27 28 29 30 31 |
# File 'lib/chainer/functions/pooling/average_pooling_2d.rb', line 23 def forward(x) @in_shape = x[0].shape @in_dtype = x[0].class col = Chainer::Utils::Conv.im2col(x[0], @kh, @kw, @sy, @sx, @ph, @pw) y = col.mean(axis: [2, 3]) [y] end |