tiny_yolo.py 文件源码

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

项目:YOLOv1_tensorflow 作者: Nielsyang 项目源码 文件源码
def loss_func_yolo(output, label):
  res = 0

  for i in range(BATCH_SIZE):
    for j in range(0, S*S*(B*5+CLASSES), B*5+CLASSES):
      res += COORD_W * tf.sign(label[i][j+2]) * (tf.square(output[i][j] - label[i][j]) + tf.square(output[i][j+1]-label[i][j+1]) + 
                                               tf.square(output[i][j+2]/(label[i][j+2]+1e-7) - 1) + 
                                               tf.square(output[i][j+3]/(label[i][j+3]+1e-7) - 1))

      res += tf.sign(label[i][j+2]) * (tf.square(output[i][j+4] - label[i][j+4]))

      res += NOOBJ_W * tf.sign(tf.floor(label[i][j])) * (tf.square(output[i][j+4] - label[i][j+4]))

      res += COORD_W * tf.sign(label[i][j+7]) * (tf.square(output[i][j+5] - label[i][j+5]) + tf.square(output[i][j+6]-label[i][j+6]) + 
                                               tf.square(output[i][j+7]/(label[i][j+7]+1e-7) - 1) + 
                                               tf.square(output[i][j+8]/(label[i][j+8]+1e-7) - 1))

      res += tf.sign(label[i][j+7]) * (tf.square(output[i][j+9] - label[i][j+9]))

      res += NOOBJ_W * tf.sign(tf.floor(label[i][j+5])) * (tf.square(output[i][j+9] - label[i][j+9]))

      res += tf.sign(label[i][j+7]) * (tf.square(output[i][j+10] - label[i][j+10]) + tf.square(output[i][j+11] - label[i][j+11]))

  return res
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号