distributions.py 文件源码

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

项目:deep-learning-models 作者: kuleshov 项目源码 文件源码
def log_bernoulli(x, p, eps=1e-5):
    """
    Compute log pdf of a Bernoulli distribution with success probability p, at values x.
        .. math:: \log p(x; p) = \log \mathcal{B}(x; p)
    Parameters
    ----------
    x : Theano tensor
        Values at which to evaluate pdf.
    p : Theano tensor
        Success probability :math:`p(x=1)`, which is also the mean of the Bernoulli distribution.
    eps : float
        Small number used to avoid NaNs by clipping p in range [eps;1-eps].
    Returns
    -------
    Theano tensor
        Element-wise log probability, this has to be summed for multi-variate distributions.
    """
    p = T.clip(p, eps, 1.0 - eps)
    return -T.nnet.binary_crossentropy(p, x)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号