src/core/optimization/ResilientPropagation.java
public void optimize(Matrix matrix, Matrix matrixGradient) throws MatrixException, DynamicParamException {
        if (dPrev == null) dPrev = new HashMap<>();
        if (wPrev == null) wPrev = new HashMap<>();

        Matrix dMPrev;
        if (dPrev.containsKey(matrix)) dMPrev = dPrev.get(matrix);
        else dPrev.put(matrix, dMPrev = matrixGradient);

        Matrix WPrev;
        if (wPrev.containsKey(matrix)) WPrev = wPrev.get(matrix);
        else wPrev.put(matrix, WPrev = new DMatrix(matrix.getRows(), matrix.getColumns()));

        Matrix dWDir = dMPrev.sgnmul(matrixGradient);

        Matrix.MatrixBinaryOperation rpropRule = (value1, value2) -> value1 == -1 ? Math.max(0.5 * value2, 10E-6) : value1 == 1 ? Math.min(1.2 * value2, 50) : value2;
        wPrev.put(matrix, WPrev = dWDir.applyBi(WPrev, rpropRule));

        matrix.subtract(matrixGradient.apply(UnaryFunctionType.SGN).multiply(WPrev), matrix);

        dPrev.put(matrix, dWDir.applyBi(matrixGradient, (value1, value2) -> value1 == -1 ? 0 : value2));
    }
/**
     * Optimizes single matrix (M) using calculated matrix gradient (dM).<br>
     * Matrix can be for example weight or bias matrix with gradient.<br>
     *
     * @param matrix matrix to be optimized.
     * @param matrixGradient matrix gradients for optimization step.
     * @throws MatrixException throws exception if matrix operation fails.
     * @throws DynamicParamException throws exception if parameter (params) setting fails.
     */
Optimizes single matrix (M) using calculated matrix gradient (dM).
Matrix can be for example weight or bias matrix with gradient.

@param matrix matrix to be optimized.
@param matrixGradient matrix gradients for optimization step.
@throws MatrixException throws exception if matrix operation fails.
@throws DynamicParamException throws exception if parameter (params) setting fails.
Optimizes single matrix ( M ) using calculated matrix gradient ( dM ) . Matrix can be for example weight or bias matrix with gradient . @param matrix matrix to be optimized . @param matrixGradient matrix gradients for optimization step . @throws MatrixException throws exception if matrix operation fails . @throws DynamicParamException throws exception if parameter ( params ) setting fails .
public void optimize(Matrix matrix, Matrix matrixGradient) throws MatrixException, DynamicParamException {
        if (dPrev == null) dPrev = new HashMap<>();
        if (wPrev == null) wPrev = new HashMap<>();
        Matrix dMPrev;
        if (dPrev.containsKey(matrix)) dMPrev = dPrev.get(matrix);
        else dPrev.put(matrix, dMPrev = matrixGradient);
        Matrix WPrev;
        if (wPrev.containsKey(matrix)) WPrev = wPrev.get(matrix);
        else wPrev.put(matrix, WPrev = new DMatrix(matrix.getRows(), matrix.getColumns()));
        Matrix dWDir = dMPrev.sgnmul(matrixGradient);
        Matrix.MatrixBinaryOperation rpropRule = (value1, value2) -> value1 == -1 ? Math.max(0.5 * value2, 10E-6) : value1 == 1 ? Math.min(1.2 * value2, 50) : value2;
        wPrev.put(matrix, WPrev = dWDir.applyBi(WPrev, rpropRule));
        matrix.subtract(matrixGradient.apply(UnaryFunctionType.SGN).multiply(WPrev), matrix);
        dPrev.put(matrix, dWDir.applyBi(matrixGradient, (value1, value2) -> value1 == -1 ? 0 : value2));
    }
public void optimize ( Matrix matrix , Matrix matrixGradient ) throws MatrixException , DynamicParamException { if ( dPrev == null ) dPrev = new HashMap < > ( ) ; if ( wPrev == null ) wPrev = new HashMap < > ( ) ; Matrix dMPrev ; if ( dPrev . containsKey ( matrix ) ) dMPrev = dPrev . get ( matrix ) ; else dPrev . put ( matrix , dMPrev = matrixGradient ) ; Matrix WPrev ; if ( wPrev . containsKey ( matrix ) ) WPrev = wPrev . get ( matrix ) ; else wPrev . put ( matrix , WPrev = new DMatrix ( matrix . getRows ( ) , matrix . getColumns ( ) ) ) ; Matrix dWDir = dMPrev . sgnmul ( matrixGradient ) ; Matrix . MatrixBinaryOperation rpropRule = ( value1 , value2 ) -> value1 == - 1 ? Math . max ( 0.5 * value2 , 10E-6 ) : value1 == 1 ? Math . min ( 1.2 * value2 , 50 ) : value2 ; wPrev . put ( matrix , WPrev = dWDir . applyBi ( WPrev , rpropRule ) ) ; matrix . subtract ( matrixGradient . apply ( UnaryFunctionType . SGN ) . multiply ( WPrev ) , matrix ) ; dPrev . put ( matrix , dWDir . applyBi ( matrixGradient , ( value1 , value2 ) -> value1 == - 1 ? 0 : value2 ) ) ; }
Optimizes single matrix (M) using calculated matrix gradient (dM).<br>
 Matrix can be for example weight or bias matrix with gradient.<br>
Optimizes single matrix ( M ) using calculated matrix gradient ( dM ) . <br > Matrix can be for example weight or bias matrix with gradient . <br >