ops.py 文件源码

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

项目:seglink 作者: bgshih 项目源码 文件源码
def smooth_l1_loss(offsets, gt_offsets, scope=None):
  """
  Smooth L1 loss between offsets and encoded_gt
  ARGS
    offsets: [m?, 5], predicted offsets for one example
    gt_offsets: [m?, 5], correponding groundtruth offsets
  RETURN
    loss: scalar
  """
  with tf.variable_scope(scope or 'smooth_l1_loss'):
    gt_offsets = tf.stop_gradient(gt_offsets)
    diff = tf.abs(offsets - gt_offsets)
    lesser_mask = tf.cast(tf.less(diff, 1.0), tf.float32)
    larger_mask = 1.0 - lesser_mask
    losses = (0.5 * tf.square(diff)) * lesser_mask + (diff - 0.5) * larger_mask
    return tf.reduce_sum(losses, 1)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号