Online Triplet Mining - TripletMarginLoss

Hi,

From what I understand using this loss function without modifying the data loader is considered an “offline” implementation - i.e. the triplets are chosen randomly.

Are there any recommendations or even other implementations for an “online” triplet loss? I’m looking for ways that while training, the model chooses the anchor, positive and negative samples such that they are considered semi-hard-triplets.

A good explanation for what I mean can be found in this post - Triplet Loss and Online Triplet Mining in TensorFlow | Olivier Moindrot blog