and non-matching pairs:

$$\begin{split}
\label{Eq3}
l_g(p_1,p^+_2) =   max (0,  L_2(p_1,p^+_2) - L_2(p_1,p^-_2) + g  ), \\
p_1 \equiv p^+_2 \cap  p_1 \neq p^-_2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\end{split}$$

$l_g(p_1,p^-_2)$ is set to $-l_g(p_1,p^+_2)$ (reverse gradient). While $l_g$ intuitively seems to be better suited for the given problem than $l_t$, we will show in Section \[eval\] why this is not the case. There we will also compare $l_t$ to further loss functions.

The given loss functions have in common that the loss gradient is sometimes zero. Ordinary approaches still back propagate a zero gradient. This not only makes the approach slower than necessary, but also leads to a variable effective batch size of training samples, that are actually back propagated. This is a limited issue for the hinge embedding loss $l_h$, where only $\approx 25\%$ of the training samples obtain a zero gradient in our tests. However, with $l_t$ (and suitable $t$) more than 80% of the samples obtain a zero gradient.

As a result, we only add training samples with a non-zero loss to a batch. All other samples are rejected without back propagation. This not only increases the training speed by a factor of around two in our tests, but also improves 