losses.py 文件源码

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

项目:youtube-8m 作者: wangheda 项目源码 文件源码
def calculate_loss_postprocess(self, predictions, labels, **unused_params):
    with tf.name_scope("loss_postprocess"):
      float_labels = tf.cast(labels, tf.float32)
      predictions_pos = predictions*float_labels + (1-float_labels)
      predictions_neg = predictions*(1-float_labels)
      min_pos = tf.stop_gradient(tf.reduce_min(predictions_pos))
      max_neg = tf.stop_gradient(tf.reduce_max(predictions_neg))
      predictions_pos_mistake = tf.nn.relu(max_neg-predictions_pos)-0.01*tf.nn.relu(predictions_pos-max_neg)
      predictions_neg_mistake = tf.nn.relu(predictions_neg-min_pos)-0.01*tf.nn.relu(min_pos-predictions_neg)
      postprocess_loss = predictions_pos_mistake + predictions_neg_mistake
      return tf.reduce_mean(tf.reduce_sum(postprocess_loss, 1))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号