To train both networks to generate discriminative global descriptors we use a deep metric learning approach [1]} with a triplet margin loss [2]} defined as:
\(L(a_i,p_i,n_i) = \max \left\lbrace  d(a_i,p_i) - d(a_i,n_i) + m, 0 \right\rbrace  ,\) 
