据我所知,这Triplet Loss是一个损失函数,它减少了锚点和正值之间的距离,但减少了锚点和负值之间的距离。此外,还添加了一个边距。
所以对于例子让我们假设: a Siamese Network,它给出了嵌入:
anchor_output = [1,2,3,4,5...] # embedding given by the CNN model
positive_output = [1,2,3,4,4...]
negative_output= [53,43,33,23,13...]
Run Code Online (Sandbox Code Playgroud)
而且我认为我可以获得三重损失,例如:(我认为我必须使用 Lambda 层左右将其作为损失)
# calculate triplet loss
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)
Run Code Online (Sandbox Code Playgroud)
那么到底是什么: tfa.losses.TripletHardLoss和 tfa.losses.TripletSemiHardLoss
据我所知,Semi 和 hard 是Siamese Techniques推动模型学习更多的数据生成技术类型。
我的想法:正如我在这篇文章中学到的,我认为你可以:
27图像neural-network deep-learning conv-neural-network keras tensorflow