Here是对三联学习的简短回顾。 我使用三个具有共享权重的卷积神经网络来生成面嵌入(锚,正,否定),损失描述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 。这些只是10 000个三联体对的测试值,但我在实际组(600 000个三联体对)上得到了类似的结果。
为什么会这样?这是对的吗?
我使用SGD的动力,从学习率0.001 开始。
答案 0 :(得分:3)
以下是三胞胎硬度术语的快速回顾:
d(a,p) + margin < d(a,n)
d(a,n) < d(a,p)
d(a, p) < d(a, n) < d(a, p) + margin
你在这里描述的内容:
当我只选择硬三联体(距离(锚,正)和<距离(锚,负))
实际上是选择半硬三胞胎和轻松三胞胎。你正在移除硬三胞胎,所以你的损失会更小。
答案 1 :(得分:1)
服用tf.sqrt(d_pos)和tf.sqrt(d_neg)后你得到了什么?