Fork me on GitHub

src/arraymancer/nn/layers/maxpool2D

  Source Edit

Types

MaxPool2D[T] = object
  Source Edit
MaxPool2DGate[TT] {.final.} = ref object of Gate[TT]
  Source Edit

Procs

proc forward[T](self: MaxPool2D[T]; input: Variable[Tensor[T]]): Variable[
    Tensor[T]]
  Source Edit
proc init[T](ctx: Context[Tensor[T]]; layerType: typedesc[MaxPool2D[T]];
             inShape: seq[int]; kernelSize, padding, stride: Size2D): MaxPool2D[
    T]
Creates an 2d maxpool layer. Input:
- ``inShape`` Expected shape if input in the form of ``[C, H_in, W_in]``
- ``kernelSize`` Height and width of the pooling kernel.
- ``padding`` Size2D tuple with height and width of the padding
- ``stride`` Size2D tuple with height and width of the stride

Returns the created MaxPool2D.

  Source Edit
func inShape[T](self: MaxPool2D[T]): seq[int]
  Source Edit
proc maxpool2d[TT](input: Variable[TT]; kernel: Size2D;
                   padding: Size2D = (0, 0); stride: Size2D = (1, 1)): Variable[
    TT]
Input:
- ``input`` Variable wrapping a 4D Tensor shape [N,C,H_in,W_in]
- ``kernel`` Height (kH) and width (kW) of the pooling kernel.
- ``padding`` Size2D tuple with height and width of the padding
- ``stride`` Size2D tuple with height and width of the stride

Returns:

- A variable with a pooled 4D Tensor of shape [N,C,H_out,W_out], where
   H_out = (H_in + (2*padding.height) - kH) / stride.height + 1
   W_out = (W_in + (2*padding.width) - kW) / stride.width + 1

Warning âš :

  • Experimental, there is no tests yet for this layer
  Source Edit
func outShape[T](self: MaxPool2D[T]): seq[int]
  Source Edit
Arraymancer Technical reference Tutorial Spellbook (How-To's) Under the hood