# A Novel Hierarchical Adaptive Feature Fusion Method for Meta-Learning
## 3 Method
### Weight Optimization  
The particle swarm optimization (PSO) [27, 28] algorithm is used in weight optimization. First, the weight optimization is carried out on the meta-evaluation set, and the optimal feature fusion weight is found by the optimization algorithm used in meta-testing. The particle swarm optimization algorithm is discussed in detail below. PSO is derived from the study of flock predation behavior and has the characteristics of evolution and swarm intelligence. The algorithm stores the information of the optimal global position and the known optimal local position, which has a good effect on fast convergence and avoids premature falling into the optimal local solution. However, it is easy for the standard particle swarm algorithm to fall into local optimum, and to overcome this problem, we use an adaptive inertia weight strategy that relates the change in inertia weight to the change in the particle's own fitness, and we use the fitness variance to  
Figure 4: Feature fusion of different stages of the network. In the figure, a \(\times\) a \(\times\) b represents the dimension of the input feature; c \(\times\) c denotes the feature dimension of each stage; S/Q denotes the size of support sets or query sets in a run; _Pooling_ represents pooling operation; _Concat_ indicates feature splicing. determine whether the algorithm falls into local optimum. If the algorithm falls into local optimum, a disturbance mechanism is used to generate new particles and replace the particles with the worst fitness in the population when the algorithm stalls, thus allowing the particles to jump out of the local optimum. Compared to other optimization algorithms, the particle swarm optimization algorithm has memory, all particles in the algorithm retain a better solution and the particles are only updated by internal velocity, making the algorithm easier to implement with fewer parameters. Therefore, this paper uses the particle swarm optimization algorithm to optimize the feature fusion weights. Our algorithm framework is shown in Figure 5.  
Figure 5: Flow chart of adaptive feature fusion and weight optimization algorithm. (1) Population initialization \(Q(t_{0})=\{Q_{i}(t_{0})\}_{i=1}^{n}\), where \(Q_{i}(t_{0})\) represents the \(i\)-th individual of the \(t_{0}\) generation in the population. \(t_{0}\) is the initial generation and \(n\) is the total number of individuals in the population. Each individual has an initial position \(X_{t_{0}}^{i}\) and an initial velocity \(V_{t_{0}}^{i}\) at the beginning. Each group weight of feature fusion corresponds to an individual, and population initialization corresponds to the initialization of \(n\) group weight of \(\lambda^{i}=\left\{\lambda_{1}^{i},\lambda_{2}^{i},\lambda_{3}^{i},\lambda_{4 }^{i}\right\}_{i=1}^{n}\) of feature fusion. (2) Each individual in the population is measured, and the individual solution can be expressed as \(P(t)=\left(P_{i}(t)\right)_{i=1}^{n}\), where \(P_{i}(t)\) represents the solution of the \(i\)-th individual in the \(t\) generation population. (3) \(P_{i}(t)\) is evaluated by the fitness function. Given that the meta-evaluation set \(C=\left\{(\,D_{j}^{train},D_{j}^{test})\,\right\}_{j=1}^{l}\), \(D_{j}^{train}\) is used to train the classifier, \(D_{j}^{test}\) is used to test the classifier, and the optimization process of each individual is set up as a thread that the computer can execute using the parallel computing method. The meta-learning accuracy of the classifier to the meta-evaluation set is defined as the fitness function of the population:  
\[Fitness(P_{i}(t))=Acc(C) \tag{11}\]  
where \(Acc(C)\) represents the accuracy of the meta-evaluation set, and the calculation method can be expressed as:  
\[Acc(C)=\frac{Predict\text{ }the\text{ }correct\text{ }sample\text{ }size}{The\text{ }total\text{ }number\text{ }of\text{ }samples}\times 100\% \tag{12}\]  
(4) The optimal individual is determined and retained. The optimal individuals and their fitness values were retained as the target of subsequent evolution.