# Radar Emitter Structure Inversion Method Based on Metric and Deep Learning
## 4 Res Inversion Method
### AEM Network
#### 4.2.3 Metric Scorer  
Metric learning is one of the core problems of pattern recognition. To measure the similarity between samples, metric learning can also be considered as similarity. Its purpose is to minimize the distance between the same class of samples and increase the distance between different classes of samples. Therefore, the metric learning method selected in this paper aims to improve the feature domain separability of the extracted deep RF structure features. Drawing on the design concept of the generalized end-to-end loss function [58], the input of the metric scorer is designed as samples of a batch, including \(N\) different classes of RES and \(M\) samples under each class, as shown in Figure 7.  
First, \((N\times M)\) RF signals \(\mathbf{y}_{ji}\) (\(1\leqslant j\leqslant N,1\leqslant i\leqslant M\)) are acquired to build a batch:  
\[[(\mathbf{y}_{11},\mathbf{y}_{12},\cdots,\mathbf{y}_{1M}),(\mathbf{y}_{21}, \mathbf{y}_{22},\cdots,\mathbf{y}_{2M}),\cdots,(\mathbf{y}_{N1},\mathbf{y}_{N2 },\cdots,\mathbf{y}_{NM})], \tag{16}\]  
which are then fed into the feature encoder to extract their \((N\times M)\) deep RF structure features. \(\mathbf{h}_{str\_ji}\) represents the deep RF structure features of the \(i\)-th RF signal of the \(j\)-th class of RES. Then, the centroids of the deep RF structure features of the \(j\)-th class of RES are calculated:  
\[\mathbf{c}_{k}=\mathrm{E}_{m}[\mathbf{h}_{str\_jm}]=\frac{1}{M}\sum_{m=1}^{M} \mathbf{h}_{str\_jm}(1\leqslant j,k\leqslant N,1\leqslant i\leqslant M), \tag{17}\]  
where \(\mathbf{h}_{str\_jm}=[\mathbf{h}_{str\_j1},\mathbf{h}_{str\_j2},\cdots,\mathbf{ h}_{str\_j[M]}]\). In addition, it is noted that the deletion of a term when calculating the centroid of the real RES can stabilize the training process and help avoid trivial solutions [58]. Therefore, when \(k=j\), the centroid of deep RF structure features is calculated using the following formula:  
\[\mathbf{c}_{j}^{(-i)}=\frac{1}{M-1}\sum_{m=1,m\
eq i}^{M}\mathbf{h}_{str\_jm}. \tag{18}\]  
In addition, the deep RF structure features \(\mathbf{h}_{str\_ji}\) of each RF signal and the centroids \(\mathbf{c}_{k}\) of all classes are combined in series to form \((N\times M\times N)\) RF feature pairs as the input of the metric scorer. \[\mathbf{h}_{m\_jik}= \begin{cases}[\mathbf{h}_{str\_ji},\mathbf{c}_{j}^{(-i)} ]&if\;\;k=j;\\ \mathbf{h}_{str\_ji},\mathbf{c}_{k}&otherwise.\end{cases}  \tag{19}\]  
Figure 7: Metric scorer. The similarity score of each RF feature pair is calculated using a metric scorer, and the mapping between the feature domain and metric domain is realized:  
\[\mathbf{s}_{ijk}=g_{s}(\mathbf{h}_{ms\_jik},\theta_{s}), \tag{20}\]  
where \(\theta_{s}\) represents the metric scorer parameter. In the metric scorer, for each class of RES, each deep RF structure feature in \(M\) samples should have a higher similarity relative to the centroid of the deep RF structure feature in the same class, and it is far from the centroid of deep RF structure features in other classes. As shown in Figure 7, the expected effect of the metric scorer is that it introduces a larger value with respect to the colored part of the similarity score matrix, while the gray part has a smaller value.