Class LibMatrixDNN


  • public class LibMatrixDNN
    extends Object
    • Constructor Detail

      • LibMatrixDNN

        public LibMatrixDNN()
    • Method Detail

      • conv2d

        public static void conv2d​(MatrixBlock input,
                                  MatrixBlock filter,
                                  MatrixBlock outputBlock,
                                  DnnParameters params)
        This method performs convolution (i.e. cross-correlation) operation on input
        Parameters:
        input - input batch
        filter - filter
        outputBlock - output of convolution
        params - convolution parameters
      • conv2dBackwardData

        public static void conv2dBackwardData​(MatrixBlock filter,
                                              MatrixBlock dout,
                                              MatrixBlock outputBlock,
                                              DnnParameters params)
        This method computes the backpropogation errors for previous layer of convolution operation
        Parameters:
        filter - filter used in conv2d
        dout - errors from next layer
        outputBlock - output errors
        params - convolution parameters
      • conv2dBackwardFilter

        public static void conv2dBackwardFilter​(MatrixBlock input,
                                                MatrixBlock dout,
                                                MatrixBlock outputBlock,
                                                DnnParameters params)
        This method computes the backpropogation errors for filter of convolution operation
        Parameters:
        input - input image
        dout - errors from next layer
        outputBlock - output errors
        params - convolution parameters
      • poolingBackward

        public static void poolingBackward​(MatrixBlock input,
                                           MatrixBlock dout,
                                           MatrixBlock outputBlock,
                                           DnnParameters params,
                                           boolean performReluBackward,
                                           LibMatrixDNN.PoolingType poolType)
        This method computes the backpropogation errors for previous layer of pooling operation
        Parameters:
        input - input matrix
        dout - dout matrix
        outputBlock - output matrix
        params - convolution parameters
        performReluBackward - perform ReLU backward
        poolType - type of pooling
      • reluBackward

        public static void reluBackward​(MatrixBlock input,
                                        MatrixBlock dout,
                                        MatrixBlock outputBlock,
                                        int numThreads)
        This method computes the backpropagation errors for previous layer of relu operation
        Parameters:
        input - input matrix
        dout - errors from next layer
        outputBlock - output matrix
        numThreads - number of threads
      • biasAdd

        public static void biasAdd​(MatrixBlock input,
                                   MatrixBlock bias,
                                   MatrixBlock outputBlock,
                                   int numThreads)
        Performs the operation corresponding to the DML script: ones = matrix(1, rows=1, cols=Hout*Wout) output = input + matrix(bias %*% ones, rows=1, cols=F*Hout*Wout) This operation is often followed by conv2d and hence we have introduced bias_add(input, bias) built-in function
        Parameters:
        input - input matrix
        bias - bias matrix
        outputBlock - output matrix
        numThreads - number of threads
      • channelSums

        public static void channelSums​(MatrixBlock input,
                                       MatrixBlock outputBlock,
                                       int C,
                                       int HW)
        Perform channel sum operation
        Parameters:
        input - input matrix block
        outputBlock - output matrix block
        C - number of channels
        HW - height X width
      • addBias

        public static void addBias​(double[] a,
                                   double[] bias,
                                   double biasMultiplier,
                                   int N,
                                   int K,
                                   int PQ)
      • multBias

        public static void multBias​(double[] a,
                                    double[] bias,
                                    int N,
                                    int K,
                                    int PQ)
      • biasMultiply

        public static void biasMultiply​(MatrixBlock input,
                                        MatrixBlock bias,
                                        MatrixBlock outputBlock,
                                        int numThreads)
        Performs the operation corresponding to the DML script: ones = matrix(1, rows=1, cols=Hout*Wout) output = input * matrix(bias %*% ones, rows=1, cols=F*Hout*Wout) This operation is often followed by conv2d and hence we have introduced bias_multiply(input, bias) built-in function
        Parameters:
        input - input matrix
        bias - bias matrix
        outputBlock - output matrix
        numThreads - number of threads