loss_functions.py 文件源码

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

项目:tf-Faster-RCNN 作者: kevinjliang 项目源码 文件源码
def smoothL1(x, sigma):
    '''
    Tensorflow implementation of smooth L1 loss defined in Fast RCNN:
        (https://arxiv.org/pdf/1504.08083v2.pdf)

                    0.5 * (sigma * x)^2         if |x| < 1/sigma^2
    smoothL1(x) = {
                    |x| - 0.5/sigma^2           otherwise
    '''
    with tf.variable_scope('smoothL1'):
        conditional = tf.less(tf.abs(x), 1/sigma**2)

        close = 0.5 * (sigma * x)**2
        far = tf.abs(x) - 0.5/sigma**2

    return tf.where(conditional, close, far)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号