src/core/layer/OutputLayer.java
public void forwardProcess() throws MatrixException {
        if (targets == null || targets.isEmpty() || !training) return;
        error = null;
        for (Integer sampleIndex : targets.keySet()) {
            for (Integer matrixIndex : targets.entryKeySet()) {
                Matrix currentOutputs = getLayerOutputs().get(sampleIndex, matrixIndex);
                Matrix currentTargets = targets.get(sampleIndex, matrixIndex);
                Matrix outputError;
                if (multiOutput) {
                    if (currentOutputs.getSubMatrices().size() != lossFunctions.size()) throw new MatrixException("Number of outputs is not matching with number of loss functions");
                    ArrayList<Matrix> totalError = new ArrayList<>();
                    int lossFunctionsSize = lossFunctions.size();
                    for (int index = 0; index < lossFunctionsSize; index++) {
                        LossFunction lossFunction = lossFunctions.get(index);
                        Matrix subOutputs = currentOutputs.getSubMatrices().get(index);
                        Matrix subTargets = currentTargets.getSubMatrices().get(index);
                        Matrix subOutputError = lossFunction.getError(subOutputs, subTargets);
                        totalError.add(subOutputError);
                    }
                    outputError = new JMatrix(totalError, true);
                }
                else {
                    outputError = lossFunction.getError(currentOutputs, currentTargets);
                }
                error = error == null ? outputError : error.add(outputError);
            }
        }
        error = LossFunction.getMeanError(error, targets.totalSize());
    }
/**
     * Executes forward processing step of output layer.
     *
     * @throws MatrixException throws exception if matrix operation fails.
     */
Executes forward processing step of output layer.

@throws MatrixException throws exception if matrix operation fails.
Executes forward processing step of output layer . @throws MatrixException throws exception if matrix operation fails .
public void forwardProcess() throws MatrixException {
        if (targets == null || targets.isEmpty() || !training) return;
        error = null;
        for (Integer sampleIndex : targets.keySet()) {
            for (Integer matrixIndex : targets.entryKeySet()) {
                Matrix currentOutputs = getLayerOutputs().get(sampleIndex, matrixIndex);
                Matrix currentTargets = targets.get(sampleIndex, matrixIndex);
                Matrix outputError;
                if (multiOutput) {
                    if (currentOutputs.getSubMatrices().size() != lossFunctions.size()) throw new MatrixException("Number of outputs is not matching with number of loss functions");
                    ArrayList<Matrix> totalError = new ArrayList<>();
                    int lossFunctionsSize = lossFunctions.size();
                    for (int index = 0; index < lossFunctionsSize; index++) {
                        LossFunction lossFunction = lossFunctions.get(index);
                        Matrix subOutputs = currentOutputs.getSubMatrices().get(index);
                        Matrix subTargets = currentTargets.getSubMatrices().get(index);
                        Matrix subOutputError = lossFunction.getError(subOutputs, subTargets);
                        totalError.add(subOutputError);
                    }
                    outputError = new JMatrix(totalError, true);
                }
                else {
                    outputError = lossFunction.getError(currentOutputs, currentTargets);
                }
                error = error == null ? outputError : error.add(outputError);
            }
        }
        error = LossFunction.getMeanError(error, targets.totalSize());
    }
public void forwardProcess ( ) throws MatrixException { if ( targets == null || targets . isEmpty ( ) || ! training ) return ; error = null ; for ( Integer sampleIndex : targets . keySet ( ) ) { for ( Integer matrixIndex : targets . entryKeySet ( ) ) { Matrix currentOutputs = getLayerOutputs ( ) . get ( sampleIndex , matrixIndex ) ; Matrix currentTargets = targets . get ( sampleIndex , matrixIndex ) ; Matrix outputError ; if ( multiOutput ) { if ( currentOutputs . getSubMatrices ( ) . size ( ) != lossFunctions . size ( ) ) throw new MatrixException ( "Number of outputs is not matching with number of loss functions" ) ; ArrayList < Matrix > totalError = new ArrayList < > ( ) ; int lossFunctionsSize = lossFunctions . size ( ) ; for ( int index = 0 ; index < lossFunctionsSize ; index ++ ) { LossFunction lossFunction = lossFunctions . get ( index ) ; Matrix subOutputs = currentOutputs . getSubMatrices ( ) . get ( index ) ; Matrix subTargets = currentTargets . getSubMatrices ( ) . get ( index ) ; Matrix subOutputError = lossFunction . getError ( subOutputs , subTargets ) ; totalError . add ( subOutputError ) ; } outputError = new JMatrix ( totalError , true ) ; } else { outputError = lossFunction . getError ( currentOutputs , currentTargets ) ; } error = error == null ? outputError : error . add ( outputError ) ; } } error = LossFunction . getMeanError ( error , targets . totalSize ( ) ) ; }
Executes forward processing step of output layer.
Executes forward processing step of output layer .