Skip to content

← deep_learning package

Pooling

Perform an N-dimensional spatial pooling operation (average or max) on the given data.

This will sweep a window over the data, using the given strides as the step size (and respecting padding at the borders), and compute the average or max value within the window. The output size is the size of the grid of valid positions for the window (given padding and strides). If there were multiple feature axes in the input, they will be flattened into a single feature axis placed at the end. The full output shape is first the instance axes if any, then any unspecified non-feature dimensions, then the specified "spatial" (i.e., swept-over) dimensions in the order specified, followed by a single feature axis. Beware that there is a difference between the semantics of Keras and Haiku pooling: Keras pooling only applies to spatial dimensions, while Haiku pooling windows are specified in terms of all (non-batch) dimensions, including the channels axis. This node defaults to the Keras semantics, but allows you to perform Haiku-style pooling by specifying a window size that is greater than the number of spatial dimensions in the data. Also as in Keras, the default strides equals the window size, meaning that pooling is by default a downsampling operation if not strides are specified. Version 0.2.0

Ports/Properties

data

Data to process.

  • verbose name: Data
  • default value: None
  • port type: DataPort
  • value type: AnyNumeric (can be None)
  • data direction: INOUT

pool_axes

List and order of axes over which to pool adjacent values. If the input data are packets, this determines the order of these axes in the output data, and the order in which the size of the pooling window etc is given. Alternatively one may also give just an integer number of axes to pool over, in which case the last N axes in the data (that are neither feature nor instance) will be pooled over. If the input data are plain arrays and named axes are listed, this merely determines the number of spatial axes and the names are just mnemonic and not otherwise used. Conceptually, the pooling operation sweeps a window over the (with a step size given by the strides parameter), and for each position of the window, either the average or the maximum of the values is taken to produce a single number for each window position. The results are arranged in an array that has the same order of spatial dimensions, but which is (typically) smaller in each dimension by a factor depending on the step size. The window can either be limited to not run past the edges of the data (padding=valid), or it can be allowed to run past the edges of the data by half the window size, which results in an output size that is exactly the input size divided by the respective step sizes (padding=same). Note that this operation will not pool over feature axes, which will be arranged into a single feature axis at the end, but instead the pooling is applied separately for each feature. Likewise, the operation does not pool over instances, and any instance axes are arranged at the beginning. If plain array data is given, then the node needs to be told, using the feature_axis parameter, where the feature axis is assumed to be located (either at the end or before the spatial axes). This is automatic when packet data is provided. This parameter is not limited to the predefined options.

  • verbose name: Axes To Pool Over
  • default value: time
  • port type: ComboPort
  • value type: str (can be None)

pool_type

Type of pooling to perform. Either the maximum or the average of the values in the pooling window is taken. Both pooling operations have their uses, with max pooling being more suitable for detecting local features in a translation-invariant manner, and average pooling can be used as a lowpass filter on features.

  • verbose name: Pooling Type
  • default value: max
  • port type: EnumPort
  • value type: str (can be None)

window

Size of the pooling window. This is a list of integers, one for each dimension as given in pool axes. Can also be given as a single-element list, in which case the window is the same size along all of the given spatial dimensions. For pooling along a single dimension one may either just name the axis to pool over and give a single value for the window size, or one may list all spatial axes and describe the window size as in e.g., [1, 3, 1] to pool over the second axis. Which is more efficient depends on the implementation.

  • verbose name: Window Size
  • default value: [3]
  • port type: ListPort
  • value type: list (can be None)

strides

Step size with which the window is swept over the data. If not given, defaults to the same as the window size. This is a list of integers, one for each dimension as given in pool axes. Can also be given as a single-element list, in which case the same step size is used along all of the specified spatial dimensions. A step size greater than 1 means that the window will be shifted by this amount between successive positions; as a result, the output data along this axis will be shorter by this factor (matching the number of positions at which the window is applied).

  • verbose name: Step Size (Strides)
  • default value: None
  • port type: ListPort
  • value type: list (can be None)

padding

Padding strategy for the data. This can be either 'valid' or 'same'. 'valid' means no padding (i.e., the window will not run off the edges of the data, but the output data will be shortened along each axis according to the number of valid positions of the window along that axis), and 'same' means that the output will have the same shape as the input (aside from downsampling due to strides).

  • verbose name: Padding
  • default value: valid
  • port type: EnumPort
  • value type: str (can be None)

feature_axis

Dimension to exclude from pooling. This is typically the feature dimension (channels in traditional deep earning nomenclature), which is often the last axis but can be the axis just prior to the spatial dimensions. If data is provided in packet format, then this is automatically determined inferred from the data and should not be specified. If plain array data is given, this defaults to -1, meaning the last axis in the data. This is ignored if you provide a longer list for windows/strides than there are spatial dimensions in the data.

  • verbose name: Feature Axis
  • default value: None
  • port type: IntPort
  • value type: int (can be None)

set_breakpoint

Set a breakpoint on this node. If this is enabled, your debugger (if one is attached) will trigger a breakpoint.

  • verbose name: Set Breakpoint (Debug Only)
  • default value: False
  • port type: BoolPort
  • value type: bool (can be None)

metadata

User-definable meta-data associated with the node. Usually reserved for technical purposes.

  • verbose name: Metadata
  • default value: {}
  • port type: DictPort
  • value type: dict (can be None)