class Chainer::Functions::Pooling::AveragePooling2D
Attributes
in_dtype[R]
in_shape[R]
Public Class Methods
average_pooling_2d(x, ksize, stride: nil, pad: 0)
click to toggle source
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. @param [Chainer::Variable] x Input variable. @param [integer] ksize Size of pooling window. `ksize=k` and `ksize=[k, k]` are equivalent. @param [integer] stride Stride of pooling applications. `stride=s` and `stride=[s, s]` are equivalent.
If `nil` is specified, then it uses same stride as the pooling window size.
@param [integer] pad Spatial padding width for the input array. `pad=p` and `pad=[p, p]` are equivalent. @return [Chainer::Variable] Output variable
# 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
Public Instance Methods
backward(indexes, gy)
click to toggle source
# File lib/chainer/functions/pooling/average_pooling_2d.rb, line 33 def backward(indexes, gy) AveragePooling2DGrad.new(self).apply(gy) end
forward(x)
click to toggle source
Average pooling over a set of 2d planes.
# 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