def softmax_numpy(x):
    """
    NumpPy implementation of the softmax function.

    Parameters
    ----------
    x : ndarray
        Should have two dimensions

    Returns
    -------
    rval : ndarray
        rval[i,:] is the softmax of x[i,:]
    """
    stable_x = (x.T - x.max(axis=1)).T
    numer = np.exp(stable_x)
    return (numer.T / numer.sum(axis=1)).T
dataset/ETHPy150Open lisa-lab/pylearn2/pylearn2/expr/nnet.py/softmax_numpy/original