MCPcopy Create free account
hub / github.com/ddbourgin/numpy-ml / __init__

Method __init__

numpy_ml/neural_nets/layers/layers.py:3182–3211  ·  view source on GitHub ↗

A single two-dimensional pooling layer. Parameters ---------- kernel_shape : 2-tuple The dimension of a single 2D filter/kernel in the current layer stride : int The stride/hop of the convolution kernels as they move over the

(self, kernel_shape, stride=1, pad=0, mode="max", optimizer=None)

Source from the content-addressed store, hash-verified

3180
3181class Pool2D(LayerBase):
3182 def __init__(self, kernel_shape, stride=1, pad=0, mode="max", optimizer=None):
3183 """
3184 A single two-dimensional pooling layer.
3185
3186 Parameters
3187 ----------
3188 kernel_shape : 2-tuple
3189 The dimension of a single 2D filter/kernel in the current layer
3190 stride : int
3191 The stride/hop of the convolution kernels as they move over the
3192 input volume. Default is 1.
3193 pad : int, tuple, or 'same'
3194 The number of rows/columns of 0's to pad the input. Default is 0.
3195 mode : {"max", "average"}
3196 The pooling function to apply.
3197 optimizer : str, :doc:`Optimizer <numpy_ml.neural_nets.optimizers>` object, or None
3198 The optimization strategy to use when performing gradient updates
3199 within the :meth:`update` method. If None, use the :class:`SGD
3200 <numpy_ml.neural_nets.optimizers.SGD>` optimizer with
3201 default parameters. Default is None.
3202 """ # noqa: E501
3203 super().__init__(optimizer)
3204
3205 self.pad = pad
3206 self.mode = mode
3207 self.in_ch = None
3208 self.out_ch = None
3209 self.stride = stride
3210 self.kernel_shape = kernel_shape
3211 self.is_initialized = False
3212
3213 def _init_params(self):
3214 self.derived_variables = {"out_rows": [], "out_cols": []}

Callers

nothing calls this directly

Calls 1

__init__Method · 0.45

Tested by

no test coverage detected