opr.miners package
Module for miners.
opr.miners.batch_hard_triplet_miner
Batch hard triplet miner implementation.
Code adopted from repository: https://github.com/jac99/MinkLocMultimodal, MIT License
- class opr.miners.batch_hard_triplet_miner.BatchHardTripletMiner(distance: BaseDistance)[source]
Bases:
ModuleBatch hard triplet miner.
Original idea is taken from repository: https://github.com/jac99/MinkLocMultimodal, MIT License
- forward(embeddings: Tensor, positives_mask: Tensor, negatives_mask: Tensor) Tuple[Tensor, Tensor, Tensor][source]
Mine hard triplets from given batch of embeddings. For each element in batch triplet will be mined.
- Parameters:
embeddings (Tensor) – Model output embeddings.
positives_mask (Tensor) – Binary mask of positive elements in batch.
negatives_mask (Tensor) – Binary mask of negative elements in batch.
- Returns:
Hard triplets tuple (a, p, n).
- Return type:
Tuple[Tensor, Tensor, Tensor]
- property stats: Dict[str, float]
Return statistics of last forward pass.