Class Convolution1DUtils


  • public class Convolution1DUtils
    extends Object
    • Method Detail

      • getOutputSize

        public static int getOutputSize​(INDArray inputData,
                                        int kernel,
                                        int strides,
                                        int padding,
                                        ConvolutionMode convolutionMode)
      • getRnnFormatFromLayer

        public static RNNFormat getRnnFormatFromLayer​(Layer layer)
        Get the RNNFormat for the given layer. Throws an IllegalArgumentException if a layer doesn't have an rnn format
        Parameters:
        layer - the layer to get the format for
        Returns:
        the format for the layer
      • reshapeWeightArrayOrGradientForFormat

        public static INDArray reshapeWeightArrayOrGradientForFormat​(INDArray w,
                                                                     RNNFormat rnnFormat)
        Reshapes the given weight array or weight gradient to work with the specified RNNFormat
        Parameters:
        w - the weight array or gradient
        rnnFormat - the RNNFormat to use
        Returns:
        the reshaped array.
      • getOutputSize

        public static long getOutputSize​(long inH,
                                         int kernel,
                                         int strides,
                                         int padding,
                                         ConvolutionMode convolutionMode,
                                         int dilation)
        Get the output size (height) for the given input data and CNN1D configuration
        Parameters:
        inH - Input size (height, or channels).
        kernel - Kernel size
        strides - Stride
        padding - Padding
        convolutionMode - Convolution mode (Same, Strict, Truncate)
        dilation - Kernel dilation
        Returns:
        Output size (width)
      • getOutputSize

        public static int getOutputSize​(INDArray inputData,
                                        int kernel,
                                        int strides,
                                        int padding,
                                        ConvolutionMode convolutionMode,
                                        int dilation)
        Get the output size (height) for the given input data and CNN1D configuration
        Parameters:
        inputData - Input data
        kernel - Kernel size
        strides - Stride
        padding - Padding
        convolutionMode - Convolution mode (Same, Strict, Truncate)
        dilation - Kernel dilation
        Returns:
        Output size (width)
      • validateShapes

        public static void validateShapes​(INDArray inputData,
                                          int eKernel,
                                          int strides,
                                          int padding,
                                          ConvolutionMode convolutionMode,
                                          int dilation,
                                          int inShape,
                                          boolean atrous)
      • effectiveKernelSize

        public static int effectiveKernelSize​(int kernel,
                                              int dilation)
      • validateConvolutionModePadding

        public static void validateConvolutionModePadding​(ConvolutionMode mode,
                                                          int padding)
        Check that the convolution mode is consistent with the padding specification
      • getSameModeTopLeftPadding

        public static int getSameModeTopLeftPadding​(int outSize,
                                                    int inSize,
                                                    int kernel,
                                                    int strides,
                                                    int dilation)
        Get top padding for same mode only.
        Parameters:
        outSize - Output size (length 2 array, height dimension first)
        inSize - Input size (length 2 array, height dimension first)
        kernel - Kernel size (length 2 array, height dimension first)
        strides - Strides (length 2 array, height dimension first)
        dilation - Dilation (length 2 array, height dimension first)
        Returns:
        Top left padding (length 2 array, height dimension first)
      • getSameModeBottomRightPadding

        public static int getSameModeBottomRightPadding​(int outSize,
                                                        int inSize,
                                                        int kernel,
                                                        int strides,
                                                        int dilation)
      • validateCnn1DKernelStridePadding

        public static void validateCnn1DKernelStridePadding​(int kernel,
                                                            int stride,
                                                            int padding)
        Perform validation on the CNN layer kernel/stride/padding. Expect int, with values > 0 for kernel size and stride, and values >= 0 for padding.
        Parameters:
        kernel - Kernel size to check
        stride - Stride to check
        padding - Padding to check