【发布时间】:2018-07-17 09:10:01
【问题描述】:
我正在尝试实现论文 [1] 中介绍的边际损失。 到目前为止,这就是我所做的。
def marginal_loss(model1, model2, y, margin, threshold):
margin_ = 1/(tf.pow(margin,2)-margin)
tmp = (1. - y)
euc_dist = tf.sqrt(tf.reduce_sum(tf.pow(model1-model2, 2), 1, keep_dims=True))
thres_dist = threshold - euc_dist
mul_val = tf.multiply(tmp, thres_dist)
sum_ = tf.reduce_sum(mul_val)
return tf.multiply(margin_, sum_)
但是,经过一些时期后,该值变为 nan。我不确定我犯了什么错误。此外,我使用 1 代替了 epsilon(在论文中描述),因为它的值不清楚。同样,确切的阈值也是未知的。
感谢您的帮助。
[1]https://ibug.doc.ic.ac.uk/media/uploads/documents/deng_marginal_loss_for_cvpr_2017_paper.pdf
【问题讨论】:
标签: tensorflow deep-learning loss-function