nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/learning/AdaMaxUpdater.java
@Override
    public void applyUpdater(INDArray gradient, int iteration, int epoch) {
        if (m == null || u == null)
            throw new IllegalStateException("Updater has not been initialized with view state");

        //m = B_1 * m + (1-B_1)*grad
        m.muli(config.getBeta1()).addi(gradient.mul(1 - config.getBeta1()));

        //u = max(B_2 * u, |grad|)
        u.muli(config.getBeta2());
        Transforms.abs(gradient, false); //In-place should be OK here, original gradient values aren't used again later
        Nd4j.getExecutioner().exec(new OldMax(u, gradient, u, u.length()));

        double beta1t = FastMath.pow(config.getBeta1(), iteration + 1);

        double learningRate = config.getLearningRate(iteration, epoch);
        double alphat = learningRate / (1.0 - beta1t);
        if (Double.isNaN(alphat) || Double.isInfinite(alphat) || alphat == 0.0) {
            alphat = config.getEpsilon();
        }

        u.addi(1e-32); // prevent NaNs in params
        gradient.assign(m).muli(alphat).divi(u);
    }
@Override
    public void applyUpdater(INDArray gradient, int iteration, int epoch) {
        if (m == null || u == null)
            throw new IllegalStateException("Updater has not been initialized with view state");

        //m = B_1 * m + (1-B_1)*grad
        m.muli(config.getBeta1()).addi(gradient.mul(1 - config.getBeta1()));

        //u = max(B_2 * u, |grad|)
        u.muli(config.getBeta2());
        Transforms.abs(gradient, false); //In-place should be OK here, original gradient values aren't used again later
        Nd4j.getExecutioner().exec(new OldMax(u, gradient, u, u.length()));

        double beta1t = FastMath.pow(config.getBeta1(), iteration + 1);

        double learningRate = config.getLearningRate(iteration, epoch);
        double alphat = learningRate / (1.0 - beta1t);
        if (Double.isNaN(alphat) || Double.isInfinite(alphat) || alphat == 0.0) {
            alphat = config.getEpsilon();
        }

        u.addi(1e-32); // prevent NaNs in params
        gradient.assign(m).muli(alphat).divi(u);
    }
@ Override public void applyUpdater ( INDArray gradient , int iteration , int epoch ) { if ( m == null || u == null ) throw new IllegalStateException ( "Updater has not been initialized with view state" ) ; //m = B_1 * m + (1-B_1)*grad m . muli ( config . getBeta1 ( ) ) . addi ( gradient . mul ( 1 - config . getBeta1 ( ) ) ) ; //u = max(B_2 * u, |grad|) u . muli ( config . getBeta2 ( ) ) ; Transforms . abs ( gradient , false ) ; //In-place should be OK here, original gradient values aren't used again later Nd4j . getExecutioner ( ) . exec ( new OldMax ( u , gradient , u , u . length ( ) ) ) ; double beta1t = FastMath . pow ( config . getBeta1 ( ) , iteration + 1 ) ; double learningRate = config . getLearningRate ( iteration , epoch ) ; double alphat = learningRate / ( 1.0 - beta1t ) ; if ( Double . isNaN ( alphat ) || Double . isInfinite ( alphat ) || alphat == 0.0 ) { alphat = config . getEpsilon ( ) ; } u . addi ( 1e-32 ) ; // prevent NaNs in params gradient . assign ( m ) . muli ( alphat ) . divi ( u ) ; }
Calculate the update based on the given gradient

@param gradient  the gradient to get the update for
@param iteration
@return the gradient
Calculate the update based on the given gradient