In order to better utilize the samples present in a batch, hard positive and hard negative (HPHN) mining [1]}, [2]} has been proposed. The expression for HPHN-triplet loss is given by:
\(\mathcal {L}_{HPHNtri}=\frac{1}{|\mathcal {P}|}\sum _{(i,j)\in \mathcal {P}}\bigg [\max \left(\max _{\mathbf {c}[i]= \mathbf {c}[k]}d_{i,k},\max _{\mathbf {c}[j]= \mathbf {c}[l]}d_{j,l}\right)\nonumber \\+m-\min \left(\min _{\mathbf {c}[i]\ne \mathbf {c}[k]}d_{i,k},\min _{\mathbf {c}[j]\ne \mathbf {c}[l]}d_{j,l}\right)\bigg ]_+.\) 
