Pooling Layers

class npdl.layers.MeanPooling(pool_size)[source][source]

Average pooling operation for spatial data.

Parameters:
pool_size : tuple of 2 integers,

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

Returns:
4D numpy.array

with shape (nb_samples, channels, pooled_rows, pooled_cols) if dim_ordering=’th’ or 4D tensor with shape: (samples, pooled_rows, pooled_cols, channels) if dim_ordering=’tf’.

backward(pre_grad, *args, **kwargs)[source][source]

calculate the input gradient

connect_to(prev_layer)[source][source]

Propagates the given input through this layer (and only this layer).

Parameters:
prev_layer : previous layer

The previous layer to propagate through this layer.

forward(input, *args, **kwargs)[source][source]

Calculate layer output for given input (forward propagation).

class npdl.layers.MaxPooling(pool_size)[source][source]

Max pooling operation for spatial data.

Parameters:
pool_size : tuple of 2 integers,

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

Returns:
4D numpy.array

with shape (nb_samples, channels, pooled_rows, pooled_cols) if dim_ordering=’th’ or 4D tensor with shape: (samples, pooled_rows, pooled_cols, channels) if dim_ordering=’tf’.

backward(pre_grad, *args, **kwargs)[source][source]

calculate the input gradient

connect_to(prev_layer)[source][source]

Propagates the given input through this layer (and only this layer).

Parameters:
prev_layer : previous layer

The previous layer to propagate through this layer.

forward(input, *args, **kwargs)[source][source]

Calculate layer output for given input (forward propagation).