# Reconstructed Prototype Network Combined with CDC-TAGCN for Few-Shot Action Recognition
## 3 Method
### Prototype Network (PN) and Reconstructed Prototype Network (RC-PN)  
**Prototype Network (PN)**: The prototype network generates a corresponding prototype \(C_{k}\) for each class in the support set. The generation process of \(C_{k}\) is shown in Formula (3). \[C_{k}=\frac{1}{K}\sum_{(\Omega_{i}^{S},y_{i}^{S})\in S_{k}}f_{\Phi}\Big{(} \Omega_{i}^{S}\Big{)} \tag{3}\]  
In the training phase, \(S_{k}\) is a subset of \(S_{train}\). \(\Omega_{i}^{S}\) denotes the \(i-th\) input of the sample in support set \(S_{k}\), \(f_{\Phi}\) represents the encoder, and \(f_{\Phi}(\Omega_{i}^{S})\) represents the encoded features. Samples from the same action class exhibit a high degree of similarity in their features. The prototype network employs the \(K\)-nearest neighbors approach to classify the samples in the query set with the following Formula (4):  
\[P_{\Phi}\Big{(}y=k\;\Big{|}\;\Omega_{i}^{Q}\Big{)}=\frac{exp\Big{(}-d\Big{(}f _{\Phi}\Big{(}\Omega_{i}^{Q}\Big{)}\Big{)},C_{k}\Big{)}}{\sum_{k^{\prime}}exp \Big{(}-d\Big{(}f_{\Phi}\Big{(}\Omega_{i}^{Q}\Big{)}\Big{)},C_{k^{\prime}} \Big{)}} \tag{4}\]  
Formula (4) utilizes the Softmax function to convert distances into probabilities. Here, \(exp(\cdot)\) represents the exponential function. The function \(d(\cdot)\) is the distance between query samples and prototypes. The negative sign is used to invert the magnitude relationship of values so that the smaller the distance, the greater the similarity. The distance can be Euclidean distance, Mahalanobis distance, and so on. However, these distance metrics may not be optimal for time series calculations. The DTW algorithm can better measure the distance between time series. \[\Gamma(i,j)=E(i,j)+min\{\Gamma(i-1,j-1),\Gamma(i-1,j),\Gamma(i,j-1)\} \tag{5}\]\(E(i,j)\) represents the Frobenius norm of certain two moments in two sequences \(\Omega_{i}\) and \(\Omega_{j}\). When \(\Gamma(i,j)=\Gamma(m,m)\), it indicates the negative cumulative DTW distance between two sequences \(\Omega_{i}\) and \(\Omega_{j}\), each consisting of \(m\) moments. In practice, in real deployment, we use Soft-DTW, which allows the \(min\{\Gamma(i-1,j-1),\Gamma(i-1,j),\Gamma(i,j-1)\}\) to transition from being discrete to differentiable, thus resulting in a smoother outcome. For more details, please refer to the paper [3]. Figure 1 is a schematic diagram of the prototype network. Formula (6) is the loss function of the prototype network:  
\[L_{origin}=-\frac{1}{L}\sum_{i}^{L}\text{log}P_{\Phi}\left(\hat{y_{i}}=y_{i} \middle|\Omega_{i}^{Q}\right) \tag{6}\]  
\(L\) represents the number of query samples, while \(\hat{y_{i}}\) and \(y_{i}\) are the predicted and true labels for the query sample \(\Omega_{i}^{Q}\). When the \(\hat{y_{i}}\) matches perfectly to \(y_{i}\), the independent variable of the \(\text{log}(\cdot)\) function is 1, resulting in a total loss of 0. **Reconstructed Prototype Network (RC-PN)**: This section will introduce our reconstructed prototype network (RC-PN). RC-PN introduces SCR (sample coefficient reconstruction) and \(L_{RC}\) (reconstruction loss of distance). SCR makes the model more robust to noise interference. Additionally, \(L_{RC}\) enlarges the distances between class prototypes, leading to a more dispersed distribution of class prototypes and smaller differences between samples of the same class. Existing prototypes are generated by taking the mean of all samples within a class. However, there are often high-noise samples within datasets, and generating prototypes by a mean-based approach can be easily influenced by noise, leading to destructive results. In SCR, the generation of prototypes abandons the mean-based approach and attempts to create new prototypes using the cosine similarity between query samples and support set samples.