Convolution and pooling

Convolution and pooling.

class penne.conv.convolve(x, y, mode='full')[source]

Discrete convolution.

Same as scipy.signal.convolve (n-dimensional) if available; otherwise, same as numpy.convolve (1-dimensional).

class penne.conv.pool(a, blockshape)[source]

Tile an array into nonoverlapping blocks and return an array of the blocks.

If blockshape is (a, b, ...), returns result, where

result[I, i, J, j, ...] = a[I*a+i, J*b+j, ...]

If blockshape has fewer axes than a does, they are right-aligned.

Parameters:
  • a (Expression) – array to be tiled.
  • blockshape (tuple of ints) – shape of the blocks.
penne.conv.max_pool(a, blockshape)[source]

Tile an array into nonoverlapping blocks and return the maximum value of each block.

If blockshape has fewer axes than a does, they are right-aligned.

Parameters:
  • a (Expression) – array to be tiled.
  • blockshape (tuple of ints) – shape of the blocks.
penne.conv.mean_pool(a, blockshape)[source]

Tile an array into nonoverlapping blocks and return the mean value of each block.

If blockshape has fewer axes than a does, they are right-aligned.

Parameters:
  • a (Expression) – array to be tiled.
  • blockshape (tuple of ints) – shape of the blocks.