# Reconstructed Prototype Network Combined with CDC-TAGCN for Few-Shot Action Recognition
## 3 Method
### Prototype Network (PN) and Reconstructed Prototype Network (RC-PN)
The cosine similarity between query and support samples is denoted as \(Sim\) and is calculated using the following Formula (7):  
\[Sim\left(f_{\Phi}\left(\Omega_{i}^{S}\right),f_{\Phi}\left(\Omega_{i}^{Q} \right)\right)=\frac{f_{\Phi}\left(\Omega_{i}^{S}\right)\cdot f_{\Phi}\left( \Omega_{i}^{Q}\right)}{\left|\left|f_{\Phi}\left(\Omega_{i}^{S}\right)\right| \right|\cdot\left|\left|f_{\Phi}\left(\Omega_{i}^{Q}\right)\right|\right|} \tag{7}\]  
Figure 1: Different colors represent different classes, and the dotted line represents the distance between the query sample and prototypes. According to Equation (4), the closer to a prototype, the higher the probability of belonging to that class. Larger \(Sim\) values imply greater similarity between two features. With a larger \(Sim\) value, the corresponding weight \(\alpha_{i}\) of the support sample should also be greater, \(\alpha_{i}\) calculated as follows:  
\[\alpha_{i}=\frac{exp\left(Sim\left(f_{\phi}\left(\Omega_{i}^{S}\right),f_{\phi} \left(\Omega_{i}^{Q}\right)\right)\right)}{\sum_{\Omega_{i}^{S}\in S_{k}}exp \left(Sim\left(f_{\phi}\left(\Omega_{j}^{S}\right),f_{\phi}\left(\Omega_{i}^{ Q}\right)\right)\right)} \tag{8}\]  
Figure 2 is a schematic diagram of the new prototypes generated by SCR. Further scrutinizing the Formula (8), \(\alpha_{i}\) varies with variations in the query sample \(\Omega_{i}^{Q}\). In other words, the prototypes are adaptively generated based on the query sample. The new prototype generation formula becomes:  
\[C_{k}=\sum_{\Omega_{j}^{S}\in S_{k}}\alpha_{i}f_{\phi}\left(\Omega_{i}^{S}\right) \tag{9}\]  
In the course of our research, we observed the presence of similar samples belonging to different classes. Logically, similar samples cause their respective feature matrices to be very close in value, resulting in their scattering within an overlapping space. This study incorporated a reconstruction distance loss, denoted as \(L_{RC}\). Unlike triplets loss [29], \(L_{RC}\) does not require label involvement and is computationally simpler. \(L_{RC}\) introduces a reward-penalty mechanism for distances into the original loss function, making the features of prototypes' intra-class samples more similar, bringing them closer in the same space. Additionally, it pushes features of samples from different classes farther apart, enhancing the overall dispersion of samples in the feature space. The \(L_{RC}\) loss formula is as follows:  
\[L_{RC}=\left\{ \begin{array}{cl}d(F_{b},C_{k})&k=b\\ max(0,\Delta-d(F_{b},C_{k}))&k\
eq b\end{array} \right. \tag{10}\]  
\(F_{b}=f_{\phi}\left(\Omega_{i}^{S}\right)\), where the subscript \(b\) indicates that the label of a sample belongs to class \(b\), and \(C_{k}\) represents the prototype for class \(k\). When \(k=b\), it indicates that the support sample and the class represented by \(C_{k}\) are of the same class. In this case, adding distance between the support sample and the prototype \(C_{k}\) to the loss function aims to gradually bring the support samples closer to the prototype. When \(k\
eq b\), it means that the support sample and \(C_{k}\) do not belong to the same class. In this scenario, \(\Delta\) represents the allowed distance between \(F_{b}\) and \(C_{k}\). If the distance does not exceed \(\Delta\), it is recorded as 0; otherwise, it is taken as \(\Delta-d(F_{c},C_{k})\). This ensures that the support samples move farther from other prototypes during iterations, making prototypes more dispersed. Figure 3 is a schematic diagram of \(L_{RC}\). Figure 2: In contrast to Figure 1, this figure illustrates how SCR enables query samples that were originally misclassified into the blue class to be correctly classified into the green class. The final loss function Formula (11) is as follows, \(\lambda\) controls the contribution:  
\[L_{total}=-\frac{1}{|Q|}{\sum_{i}^{|Q|}{\log}P_{\Phi}\left(\dot{\cdot} \overbrace{y_{i}}^{\cdot}=y_{i}\bigg{|}\Omega_{i}^{Q}\right)}+\lambda L_{RC} \tag{11}\]  
Figure 4 summarizes the process of the prototype network part.