neupy.layers.MaxPooling

class neupy.layers.MaxPooling[source]

Maximum pooling layer.

Parameters:
size : tuple with 2 integers

Factor by which to downscale (vertical, horizontal). (2, 2) will halve the image in each dimension.

stride : tuple or int.

Stride size, which is the number of shifts over rows/cols to get the next pool region. If stride is None, it is considered equal to ds (no overlap on pooling regions).

padding : {valid, same}

(pad_h, pad_w), pad zeros to extend beyond four borders of the images, pad_h is the size of the top and bottom margins, and pad_w is the size of the left and right margins.

name : str or None

Layer’s identifier. If name is equal to None than name will be generated automatically. Defaults to None.

Examples

2D pooling

>>> from neupy import layers
>>>
>>> network = layers.join(
...     layers.Input((10, 10, 3)),
...     layers.MaxPooling((2, 2)),
... )
>>> network.output_shape
(3, 5, 5)

1D pooling

>>> from neupy import layers
>>>
>>> network = layers.join(
...     layers.Input((30, 10)),
...     layers.Reshape((10, 1, 30)),
...     layers.MaxPooling((2, 1)),
... )
>>> network.output_shape
(10, 15, 1)
Attributes:
input_shape : tuple

Returns layer’s input shape in the form of a tuple. Shape will not include batch size dimension.

output_shape : tuple

Returns layer’s output shape in the form of a tuple. Shape will not include batch size dimension.

training_state : bool

Defines whether layer in training state or not. Training state will enable some operations inside of the layers that won’t work otherwise.

parameters : dict

Parameters that networks uses during propagation. It might include trainable and non-trainable parameters.

graph : LayerGraph instance

Graphs that stores all relations between layers.

Methods

disable_training_state() Context manager that switches off trainig state.
initialize() Set up important configurations related to the layer.
options = {'name': Option(class_name='BaseLayer', value=Property(name="name")), 'padding': Option(class_name='BasePooling', value=ChoiceProperty(name="padding")), 'size': Option(class_name='BasePooling', value=TypedListProperty(name="size")), 'stride': Option(class_name='BasePooling', value=Spatial2DProperty(name="stride"))}[source]
pooling_type = 'MAX'[source]