使用半硬三元组时损耗减少 [英] Loss decreases when using semi hard triplets

查看:224
本文介绍了使用半硬三元组时损耗减少的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此处是对三元组学习的简短回顾. 我正在使用三个具有共享权重的卷积神经网络,以生成人脸嵌入(),并描述了损失此处.

Here is a short review of triplet learning. I'm using three convolutional neural networks with shared weights in order to generate faces embeddings (anchor, positive, negative), with the loss described here.

三重损失:

anchor_output = ...  # shape [None, 128]
positive_output = ...  # shape [None, 128]
negative_output = ...  # shape [None, 128]

d_pos = tf.reduce_sum(tf.square(anchor_output - positive_output), 1)
d_neg = tf.reduce_sum(tf.square(anchor_output - negative_output), 1)

loss = tf.maximum(0., margin + d_pos - d_neg)
loss = tf.reduce_mean(loss)

当我仅选择三元组(distance(anchor, positive) < distance(anchor, negative))时,损失非常小: 0.08 . 当我选择所有三胞胎时,损失变得更大 0.17855 .这些只是用于10000个三联体对的测试值,但是我在实际组(600000个三联体对)上得到了相似的结果.

When I select only the hard triplets (distance(anchor, positive) < distance(anchor, negative)), the loss is very small: 0.08. When I select all triplets, the loss becomes bigger 0.17855. These are just test values for 10 000 triplet pairs, but I get similar results on the actual set (600 000 triplet pairs).

为什么会这样?正确吗?

Why does this happen? Is it correct?

我正在使用SGD,它以 0.001的学习率开始.

I'm using SGD with momentum, starting with learning rate 0.001.

推荐答案

以下是有关三重硬度的术语的快速回顾:

Here is a quick recap of the terminology on the hardness of triplets:

  • 简易三元组:由于d(a,p) + margin < d(a,n)
  • 而丢失0的三元组
  • 硬三元组:三元组,其中负数比正数更靠近锚点,即d(a,n) < d(a,p)
  • 半硬三元组:三元组中的负数不比正数更靠近锚点,但仍具有正损失:d(a, p) < d(a, n) < d(a, p) + margin
  • easy triplets: triplets which have a loss of 0, because d(a,p) + margin < d(a,n)
  • hard triplets: triplets where the negative is closer to the anchor than the positive, i.e. d(a,n) < d(a,p)
  • semi-hard triplets: triplets where the negative is not closer to the anchor than the positive, but still has positive loss: d(a, p) < d(a, n) < d(a, p) + margin

您在这里描述的内容:

当我仅选择硬三胞胎时(距离(锚定,正)<距离(锚定,负))

When I select only the hard triplets (distance(anchor, positive) < distance(anchor, negative))

实际上是在选择半硬三胞胎和简易三胞胎.您将卸下硬三重轴,因此损失较小.

is actually selecting semi-hard triplets and easy triplets. You're removing the hard triplets, so your loss is smaller.

这篇关于使用半硬三元组时损耗减少的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆