src/utils/matrix/ComputableMatrix.java
public Matrix softmax(Matrix result) throws MatrixException {
        if (getColumns() != 1) {
            throw new MatrixException("Matrix must be a column vector.");
        }
        if (getRows() != result.getRows() || getColumns() != result.getColumns()) {
            throw new MatrixException("Incompatible result matrix size: " + result.getRows() + "x" + result.getColumns());
        }

        final double maxValue = max();
        apply(result, (Matrix.MatrixUnaryOperation & Serializable) (value) -> Math.exp(value - maxValue));
        result.divide(result.sum(), result);

        return result;
    }
/**
     * Returns softmax of matrix.
     *
     * @param result result matrix.
     * @return softmax of matrix.
     * @throws MatrixException thrown if index dimensions do not match.
     */
Returns softmax of matrix.

@param result result matrix.
@return softmax of matrix.
@throws MatrixException thrown if index dimensions do not match.
Returns softmax of matrix . @param result result matrix . @return softmax of matrix . @throws MatrixException thrown if index dimensions do not match .
public Matrix softmax(Matrix result) throws MatrixException {
        if (getColumns() != 1) {
            throw new MatrixException("Matrix must be a column vector.");
        }
        if (getRows() != result.getRows() || getColumns() != result.getColumns()) {
            throw new MatrixException("Incompatible result matrix size: " + result.getRows() + "x" + result.getColumns());
        }
        final double maxValue = max();
        apply(result, (Matrix.MatrixUnaryOperation & Serializable) (value) -> Math.exp(value - maxValue));
        result.divide(result.sum(), result);
        return result;
    }
public Matrix softmax ( Matrix result ) throws MatrixException { if ( getColumns ( ) != 1 ) { throw new MatrixException ( "Matrix must be a column vector." ) ; } if ( getRows ( ) != result . getRows ( ) || getColumns ( ) != result . getColumns ( ) ) { throw new MatrixException ( "Incompatible result matrix size: " + result . getRows ( ) + "x" + result . getColumns ( ) ) ; } final double maxValue = max ( ) ; apply ( result , ( Matrix . MatrixUnaryOperation & Serializable ) ( value ) -> Math . exp ( value - maxValue ) ) ; result . divide ( result . sum ( ) , result ) ; return result ; }
Returns softmax of matrix.
Returns softmax of matrix .