src/core/layer/regularization/Lp_Regularization.java
public void backwardProcess() throws MatrixException {
        resetLayerGradients();
        getLayerGradients().putAll(getNextLayerGradients());

        HashMap<Matrix, Matrix> layerWeightGradients = new HashMap<>();

        NeuralNetworkLayer previousNeuralNetworkLayer = getPreviousLayer();
        while (previousNeuralNetworkLayer != null) {
            HashMap<Matrix, Matrix> currentLayerWeightGradients = previousNeuralNetworkLayer.getLayerWeightGradients();
            if (currentLayerWeightGradients != null) layerWeightGradients.putAll(currentLayerWeightGradients);
            previousNeuralNetworkLayer = previousNeuralNetworkLayer.getPreviousLayer();
        }

        for (Matrix weight : layerRegularizedWeights) {
            if (layerWeightGradients.containsKey(weight)) {
                Matrix weightGradientSum = layerWeightGradients.get(weight);
                weightGradientSum.add(weight.apply((value) -> value != 0 ? p * lambda * Math.pow(Math.abs(value), p - 1) / value : 0), weightGradientSum);
            }
        }
    }
/**
     * Takes single backward processing step to process layer output gradient(s) towards input.<br>
     * Applies automated backward (automatic gradient) procedure when relevant to layer.<br>
     * Additionally applies any regularization defined for layer.<br>
     *
     * @throws MatrixException throws exception if matrix operation fails.
     */
Takes single backward processing step to process layer output gradient(s) towards input.
Applies automated backward (automatic gradient) procedure when relevant to layer.
Additionally applies any regularization defined for layer.

@throws MatrixException throws exception if matrix operation fails.
Takes single backward processing step to process layer output gradient ( s ) towards input . Applies automated backward ( automatic gradient ) procedure when relevant to layer . Additionally applies any regularization defined for layer . @throws MatrixException throws exception if matrix operation fails .
public void backwardProcess() throws MatrixException {
        resetLayerGradients();
        getLayerGradients().putAll(getNextLayerGradients());
        HashMap<Matrix, Matrix> layerWeightGradients = new HashMap<>();
        NeuralNetworkLayer previousNeuralNetworkLayer = getPreviousLayer();
        while (previousNeuralNetworkLayer != null) {
            HashMap<Matrix, Matrix> currentLayerWeightGradients = previousNeuralNetworkLayer.getLayerWeightGradients();
            if (currentLayerWeightGradients != null) layerWeightGradients.putAll(currentLayerWeightGradients);
            previousNeuralNetworkLayer = previousNeuralNetworkLayer.getPreviousLayer();
        }
        for (Matrix weight : layerRegularizedWeights) {
            if (layerWeightGradients.containsKey(weight)) {
                Matrix weightGradientSum = layerWeightGradients.get(weight);
                weightGradientSum.add(weight.apply((value) -> value != 0 ? p * lambda * Math.pow(Math.abs(value), p - 1) / value : 0), weightGradientSum);
            }
        }
    }
public void backwardProcess ( ) throws MatrixException { resetLayerGradients ( ) ; getLayerGradients ( ) . putAll ( getNextLayerGradients ( ) ) ; HashMap < Matrix , Matrix > layerWeightGradients = new HashMap < > ( ) ; NeuralNetworkLayer previousNeuralNetworkLayer = getPreviousLayer ( ) ; while ( previousNeuralNetworkLayer != null ) { HashMap < Matrix , Matrix > currentLayerWeightGradients = previousNeuralNetworkLayer . getLayerWeightGradients ( ) ; if ( currentLayerWeightGradients != null ) layerWeightGradients . putAll ( currentLayerWeightGradients ) ; previousNeuralNetworkLayer = previousNeuralNetworkLayer . getPreviousLayer ( ) ; } for ( Matrix weight : layerRegularizedWeights ) { if ( layerWeightGradients . containsKey ( weight ) ) { Matrix weightGradientSum = layerWeightGradients . get ( weight ) ; weightGradientSum . add ( weight . apply ( ( value ) -> value != 0 ? p * lambda * Math . pow ( Math . abs ( value ) , p - 1 ) / value : 0 ) , weightGradientSum ) ; } } }
Takes single backward processing step to process layer output gradient(s) towards input.<br>
 Applies automated backward (automatic gradient) procedure when relevant to layer.<br>
 Additionally applies any regularization defined for layer.<br>
Takes single backward processing step to process layer output gradient ( s ) towards input . <br > Applies automated backward ( automatic gradient ) procedure when relevant to layer . <br > Additionally applies any regularization defined for layer . <br >