src/utils/matrix/ComputableMatrix.java
public Matrix gumbelSoftmax(Matrix result, double gumbelSoftmaxTau) 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());
        }

        // https://blog.evjang.com/2016/11/tutorial-categorical-variational.html
        apply(result, (Matrix.MatrixUnaryOperation & Serializable) (value) -> (value + getGumbelNoise()) / gumbelSoftmaxTau);
        final double maxValue = max();
        apply(result, (Matrix.MatrixUnaryOperation & Serializable) (value) -> Math.exp(value - maxValue));
        result.divide(result.sum(), result);


        return result;
    }
/**
     * Returns Gumbel softmax of matrix.<br>
     * Applies sigmoid prior log function plus adds Gumbel noise.<br>
     *
     * @param result result matrix.
     * @param gumbelSoftmaxTau tau value for Gumbel Softmax.
     * @return Gumbel softmax of matrix.
     * @throws MatrixException thrown if index dimensions do not match.
     */
Returns Gumbel softmax of matrix.
Applies sigmoid prior log function plus adds Gumbel noise.

@param result result matrix.
@param gumbelSoftmaxTau tau value for Gumbel Softmax.
@return Gumbel softmax of matrix.
@throws MatrixException thrown if index dimensions do not match.
Returns Gumbel softmax of matrix . Applies sigmoid prior log function plus adds Gumbel noise . @param result result matrix . @param gumbelSoftmaxTau tau value for Gumbel Softmax . @return Gumbel softmax of matrix . @throws MatrixException thrown if index dimensions do not match .
public Matrix gumbelSoftmax(Matrix result, double gumbelSoftmaxTau) 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());
        }
        apply(result, (Matrix.MatrixUnaryOperation & Serializable) (value) -> (value + getGumbelNoise()) / gumbelSoftmaxTau);
        final double maxValue = max();
        apply(result, (Matrix.MatrixUnaryOperation & Serializable) (value) -> Math.exp(value - maxValue));
        result.divide(result.sum(), result);
        return result;
    }
public Matrix gumbelSoftmax ( Matrix result , double gumbelSoftmaxTau ) 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 ( ) ) ; } apply ( result , ( Matrix . MatrixUnaryOperation & Serializable ) ( value ) -> ( value + getGumbelNoise ( ) ) / gumbelSoftmaxTau ) ; final double maxValue = max ( ) ; apply ( result , ( Matrix . MatrixUnaryOperation & Serializable ) ( value ) -> Math . exp ( value - maxValue ) ) ; result . divide ( result . sum ( ) , result ) ; return result ; }
Returns Gumbel softmax of matrix.<br>
 Applies sigmoid prior log function plus adds Gumbel noise.<br>
Returns Gumbel softmax of matrix . <br > Applies sigmoid prior log function plus adds Gumbel noise . <br >
// https://blog.evjang.com/2016/11/tutorial-categorical-variational.html
