utils.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:pyglmnet 作者: glm-tools 项目源码 文件源码
def softmax(w):
    """Softmax function of given array of number w.

    Parameters
    ----------
    w: array | list
        The array of numbers.

    Returns
    -------
    dist: array
        The resulting array with values ranging from 0 to 1.
    """
    w = np.array(w)
    maxes = np.amax(w, axis=1)
    maxes = maxes.reshape(maxes.shape[0], 1)
    e = np.exp(w - maxes)
    dist = e / np.sum(e, axis=1, keepdims=True)
    return dist
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号