Pooling layers

class lasagne.layers.MaxPool1DLayer(incoming, pool_size, stride=None, pad=0, ignore_border=True, **kwargs)[source]

1D max-pooling layer

Performs 1D max-pooling over the trailing axis of a 3D input tensor.

Parameters:

incoming : a Layer instance or tuple

The layer feeding into this layer, or the expected input shape.

pool_size : integer or iterable

The length of the pooling region. If an iterable, it should have a single element.

stride : integer, iterable or None

The stride between sucessive pooling regions. If None then stride == pool_size.

pad : integer or iterable

The number of elements to be added to the input on each side. Must be less than stride.

ignore_border : bool

If True, partial pooling regions will be ignored. Must be True if pad != 0.

**kwargs

Any additional keyword arguments are passed to the Layer superclass.

Notes

The value used to pad the input is chosen to be less than the minimum of the input, so that the output of each pooling region always corresponds to some element in the unpadded input region.

Using ignore_border=False prevents Theano from using cuDNN for the operation, so it will fall back to a slower implementation.

class lasagne.layers.MaxPool2DLayer(incoming, pool_size, stride=None, pad=(0, 0), ignore_border=True, **kwargs)[source]

2D max-pooling layer

Performs 2D max-pooling over the two trailing axes of a 4D input tensor.

Parameters:

incoming : a Layer instance or tuple

The layer feeding into this layer, or the expected input shape.

pool_size : integer or iterable

The length of the pooling region in each dimension. If an integer, it is promoted to a square pooling region. If an iterable, it should have two elements.

stride : integer, iterable or None

The strides between sucessive pooling regions in each dimension. If None then stride = pool_size.

pad : integer or iterable

Number of elements to be added on each side of the input in each dimension. Each value must be less than the corresponding stride.

ignore_border : bool

If True, partial pooling regions will be ignored. Must be True if pad != (0, 0).

**kwargs

Any additional keyword arguments are passed to the Layer superclass.

Notes

The value used to pad the input is chosen to be less than the minimum of the input, so that the output of each pooling region always corresponds to some element in the unpadded input region.

Using ignore_border=False prevents Theano from using cuDNN for the operation, so it will fall back to a slower implementation.

class lasagne.layers.Pool2DLayer(incoming, pool_size, stride=None, pad=(0, 0), ignore_border=True, mode='max', **kwargs)[source]

2D pooling layer

Performs 2D mean or max-pooling over the two trailing axes of a 4D input tensor.

Parameters:

incoming : a Layer instance or tuple

The layer feeding into this layer, or the expected input shape.

pool_size : integer or iterable

The length of the pooling region in each dimension. If an integer, it is promoted to a square pooling region. If an iterable, it should have two elements.

stride : integer, iterable or None

The strides between sucessive pooling regions in each dimension. If None then stride = pool_size.

pad : integer or iterable

Number of elements to be added on each side of the input in each dimension. Each value must be less than the corresponding stride.

ignore_border : bool

If True, partial pooling regions will be ignored. Must be True if pad != (0, 0).

mode : {‘max’, ‘average_inc_pad’, ‘average_exc_pad’}

Pooling mode: max-pooling or mean-pooling including/excluding zeros from partially padded pooling regions. Default is ‘max’.

**kwargs

Any additional keyword arguments are passed to the Layer superclass.

See also

MaxPool2DLayer
Shortcut for max pooling layer.

Notes

The value used to pad the input is chosen to be less than the minimum of the input, so that the output of each pooling region always corresponds to some element in the unpadded input region.

Using ignore_border=False prevents Theano from using cuDNN for the operation, so it will fall back to a slower implementation.

class lasagne.layers.GlobalPoolLayer(incoming, pool_function=theano.tensor.mean, **kwargs)[source]

Global pooling layer

This layer pools globally across all trailing dimensions beyond the 2nd.

Parameters:

incoming : a Layer instance or tuple

The layer feeding into this layer, or the expected input shape.

pool_function : callable

the pooling function to use. This defaults to theano.tensor.mean (i.e. mean-pooling) and can be replaced by any other aggregation function.

**kwargs

Any additional keyword arguments are passed to the Layer superclass.

class lasagne.layers.FeaturePoolLayer(incoming, pool_size, axis=1, pool_function=theano.tensor.max, **kwargs)[source]

Feature pooling layer

This layer pools across a given axis of the input. By default this is axis 1, which corresponds to the feature axis for DenseLayer, Conv1DLayer and Conv2DLayer. The layer can be used to implement maxout.

Parameters:

incoming : a Layer instance or tuple

The layer feeding into this layer, or the expected input shape.

pool_size : integer

the size of the pooling regions, i.e. the number of features / feature maps to be pooled together.

axis : integer

the axis along which to pool. The default value of 1 works for DenseLayer, Conv1DLayer and Conv2DLayer.

pool_function : callable

the pooling function to use. This defaults to theano.tensor.max (i.e. max-pooling) and can be replaced by any other aggregation function.

**kwargs

Any additional keyword arguments are passed to the Layer superclass.

Notes

This layer requires that the size of the axis along which it pools is a multiple of the pool size.

class lasagne.layers.FeatureWTALayer(incoming, pool_size, axis=1, **kwargs)[source]

‘Winner Take All’ layer

This layer performs ‘Winner Take All’ (WTA) across feature maps: zero out all but the maximal activation value within a region.

Parameters:

incoming : a Layer instance or tuple

The layer feeding into this layer, or the expected input shape.

pool_size : integer

the number of feature maps per region.

axis : integer

the axis along which the regions are formed.

**kwargs

Any additional keyword arguments are passed to the Layer superclass.

Notes

This layer requires that the size of the axis along which it groups units is a multiple of the pool size.