## 3 Design of the Siamese Network  
Siamese networks can evaluate the similarity between two samples and are based on metric learning. Unlike traditional machine learning schemes, Siamese networks can recognize new targets from a small sample after being trained by a large number of other samples [26]. The architecture of the proposed Siamese network is shown in Figure 3 and has two parts. One is feature extraction, which consists of two convolutional neural networks (CNNs) with shared weights. Compared to recurrent neural networks (RNN) and artificial neural networks (ANN), since the feature detection layer of CNN learns through the training data, it learns implicitly from the training data. CNN is more suitable for UATR. When evaluating network performance, in order to understand it more comprehensively, an MLP network was designed to be compared with CNN. The other part is a similarity calculator, which calculates the Euclidean distance between the two outputs of the Siamese sub-networks. Samples X1 and X2 are an input sample pair, which can be positive or negative. The output indicates the difference between the two samples. The Euclidean distance between two samples can be written as  
\[D_{w}(X1,X2)=\parallel G_{w}(X1)-G_{w}(X2)\parallel \tag{11}\]  
where \(G_{\omega}(X1)\) is the eigenvector of sample \(X1\), \(G_{\omega}(X2)\) is the eigenvector of sample X2, and \(D_{\omega}(X1,X2)\) represents the similarity between sample \(X1\) and sample X2. In principle, the larger \(D_{\omega}(X1,X2)\) is, the less the similarity between samples \(X1\) and \(X2\); the smaller \(D_{\omega}(X1,X2)\) is, the more the similarity [27]. Next, the Siamese network is trained using a contrastive loss function to extract differentiated features. [PERSON] et al. first proposed the contrastive loss function to determine whether two inputs were positive or negative [28]. \begin{table}
\begin{tabular}{c c c c c c} \hline \hline  & **Datasets** & **Sub-Dataset** & **Ship Status** & **No. Ships** & **No. Pairs** \\ \hline \multirow{2}{*}{Training} & \multirow{2}{*}{AA} & AA+ & 1 & 7 & \(1\times 7\times 1000\) \\  & & AA\(-\) & 1 & 7 & \(1\times 7\times 1000\) \\ \hline \multirow{4}{*}{Validation} & \multirow{2}{*}{BB} & BB+ & 41 & 7 & \(41\times 7\times 500\) \\  & & BB\(-\) & 41 & 7 & \(41\times 7\times 500\) \\  & & CC+ & 16 & 7 & \(16\times 7\times 500\) \\  & & CC\(-\) & 16 & 7 & \(16\times 7\times 500\) \\  & & DD+ & 7 & 7 & \(7\times 7\times 500\) \\  & & DD\(-\) & 7 & 7 & \(7\times 7\times 500\) \\ \hline \multirow{4}{*}{Test} & \multirow{2}{*}{EE} & EE+ & 41 & 10 & \(41\times 10\times 1000\) \\  & & EE\(-\) & 41 & 10 & \(41\times 10\times 1000\) \\  & & FF+ & 16 & 10 & \(16\times 10\times 1000\) \\ \cline{1-1}  & & FF\(-\) & 16 & 10 & \(16\times 10\times 1000\) \\ \cline{1-1}  & & GG+ & 7 & 10 & \(7\times 10\times 1000\) \\ \cline{1-1}  & & GG & GG\(-\) & 7 & 10 & \(7\times 10\times 1000\) \\ \hline \hline \end{tabular}
\end{table} 
Table 2: The dimensions of positive and negative sample pairs. Figure 3: Siamese network architecture. A dataset with \(L\) sample pairs is \(\left\{\left(\left(x_{1},x_{2}\right)^{l},y_{l}\right)\right\}\), \(l=1,2,\ldots,L\), where \(\left(x_{1},x_{2}\right)^{l}\) is the \(l\)-\(th\) sample pair and \(y_{l}\) is the label of the sample pair. If the sample pair was positive, \(y_{l}=1\); otherwise, \(y_{l}=0\). The contrastive function is expressed as  
\[Loss=\frac{1}{2L}\sum_{l=1}^{L}{y_{l}{d_{l}}^{2}}+(1-y_{l})\text{max}(margin-d_ {l},0)^{2} \tag{12}\]  
where \(d\) is the Euclidean distance, and margin is the threshold. According to (10), \(d\) is minimized if samples \(X1\) and \(X2\) are a positive pair and maximized if \(X1\) and \(X2\) are a negative pair. This makes the differences between the extracted features more significant. A CNN is a feed-forward neural network often employed in image feature extraction and classification [29].