flownet_S.py 文件源码

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

项目:flownetS_tensorflow 作者: studian 项目源码 文件源码
def loss(logits, flos):
    """Add endpoint error (EPE) predict flows to ground truth with different weight  
    Args:
    logits: Predict flows from inference().
    flos: Grund truth

    Returns:
        Loss tensor of type float.
    """
    x = logits[0]
    y = tf.image.resize_images(flos, get_size(x))
    flow6_loss = tf.scalar_mul(0.32, tf.reduce_mean(compute_euclidean_distance(x,y)))

    x = logits[1]
    y = tf.image.resize_images(flos, get_size(x))
    flow5_loss = tf.scalar_mul(0.08, tf.reduce_mean(compute_euclidean_distance(x,y)))

    x = logits[2]
    y = tf.image.resize_images(flos, get_size(x))
    flow4_loss = tf.scalar_mul(0.02, tf.reduce_mean(compute_euclidean_distance(x,y)))

    x = logits[3]
    y = tf.image.resize_images(flos, get_size(x))
    flow3_loss = tf.scalar_mul(0.01, tf.reduce_mean(compute_euclidean_distance(x,y)))

    x = logits[4]
    y = tf.image.resize_images(flos, get_size(x))
    flow2_loss = tf.scalar_mul(0.005, tf.reduce_mean(compute_euclidean_distance(x,y)))

    tf.add_to_collection('losses', tf.add_n([flow6_loss, flow5_loss, flow4_loss, flow3_loss, flow2_loss]))

    """
    x = logits
    y = tf.image.resize_images(flos, get_size(x))
    flow6_loss = tf.scalar_mul(0.32, tf.reduce_mean(compute_euclidean_distance(x,y)))
    tf.add_to_collection('losses', flow6_loss)
    """
    return tf.add_n(tf.get_collection('losses'), name='total_loss')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号