Class Convolution


  • public class Convolution
    extends Object
    • Method Detail

      • col2im

        public static INDArray col2im​(INDArray col,
                                      int[] stride,
                                      int[] padding,
                                      int height,
                                      int width)
        Parameters:
        col -
        stride -
        padding -
        height -
        width -
        Returns:
      • col2im

        public static INDArray col2im​(INDArray col,
                                      int sH,
                                      int sW,
                                      int ph,
                                      int pW,
                                      int kH,
                                      int kW)
        Rearrange matrix columns into blocks
        Parameters:
        col - the column transposed image to convert
        sH - stride height
        sW - stride width
        ph - padding height
        pW - padding width
        kH - height
        kW - width
        Returns:
      • col2im

        public static INDArray col2im​(INDArray col,
                                      INDArray z,
                                      int sH,
                                      int sW,
                                      int pH,
                                      int pW,
                                      int kH,
                                      int kW,
                                      int dH,
                                      int dW)
      • im2col

        public static INDArray im2col​(INDArray img,
                                      int[] kernel,
                                      int[] stride,
                                      int[] padding)
        Parameters:
        img -
        kernel -
        stride -
        padding -
        Returns:
      • im2col

        public static INDArray im2col​(INDArray img,
                                      int kh,
                                      int kw,
                                      int sy,
                                      int sx,
                                      int ph,
                                      int pw,
                                      boolean isSameMode)
        Implement column formatted images
        Parameters:
        img - the image to process
        kh - the kernel height
        kw - the kernel width
        sy - the stride along y
        sx - the stride along x
        ph - the padding width
        pw - the padding height
        isSameMode - whether to cover the whole image or not
        Returns:
        the column formatted image
      • im2col

        public static INDArray im2col​(INDArray img,
                                      int kh,
                                      int kw,
                                      int sy,
                                      int sx,
                                      int ph,
                                      int pw,
                                      int dh,
                                      int dw,
                                      boolean isSameMode)
      • im2col

        public static INDArray im2col​(INDArray img,
                                      int kh,
                                      int kw,
                                      int sy,
                                      int sx,
                                      int ph,
                                      int pw,
                                      boolean isSameMode,
                                      INDArray out)
      • im2col

        public static INDArray im2col​(INDArray img,
                                      int kh,
                                      int kw,
                                      int sy,
                                      int sx,
                                      int ph,
                                      int pw,
                                      int dH,
                                      int dW,
                                      boolean isSameMode,
                                      INDArray out)
        Execute im2col. Note the input must be NCHW.
        Parameters:
        img - the input image in NCHW
        kh -
        kw -
        sy -
        sx -
        ph -
        pw -
        dH -
        dW -
        isSameMode -
        out -
        Returns:
      • pooling2D

        public static INDArray pooling2D​(INDArray img,
                                         int kh,
                                         int kw,
                                         int sy,
                                         int sx,
                                         int ph,
                                         int pw,
                                         int dh,
                                         int dw,
                                         boolean isSameMode,
                                         Pooling2D.Pooling2DType type,
                                         Pooling2D.Divisor divisor,
                                         double extra,
                                         int virtualHeight,
                                         int virtualWidth,
                                         INDArray out)
        Pooling 2d implementation
        Parameters:
        img -
        kh -
        kw -
        sy -
        sx -
        ph -
        pw -
        dh -
        dw -
        isSameMode -
        type -
        extra - optional argument. I.e. used in pnorm pooling.
        virtualHeight -
        virtualWidth -
        out -
        Returns:
      • im2col

        public static INDArray im2col​(INDArray img,
                                      int kh,
                                      int kw,
                                      int sy,
                                      int sx,
                                      int ph,
                                      int pw,
                                      int pval,
                                      boolean isSameMode)
        Implement column formatted images
        Parameters:
        img - the image to process
        kh - the kernel height
        kw - the kernel width
        sy - the stride along y
        sx - the stride along x
        ph - the padding width
        pw - the padding height
        pval - the padding value (not used)
        isSameMode - whether padding mode is 'same'
        Returns:
        the column formatted image
      • outSize

        @Deprecated
        public static long outSize​(long size,
                                   long k,
                                   long s,
                                   long p,
                                   int dilation,
                                   boolean coverAll)
        Deprecated.
        The out size for a convolution
        Parameters:
        size -
        k -
        s -
        p -
        coverAll -
        Returns:
      • outputSize

        public static long outputSize​(long size,
                                      long k,
                                      long s,
                                      long p,
                                      int dilation,
                                      boolean isSameMode)
      • effectiveKernelSize

        public static long effectiveKernelSize​(long kernel,
                                               int dilation)
      • conv2d

        public static INDArray conv2d​(INDArray input,
                                      INDArray kernel,
                                      Convolution.Type type)
        2d convolution (aka the last 2 dimensions
        Parameters:
        input - the input to op
        kernel - the kernel to convolve with
        type -
        Returns:
      • convn

        public static INDArray convn​(INDArray input,
                                     INDArray kernel,
                                     Convolution.Type type,
                                     int[] axes)
        ND Convolution
        Parameters:
        input - the input to op
        kernel - the kerrnel to op with
        type - the opType of convolution
        axes - the axes to do the convolution along
        Returns:
        the convolution of the given input and kernel
      • convn

        public static INDArray convn​(INDArray input,
                                     INDArray kernel,
                                     Convolution.Type type)
        ND Convolution
        Parameters:
        input - the input to op
        kernel - the kernel to op with
        type - the opType of convolution
        Returns:
        the convolution of the given input and kernel