src/utils/procedure/expression/NormExpression.java
public void calculateGradient(int sampleIndex) throws MatrixException {
        if (result.getGradient(sampleIndex) == null) throw new MatrixException(getExpressionName() + ": Result gradient not defined.");
        // https://math.stackexchange.com/questions/1482494/derivative-of-the-l-p-norm/1482525
        if (!argument1.isStopGradient()) {
            Matrix normGradientMatrix = normGradientMatrixOperation.apply(argument1.getMatrix(sampleIndex), result.getMatrix(sampleIndex), argument1.getEmptyMatrix());
            Matrix resultMatrix = multiplyMatrixOperation.apply(result.getGradient(sampleIndex), normGradientMatrix, argument1.getEmptyMatrix());
            argument1.cumulateGradient(sampleIndex, resultMatrix, false);
        }
    }
/**
     * Calculates gradient of expression.
     *
     * @param sampleIndex sample index
     * @throws MatrixException throws exception if calculation of gradient fails.
     */
Calculates gradient of expression.
@param sampleIndex sample index
@throws MatrixException throws exception if calculation of gradient fails.
Calculates gradient of expression . @param sampleIndex sample index @throws MatrixException throws exception if calculation of gradient fails .
public void calculateGradient(int sampleIndex) throws MatrixException {
        if (result.getGradient(sampleIndex) == null) throw new MatrixException(getExpressionName() + ": Result gradient not defined.");
        if (!argument1.isStopGradient()) {
            Matrix normGradientMatrix = normGradientMatrixOperation.apply(argument1.getMatrix(sampleIndex), result.getMatrix(sampleIndex), argument1.getEmptyMatrix());
            Matrix resultMatrix = multiplyMatrixOperation.apply(result.getGradient(sampleIndex), normGradientMatrix, argument1.getEmptyMatrix());
            argument1.cumulateGradient(sampleIndex, resultMatrix, false);
        }
    }
public void calculateGradient ( int sampleIndex ) throws MatrixException { if ( result . getGradient ( sampleIndex ) == null ) throw new MatrixException ( getExpressionName ( ) + ": Result gradient not defined." ) ; if ( ! argument1 . isStopGradient ( ) ) { Matrix normGradientMatrix = normGradientMatrixOperation . apply ( argument1 . getMatrix ( sampleIndex ) , result . getMatrix ( sampleIndex ) , argument1 . getEmptyMatrix ( ) ) ; Matrix resultMatrix = multiplyMatrixOperation . apply ( result . getGradient ( sampleIndex ) , normGradientMatrix , argument1 . getEmptyMatrix ( ) ) ; argument1 . cumulateGradient ( sampleIndex , resultMatrix , false ) ; } }
Calculates gradient of expression.
Calculates gradient of expression .
// https://math.stackexchange.com/questions/1482494/derivative-of-the-l-p-norm/1482525