VL_NNPOOL - CNN poolinng.

Y = VL_NNPOOL(X, POOL) applies the pooling operator to all channels of the data X using a square filter of size POOL. X is a SINGLE array of dimension H x W x D x N where (H,W) are the height and width of the map stack, D is the image depth (number of feature channels) and N the number of of images in the stack.

Y = VL_NNPOOL(X, [POOLY, POOLX]) uses a rectangular filter of height POOLY and width POOLX.

DZDX = VL_NNPOOL(X, POOL, DZDY) computes the derivatives of the block projected onto DZDY. DZDX and DZDY have the same dimensions as X and Y respectively.

VL_NNPOOL(..., 'option', value, ...) takes the following options:

• Stride [1]

The output stride (downsampling factor). It can be either a scalar for isotropic downsampling or a vector [STRIDEY STRIDEX].

• Pad [0]

The amount of input padding. Input images are padded with zeros by this number of pixels on all sides before the convolution is computed. It can also be a vector [TOP BOTTOM LEFT RIGHT] to specify a different amount of padding in each direction. The size of the pooling filter has to exceed the padding.

• Method ['max']

Specify method of pooling. It can be either 'max' (retain max value over the pooling region per channel) or 'avg' (compute the average value over the pooling region per channel).

The pooling window must be not larger than the padded image, i.e.

  1 <= POOLY <= HEIGHT + (PADTOP + PADBOTTOM),

  YH = floor((H + (PADTOP+PADBOTTOM) - POOLY)/STRIDEY) + 1,