Pooling

USAGE

All functions can be imported using layers module

2D Layers

max_pooling2d(input_data, rf=(2, 2), strides=(2, 2), act_fn=<function lrelu>, kernel_initializer=None, bias_initializer=None, weight_decay=None, padding='VALID', data_format='NHWC', reuse=False, log=False, name='max_pooling_2d_layer')[source]

Executes Pyranet modified Max Pooling 2D on the input. It uses the 3D Max Pooling to perform the computation extending the 2D input dimension in order to match the requirements of 3D layer (the new dimension doesn’t influence results, it can be considered like a placeholder)

Parameters:
  • input_data (List[int]) – A 4D tensor with dimensions [batch_size, in_height, in_width, channels]
  • rf (Union[int, Tuple(int, int)]) – Receptive field (filter mask) size, can be an integer (same size will be used on all dimensions) or a tuple indicating (height, width)
  • strides (Union[int, Tuple(int, int)]) – Sliding step, can be an integer (same step will be used on all dimensions) or a tuple indicating (height, width)
  • act_fn – A valid activation function handler. Default is provided leaky_relu
  • kernel_initializer – Initializer used for kernel weights, default None (uses Xavier initializer)
  • bias_initializer – Initializer used for bias, default None (uses Xavier initializer)
  • weight_decay – L2 decay lambda value.
  • padding (str) – Type of padding, only VALID is supported.
  • data_format (str) – NHWC : Batch x Height x Width x Channels
  • log (bool) – Log networks structure (weights, bias and output)
  • reuse (bool) – Not used.
  • name (str) – Layer name, used in variable_scope
Returns:

Max pooled 2D tensor with output of size [batch_size, out_height, out_width, channels]

avg_pooling2d(input_data, rf=(2, 2), strides=(2, 2), act_fn=<function lrelu>, kernel_initializer=None, bias_initializer=None, weight_decay=None, padding='VALID', data_format='NHWC', reuse=False, log=False, name='max_pooling_2d_layer')[source]

Executes Pyranet modified Average Pooling 2D on the input. It uses the 3D Average Pooling to perform the computation extending the 2D input dimension in order to match the requirements of 3D layer (the new dimension doesn’t influence results, it can be considered like a placeholder)

Parameters:
  • input_data (List[int]) – A 4D tensor with dimensions [batch_size, in_height, in_width, channels]
  • rf (Union[int, Tuple(int, int)]) – Receptive field (filter mask) size, can be an integer (same size will be used on all dimensions) or a tuple indicating (height, width)
  • strides (Union[int, Tuple(int, int)]) – Sliding step, can be an integer (same step will be used on all dimensions) or a tuple indicating (height, width)
  • act_fn – A valid activation function handler. Default is provided leaky_relu
  • kernel_initializer – Initializer used for kernel weights, default None (uses Xavier initializer)
  • bias_initializer – Initializer used for bias, default None (uses Xavier initializer)
  • weight_decay – L2 decay lambda value.
  • padding (str) – Type of padding, only VALID is supported.
  • data_format (str) – NHWC : Batch x Height x Width x Channels
  • log (bool) – Log networks structure (weights, bias and output)
  • reuse (bool) – Not used.
  • name (str) – Layer name, used in variable_scope
Returns:

Max pooled 2D tensor with output of size [batch_size, out_height, out_width, channels]

3D Layers

max_pooling3d(input_data, rf=(3, 2, 2), strides=(1, 1, 2, 2, 1), act_fn=<function lrelu>, kernel_initializer=None, bias_initializer=None, weight_decay=None, padding='VALID', data_format='NDHWC', reuse=False, log=False, name='max_pooling_3d_layer')[source]

Executes Pyranet modified Max Pooling 3D on the input.

Parameters:
  • input_data (List[int]) – A 5D tensor with dimensions [batch_size, in_depth, in_height, in_width, channels]
  • rf (Union[int, Tuple(int, int, int)]) – Receptive field (filter mask) size, can be an integer (same size will be used on all dimensions) or a tuple indicating (depth, height, width)
  • strides (Union[int, Tuple(int, int, int)]) – Sliding step, can be an integer (same step will be used on all dimensions) or a tuple indicating (depth, height, width)
  • act_fn – A valid activation function handler. Default is provided leaky_relu
  • kernel_initializer – Initializer used for kernel weights, default None (uses Xavier initializer)
  • bias_initializer – Initializer used for bias, default None (uses Xavier initializer)
  • weight_decay – L2 decay lambda value.
  • padding (str) – Type of padding, only VALID is supported.
  • data_format (str) – NDHWC : Batch x Depth x Height x Width x Channels
  • log (bool) – Log networks structure (weights, bias and output)
  • reuse (bool) – Not used.
  • name (str) – Layer name, used in variable_scope
Returns:

Max pooled 3D tensor with output of size [batch_size, out_depth, out_height, out_width, channels]

avg_pooling3d(input_data, rf=(3, 2, 2), strides=(1, 1, 2, 2, 1), act_fn=<function lrelu>, kernel_initializer=None, bias_initializer=None, weight_decay=None, padding='VALID', data_format='NDHWC', reuse=False, log=False, name='max_pooling_3d_layer')[source]

Executes Pyranet modified Average Pooling 3D on the input.

Parameters:
  • input_data (List[int]) – A 5D tensor with dimensions [batch_size, in_depth, in_height, in_width, channels]
  • rf (Union[int, Tuple(int, int, int)]) – Receptive field (filter mask) size, can be an integer (same size will be used on all dimensions) or a tuple indicating (depth, height, width)
  • strides (Union[int, Tuple(int, int, int)]) – Sliding step, can be an integer (same step will be used on all dimensions) or a tuple indicating (depth, height, width)
  • act_fn – A valid activation function handler. Default is provided leaky_relu
  • kernel_initializer – Initializer used for kernel weights, default None (uses Xavier initializer)
  • bias_initializer – Initializer used for bias, default None (uses Xavier initializer)
  • weight_decay – L2 decay lambda value.
  • padding (str) – Type of padding, only VALID is supported.
  • data_format (str) – NDHWC : Batch x Depth x Height x Width x Channels
  • log (bool) – Log networks structure (weights, bias and output)
  • reuse (bool) – Not used.
  • name (str) – Layer name, used in variable_scope
Returns:

Average pooled 3D tensor with output of size [batch_size, out_depth, out_height, out_width, channels]