metric-learn icon indicating copy to clipboard operation
metric-learn copied to clipboard

Refactor LMNN as a triplets learner

Open zdk123 opened this issue 3 years ago • 0 comments

Addresses my request in #210.

  1. Introduces a _BaseLMNN/ LMNN class to operate on triplets, s.t. d(triplets[i, 0],triplets[i, 1]) < d(triplets[i, 0], triplets[i, 2]) - the same setup as SCML.
  • from this definition of triplets, create a 'label mask', an nxn matrix with mask[i,j] = 1 and mask[i,k] = -1 for the set triplet[i,j,k] (else 0).
  • This simply reformulates the loss_grad / _find_impostors to operate on this label mask (imposters that violate the large margin) are detected by evaluating the squared distances of entries implied by -1 values in the mask.
  • the desired parameter k can be inferred from the triplets by counting unique occurrences of genuine and imposter pairs
  1. Renames LMNN to LMNN_Supervised.

zdk123 avatar Jul 23 '22 20:07 zdk123