# Background-Filtering Feature-Enhanced Graph Neural Networks for Few-Shot Learning
## 3 Method
### Prediction Results Calculations as Well as LOSS Calculations  
The ability of a feature-enhanced training stage to facilitate better training of later model stages is another advantage, since focusing too much on the model query set's accuracy might occasionally result in inaccurate estimates of sample similarity between support sets. Even if we set the edge weights between support sets to 0 or 1 during the primary training, they can change to an inaccurate value after training, which would impact the model's evaluation of the query set. In conclusion, we think it is essential to incorporate the feature-enhanced training step in the loss computation and to introduce it. After completing the alternating point update operation and changed the update operation of the \(L\) layer model, we have obtained an ideal graph that can be used to predict the category of the query set, \(E^{l}\). Since the prediction of samples in the feature training stage is meaningless, the graphs in this stage do not take part in actual prediction. However, projections must be performed in order to compute LOSS. Figure 4: The network architecture used for edge updates in BFFE-GNN. The figure omits weight operations and primarily showcases the network structure. The feature-reinforcement module in the model corresponds to the multi-head self-attention depicted in the figure. In this model, we mainly use the multi-head self-attention mechanism to enhance the differences between features. Here, H corresponds to the number of attention heads in the multi-head self-attention mechanism, and in this paper, H = 4. It is clear from the definition above that the edge weight indicates how similar two samples are to one another. Then, all that has to be done is to combine the similarity weights of the support set images that are associated with the image based on the category. It is possible to determine how similar this sample is to all other samples. We acquire the final probability distribution of the sample across all categories by applying Softmax processing to the similarity. For the classification result, we choose the category in the probability distribution that has the highest likelihood according to Figure 1d. The following is the formula:  
\[p_{i}=Soft\text{max}(\sum_{j\,\,\text{$\geqslant$}\,\,S}e_{ij}^{L}\cdot Onehot( y_{j}))\,\ i\ \in\ Q \tag{12}\]  
\[\hat{y}_{i}=MaxPosition(p_{i}) \tag{13}\]  
\(Onehot(. )\) is a function that generates 1 at the corresponding label position and 0 at other positions. For example, in way = 5, \(Onehot(2)\) = [0, 0, 1, 0, 0]. Softmax gives larger values a greater probability. \(MaxPosition(. )\) is the index to find the maximum value in the given array. First, the possibility distribution of image \(i\) in each category is calculated through Softmax. Then, the value of \(\hat{y}_{i}\) is found. Given the L-layer structure of the network, we must compute Loss for every network layer. Loss is computed using the gap. It is recommended that edge weights nearing 1 contribute less to the loss for targets exhibiting accurate forecast results. It is recommended that edge weights near 0 contribute to a reduced loss for targets exhibiting inaccurate forecast results. The loss of each edge in each layer is here measured using the cross-entropy loss function, where \(\hat{y}_{ij}\) represents the prediction result, whether picture \(i\) and picture \(j\) are in the same category or not. \(Lc\) is the binary cross-entropy loss function. \[L=Average(L_{c}(\hat{y}_{ij},y_{ij},e_{ij}^{l}))\ \,where\ i\ \in\ Q\wedge\ j\ \in\ S \wedge\ l\in\ L \tag{14}\]  
\[Lc(\hat{y},y,e)=\left\{ \begin{array}{l}-log(1-e)\,\ if\ \hat{y}\
eq y\\ -log(e)\,\ if\ \hat{y}=y\end{array} \right. \tag{15}\]  
\(Average(. )\) represents the average of all elements and returns it. It should be noted that \(i\) must come from the query set, \(j\) must come from the support set, and \(l\) is the number of layers in the network. The primary training phase and the feature-enhanced training phase both employ the same loss calculation technique.