rksltnl / Deep-Metric-Learning-CVPR16

Main repository for Deep Metric Learning via Lifted Structured Feature Embedding
MIT License
341 stars 122 forks source link

Question about mining pairs #7

Closed bkj closed 8 years ago

bkj commented 8 years ago

This is a more generic algorithmic question. In your paper, you say:

We sample a few positive pairs at random, and then actively add their difficult neighbors to the training mini-batch.

I was wondering if you could explain more how you "add their difficult neighbors". I imagine that would mean finding the n nearest embedded neighbors of each of the constituents of the positive pairs. But how are you computing this efficiently? The most naive approach would be to predict on the entire dataset between each minibatch, but I figure that's probably overkill. Another way would be to store embeddings for each datapoint every time they appear in a minibatch, and find nearest neighbors using these embddings -- understanding the caveat that the embeddings are not totally up to date.

I'm planning on playing around with this but thought I'd ask your advice as well.

rksltnl commented 8 years ago

Hi,

I suggest you look at the loss layer implementation. https://github.com/rksltnl/Caffe-Deep-Metric-Learning-CVPR16/blob/0efd7544a9846f58df923c8b992198ba5c355454/src/caffe/layers/lifted_struct_similarity_softmax_layer.cpp#L32-L193

bkj commented 8 years ago

Thanks for the response. It looks like that is the function used to compute the loss/gradients on a minibatch, which is independent from the method used to actually select the minibatch -- is that correct? I can imagine that if you sample mini batches randomly you may end up with negative points inside the positive margins very infrequently.

On Tuesday, August 16, 2016, Hyun Oh Song notifications@github.com wrote:

Closed #7 https://github.com/rksltnl/Deep-Metric-Learning-CVPR16/issues/7.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rksltnl/Deep-Metric-Learning-CVPR16/issues/7#event-757967689, or mute the thread https://github.com/notifications/unsubscribe-auth/AFzgfcsheV5sDcQN3M5BlIMbffx7rxrVks5qgn5pgaJpZM4Jly11 .