pairwise_losses.py 文件源码

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

项目:jack 作者: uclmr 项目源码 文件源码
def square_exponential_loss(positive_scores, negative_scores, gamma=1.0):
    """
    Square-Exponential loss [1]:
        loss(p, n) = \sum_i - p_i^2 + \gamma e^(n_i)

    [1] http://yann.lecun.com/exdb/publis/pdf/lecun-06.pdf

    Args:
        positive_scores: (N,) Tensor containing scores of positive examples.
        negative_scores: (N,) Tensor containing scores of negative examples.
        gamma: Gamma hyper-parameter.
    Returns:
        Loss value.
    """
    square_exponential_losses = - positive_scores + gamma * tf.exp(negative_scores)
    loss = tf.reduce_sum(square_exponential_losses)
    return loss
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号