## 3 Methodology
### Vector Length Loss  
This paper proposes a vector length loss, a novel loss function that adjusts the length of the embedding vector to remove the L2-norm layer and use the triplet loss. This loss function is used with the triplet loss, including the L2-norm layer during stage 1, and the loss is calculated during the previous L2-norm layer. The loss for the length of the unnormalized embedding vector is calculated with the proposed loss function and minimized. The purpose of the vector length loss function is to adjust the length of the embedding vector by minimizing the length difference between the anchor and positive image in the triplet dataset. The vector length loss function only uses the anchor and positive image in the triplet dataset, not the negative image. In other words, the vector length loss aims to reduce the difference in the length of embedding vectors between the same class. This allows the model to be trained in stage 2 using triplet loss without the L2-norm layer. Since the vector length loss adjusts the length of the embedding vector, it can be used simultaneously with the triplet loss that adjusts the direction of the embedding vectors. \[g\left(x,\,z\right)\,=\,xz\,+\,\,\frac{1}{x(x+z)} \tag{5}\]  
Equation (5) calculates the loss for the length of the embedding vector of the anchor and positive images in the dataset, which is composed of a triplet. In Equation (5), \(x\) is the smaller value of the two embedding vector lengths, and \(z\) is the absolute value of the difference in length of the two normalized embedding vectors (Appendix B). The \(x\) is the length of the embedding vector. Therefore, \(x\) is greater than 0. Consequently, Equation (5) avoids division by zero:  
\[\frac{\delta^{2}\,g\,\left(x,\,z\right)}{\delta\,x^{2}}\ =\ \frac{2z^{2}\ +\ 6 xz\ +\ 6x^{2}}{x^{3}z^{3}\ +\ 3x^{4}z^{2}\ +\ 3x^{5}z\ +\ x^{6}} \tag{6}\]  
\[\frac{\delta^{2}\,g\,\left(x,\,z\right)}{\delta\,z^{2}}\ =\ \frac{2}{xz^{3}\ +\ 3x^{2}z^{2}\ +\ 3x^{3}z\ +\ x^{4}} \tag{7}\]  
Equations (6) and (7) are the second derivatives of \(x\) and \(z\) in Equation (5), respectively, which are always positive if \(x\) and \(z\) are greater than zero. In other words, vector length loss has one local point because the smaller embedding vector length of the anchor and positive images is always greater than zero, and the absolute value of the difference in length of two embedding vectors is greater than or equal to zero. The minimization of the loss calculated by this loss function converges \(z\) into 0 and diverges \(x\). However, Equation (5) is too sensitive to the value of \(z\), and the minimum loss cannot reach zero:  
\[h\,\left(x,\,z\right)\ =\ xz\ +\ \frac{1}{x(x+z)}\ -\ \beta \tag{8}\]  
The specific constant \(\beta\) is subtracted from Equation (5) in Equation (8), and the minimum value of the loss calculated by the equation can be adjusted to below zero, as shown in Figure 3a. In addition, the distribution of \(x\) and \(z\) can be appropriately adjusted by changing the \(\beta\). As the \(\beta\) increases, the \(z\), which can achieve the loss of zero, also increases. In addition, as the \(\beta\) increases, the range of \(x\)--which can achieve the loss of zero--increases. The purpose of this loss function is to minimize loss. In other words, the distribution of \(x\) and \(z\) means the distribution that makes the value of this loss function zero at a specific \(\beta\). As a result, it is possible to adjust the degree of distribution of \(x\) and \(z\) without calculating the loss. However, Equation (8) is still sensitive to the \(z\) value, and the allowable range for \(x\) is extremely small, which interferes with the triplet loss training because it is extremely convex. \[H\,\left(x,\,z\right)\ =\ z\ \ln\,\left(x+\ 1\right)\ +\ \frac{1}{x(x+z)}\ -\ \beta \tag{9}\]  
A natural logarithm was added to smoothen the equation and solve the problem of Equation (6) being too convex in Equation (9). The modified Equation (9) was less sensitive to the value of \(z\), and the allowable range of \(x\) was wider.