see http://www.nec-labs.com/uploads/images/Department-Images/MediaAnalytics/papers/nips16_npairmetriclearning.pdf
Read `Improved Deep Metric Learning with Multi class N pair Loss Objective <http://www.nec-labs.com/uploads/images/Department-Images/MediaAnalytics/papers/nips16_npairmetriclearning.pdf>`_ .
Npair loss requires paired data. Npair loss has two parts, the first part is L2
Npair loss requires paired data. Npair loss has two parts: the first part is L2
regularizer on the embedding vector, the second part is cross entropy loss which
regularizer on the embedding vector; the second part is cross entropy loss which
takes the similarity matrix of anchor and positive as logits.
takes the similarity matrix of anchor and positive as logits.
Args:
Args:
anchor(Variable): embedding vector for the anchor image. shape=[batch_size, embedding_dims]
anchor(Variable): embedding vector for the anchor image. shape=[batch_size, embedding_dims]
positive(Variable): embedding vector for the positive image. shape=[batch_size, embedding_dims]
positive(Variable): embedding vector for the positive image. shape=[batch_size, embedding_dims]
labels(Varieble): 1-D tensor. shape=[batch_size]
labels(Variable): 1-D tensor. shape=[batch_size]
l2_res(float32): L2 regularization term on embedding vector, default: 0.02
l2_reg(float32): L2 regularization term on embedding vector, default: 0.002