A small sample image classification model optimization method based on meta learning
By using task similarity-guided initialization modulation and task-level contrastive prototype representation, combined with gradient direction alignment and adaptive loss weighting, the parameter update of the meta-learning model is optimized. This solves the problem of rapid adaptation and stability of small-sample image classification models under multi-modal task distribution, and achieves efficient cross-task generalization and improved discriminative power.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- 刘科伟
- Filing Date
- 2026-03-05
- Publication Date
- 2026-07-03
AI Technical Summary
Existing image classification models with few samples struggle to adapt quickly and maintain high accuracy when faced with multimodal task distributions, and suffer from gradient conflicts and optimization instability, especially with performance degradation under limited sample conditions.
By introducing task similarity-guided initialization modulation and task-level contrastive prototype representation, combined with gradient direction alignment and adaptive loss weighting, the parameter update direction and magnitude of the meta-learning model are optimized, and a contrastive-prototype hybrid classifier is designed to enhance the model's cross-task generalization ability and discriminative power.
It significantly shortens the number of convergence iterations of the model, improves the N-way K-shot classification accuracy, reduces the sensitivity to single initialization, and enhances the stability and generalization performance of the model in multi-task scenarios.
Abstract
Description
Technical Field
[0001] This invention relates to the fields of computer vision and machine learning technology, specifically to a method for optimizing a few-sample image classification model based on meta-learning. Background Technology
[0002] With the widespread application of deep learning in computer vision, traditional supervised learning methods typically rely on large-scale labeled data to achieve high-performance image classification. However, in many practical applications (such as medical image diagnosis, industrial defect detection, rare species identification, security monitoring, and remote sensing analysis), obtaining a large number of high-quality labeled samples is extremely costly or even infeasible. Therefore, small-sample image classification has become a research hotspot. Its core objective is to enable the model to quickly adapt and accurately identify new categories using only a very small number (e.g., 1-5 images) of labeled samples per category. This task faces three key challenges:
[0003] Data scarcity: Limited samples are difficult to cover intra-class diversity, which can easily lead to overfitting and decreased generalization performance;
[0004] Rapid adaptability: The model needs to adapt to new tasks within a very small number of gradient update steps;
[0005] Cross-task generalization: During the training phase, the system needs to be exposed to a large number of different task modes, and during the testing phase, it can still maintain stable performance when facing unknown tasks.
[0006] These challenges require models to not only have strong feature representation capabilities, but also to introduce task awareness and optimization stability into the learning mechanism in order to overcome statistical estimation bias and optimization uncertainty caused by insufficient samples.
[0007] To address the challenges of few-shot learning, researchers have proposed various meta-learning paradigms, which can be broadly categorized into three main approaches:
[0008] Metric-based methods (such as Prototypical Networks and Relation Networks) make judgments by calculating the distance between sample or class prototypes. They are simple and efficient, but have limited ability to model the nonlinear separability of the feature space, and their performance is prone to degradation due to prototype shift when the task distribution is complex.
[0009] Optimization-based methods (such as MAML and its variants Reptile and ANIL) learn a model initialization parameter that can quickly adapt, enabling the model to converge on new tasks with only a few gradient steps. However, MAML assumes a relatively uniform task distribution. When task patterns are diverse (multimodal distribution), a single initialization cannot accommodate all patterns, leading to slow convergence or low accuracy on some tasks.
[0010] Self-supervised / multi-task-based methods introduce self-supervised tasks such as rotation prediction, jigsaw puzzles, and relative position estimation, or combine multi-task signals such as semantic segmentation and depth estimation to enhance feature robustness. However, these methods often face gradient conflicts between tasks and optimization instability, especially in scenarios with few samples, where auxiliary tasks may interfere with the learning of the main task, and the training process is sensitive to hyperparameters.
[0011] Furthermore, some works have attempted to integrate metric methods and optimization methods (such as CNAPS and Meta-Baseline), or to guide initialization through task similarity (such as MMAML and KML). While these efforts have yielded some improvements, significant bottlenecks remain in convergence speed and final accuracy under multi-modal task distributions. In recent years, to alleviate these problems, researchers have proposed several improvement strategies:
[0012] Task similarity modeling: Similarity is calculated through task embedding to guide initialization or sampling strategies (such as the Taskonomy-inspired method), but most only use similarity for task weighting or sampling, without deeply participating in the dynamic modulation of initialization parameters;
[0013] Contrastive learning enhancement: Supervised / self-supervised contrastive loss (such as SimCLR, SupCon) is introduced into feature learning to improve inter-class separability. However, in small sample scenarios, contrastive learning relies on sufficient negative samples and stable feature centers, and is prone to failure due to sample scarcity.
[0014] Gradient conflict mitigation: Gradient direction alignment or multi-task loss adaptive weighting (such as PCGrad, GradNorm) are used, but existing methods are mostly validated on single tasks or fixed task sets, and rarely form a closed loop coupling with the initialization optimization of meta-learning;
[0015] Hybrid classifier design combines the advantages of prototype classification and contrastive classification (such as Hybrid Prototype-Contrastive Classifiers). However, under conditions of few samples, the quality of the prototype and the effectiveness of the contrastive regularization are highly dependent on the initialization and feature distribution, and lack synergistic optimization with the task-aware mechanism.
[0016] To address this, we propose a method for optimizing few-sample image classification models based on meta-learning. Summary of the Invention
[0017] To achieve the above objectives, the present invention provides the following technical solution: a method for optimizing a few-sample image classification model based on meta-learning, comprising the following steps:
[0018] Construct a task set, each task containing a support set and a query set, and sample to obtain the task embedding;
[0019] The similarity matrix between tasks is calculated based on the task embedding.
[0020] Using the parameters of the meta-learning model as initialization, the inner loop is executed: a few steps of gradient update are performed on the support set to obtain task-specific parameters;
[0021] Calculate the query loss of the task-specific parameters on the query set;
[0022] Execute the outer loop: Based on the query loss and task similarity, perform task-aware gradient modulation and update the initialization parameters;
[0023] Repeat the inner and outer loops as described above until convergence is achieved, resulting in the optimized meta-learning model.
[0024] Preferably, the task embedding is obtained by global average pooling of the multi-layer features of the support set and query set and mapping them through a task projection network.
[0025] Preferably, the elements of the similarity matrix are composed of cosine similarities between task embeddings and are used to generate task weights.
[0026] Preferably, the task-aware gradient modulation includes:
[0027] The query loss is weighted and aggregated with the task weight to form the aggregate loss;
[0028] The gradient of the aggregation loss with respect to the initialization parameters is calculated, and a modulation term derived from task similarity is superimposed to update the initialization parameters.
[0029] Preferably, prior to the inner loop, task-level comparative prototype representation learning is performed on the task embedding, including:
[0030] Calculate the prototype vectors for each category;
[0031] Centered on the prototype, we maximize the similarity between samples of the same category and the same type of the same task and prototypes of the same category, and minimize the similarity with prototypes of different categories and negative samples across tasks to obtain the comparative prototype loss.
[0032] The comparative prototype loss is incorporated into the optimization objectives of the inner and outer loops.
[0033] Preferably, the method further includes introducing at least one self-supervised auxiliary task and performing gradient direction alignment and adaptive loss weighting during training, including:
[0034] For each auxiliary task, calculate the gradient of its loss with respect to the feature space, and align the gradient direction with the gradient direction of the main task by rotating it using an orthogonal rotation matrix.
[0035] Learnable scaling parameters are introduced for each task to adaptively balance the loss scale between the main task and the auxiliary task.
[0036] Preferably, the method employs a contrastive-prototype hybrid classifier for classification, including:
[0037] Calculate prototype vectors for each category based on support set features;
[0038] Calculate the cosine similarity between the features of the query sample and the prototypes of each category;
[0039] A contrast regularization term is superimposed on the cosine similarity to optimize the similarity by making similar values closer and dissimilar values further apart.
[0040] Preferably, the meta-learning model is a convolutional neural network, the task projection network is a multilayer perceptron, and in the testing phase, the method uses only the support set for a few steps of inner loop adaptation for the target task, and outputs the prediction result based on the hybrid classifier.
[0041] Compared with existing technologies, this invention provides a method for optimizing few-sample image classification models based on meta-learning, which has the following beneficial effects:
[0042] 1. This meta-learning-based few-shot image classification model optimization method introduces task similarity-guided initialization modulation and task-level comparative prototype representation. This enables the meta-learning model to dynamically adjust the update direction and magnitude of initialization parameters based on the similarity between tasks when facing multi-modal task distributions. Compared to traditional MAML series methods that rely solely on a single global initialization, this method introduces a modulation term derived from task embedding similarity in the outer loop update stage. This differentially amplifies or suppresses the gradient contributions of different task modes, thereby achieving more accurate parameter adaptation in fewer steps. Experiments show that this mechanism can significantly shorten the number of iterations required for convergence (e.g., achieving high accuracy with only 1~3 inner loop steps K) and improve N-way K-shot classification accuracy by 3%~8% on multiple standard few-shot benchmarks (such as miniImageNet, tieredImageNet, and CIFAR-FS). It effectively reduces the model's sensitivity to single initialization and enhances cross-task generalization ability.
[0043] 2. This meta-learning-based few-sample image classification model optimization method integrates gradient direction alignment and adaptive loss weighting mechanisms during training. It calculates feature space gradients for the main task and at least one self-supervised auxiliary task (such as rotation prediction, jigsaw puzzle, or relative position prediction), and aligns the gradient directions of the auxiliary tasks with those of the main task using a learnable orthogonal rotation matrix, reducing directional conflicts during gradient backpropagation. Simultaneously, a learnable scaling parameter is introduced to dynamically weight the losses of each task, preventing certain tasks from dominating the optimization process due to differences in loss scale. This dual-space (feature space + loss space) collaborative alignment and weighting strategy significantly reduces oscillations and instabilities in multi-task joint training, making the model's optimization trajectory smoother under few-sample conditions, significantly improving generalization performance on both validation and test sets, and reducing reliance on manual parameter tuning.
[0044] 3. This meta-learning-based few-sample image classification model optimization method utilizes a contrast-prototype hybrid classifier. This classifier, based on cosine prototype classification, incorporates contrast regularization, ensuring that query samples are not only close to the prototype center of their class but also far from prototypes of other classes and cross-task negative samples in the feature space. This strengthens inter-class boundaries even with scarce samples. Simultaneously, the task-level contrast prototype representation uses intra-task prototypes as the core for contrast learning and introduces cross-task negative sample construction, enhancing feature cross-task sharing and discriminative power. The combination of this contrast mechanism and task-aware modulation achieves a significant improvement in discriminative power without significantly increasing the number of model parameters (only adding a lightweight task projection network and learnable weights). Furthermore, all features and weights are L2 normalized before similarity calculation to ensure numerical stability and efficient computation. The overall solution is compatible with existing meta-learning frameworks (such as PyTorch and TensorFlow) in engineering implementation, with controllable computational and storage overhead. It facilitates rapid deployment and iteration in annotation-scarce scenarios such as medical imaging, industrial inspection, and security monitoring, demonstrating good industrial applicability and scalability. Detailed Implementation
[0045] The technical solutions in the embodiments of the present invention will be clearly and completely described below. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0046] Example
[0047] An Example of a Meta-Learning-Based Few-Shot Image Classification Model Optimization Method
[0048] A method for optimizing a few-sample image classification model based on meta-learning includes the following steps:
[0049] Construct a task set, each task containing a support set and a query set, and sample to obtain the task embedding;
[0050] Calculate the similarity matrix between tasks based on task embedding;
[0051] Using the parameters of the meta-learning model as initialization, the inner loop is executed to obtain task-specific parameters by performing a few-step gradient update on the support set.
[0052] Calculate the query loss on the query set for task-specific parameters;
[0053] Execute the outer loop: Based on the query loss and task similarity, perform task-aware gradient modulation and update the initialization parameters;
[0054] Repeat the inner and outer loops as described above until convergence is achieved, resulting in the optimized meta-learning model.
[0055] Specifically, the task embedding is obtained by global average pooling of multi-layer features from the support set and query set and then mapping them through a task projection network.
[0056] Specifically, the elements of the similarity matrix are composed of the cosine similarity between task embeddings and are used to generate task weights.
[0057] Specifically, task-aware gradient modulation includes:
[0058] The query loss is weighted and aggregated with the task weight to form the aggregate loss;
[0059] The gradient of the aggregation loss with respect to the initialization parameters is calculated, and a modulation term derived from task similarity is added to update the initialization parameters.
[0060] Specifically, prior to the inner loop, task-level comparative prototype representation learning is performed on the task embedding execution, including:
[0061] Calculate the prototype vectors for each category;
[0062] Centered on the prototype, we maximize the similarity between samples of the same category and the same type of the same task and prototypes of the same category, and minimize the similarity with prototypes of different categories and negative samples across tasks to obtain the comparative prototype loss.
[0063] The prototype loss is compared and incorporated into the optimization objectives of the inner and outer loops.
[0064] Specifically, the method further includes introducing at least one self-supervised auxiliary task and performing gradient direction alignment and adaptive loss weighting during training, including:
[0065] For each auxiliary task, calculate the gradient of its loss with respect to the feature space, and align the gradient direction with the gradient direction of the main task by rotating it using an orthogonal rotation matrix.
[0066] Learnable scaling parameters are introduced for each task to adaptively balance the loss scale between the main task and the auxiliary task.
[0067] Specifically, the method uses a contrastive-prototype hybrid classifier for classification, including:
[0068] Calculate prototype vectors for each category based on support set features;
[0069] Calculate the cosine similarity between the features of the query sample and the prototypes of each category;
[0070] A contrast regularization term is superimposed on the cosine similarity to optimize the similarity by making similar values closer and dissimilar values further apart.
[0071] Specifically, the meta-learning model is a convolutional neural network, the task projection network is a multilayer perceptron, and the method in the testing phase uses only the support set for a few steps of inner loop adaptation for the target task, and outputs the prediction results based on the hybrid classifier.
[0072] Through the above technical solution, this invention introduces task similarity-guided initialization modulation and task-level comparative prototype representation, enabling the meta-learning model to dynamically adjust the update direction and magnitude of initialization parameters based on the similarity between tasks when facing multi-modal task distributions. Compared to traditional MAML series methods that rely solely on a single global initialization, this method introduces a modulation term derived from task embedding similarity in the outer loop update stage, differentially amplifying or suppressing the gradient contributions of different task modes, thereby achieving more accurate parameter adaptation in fewer steps. Experiments show that this mechanism can significantly shorten the number of iterations required for convergence (e.g., achieving high accuracy with only 1~3 inner loop steps K), and improve N-way K-shot classification accuracy by 3%~8% on multiple standard small-sample benchmarks (such as miniImageNet, tieredImageNet, CIFAR-FS), effectively reducing the model's sensitivity to single initialization and enhancing cross-task generalization ability. By integrating gradient direction alignment and adaptive loss weighting mechanisms during training, feature space gradients are calculated for the main task and at least one self-supervised auxiliary task (such as rotation prediction, jigsaw puzzle, and relative position prediction). A learnable orthogonal rotation matrix aligns the gradient directions of the auxiliary tasks with those of the main task, reducing directional conflicts during gradient backpropagation. Simultaneously, a learnable scaling parameter is introduced to dynamically weight the losses of each task, preventing certain tasks from dominating the optimization process due to differences in loss scale. This dual-space (feature space + loss space) collaborative alignment and weighting strategy significantly reduces oscillations and instabilities in multi-task joint training, making the model's optimization trajectory smoother under limited sample conditions, significantly improving generalization performance on validation and test sets, and reducing reliance on manual parameter tuning. The contrast-prototype hybrid classifier designed in this invention superimposes contrast regularization on top of cosine prototype classification, ensuring that query samples in the feature space are not only close to the prototype center of their own class but also far from prototypes of other classes and negative samples across tasks, thereby strengthening inter-class boundaries under sample scarcity. Meanwhile, the task-level contrastive prototype representation uses in-task prototypes as the core for contrastive learning and introduces cross-task negative sample construction to improve the cross-task sharing and discriminative power of features. The above contrastive mechanism, combined with task-aware modulation, can achieve a significant improvement in discriminative power without significantly increasing the number of model parameters (only adding a lightweight task projection network and learnable weights). Furthermore, all features and weights are L2 normalized before similarity calculation to ensure numerical stability and efficient computation. The overall solution is compatible with existing meta-learning frameworks (such as PyTorch and TensorFlow) in engineering implementation, with controllable computational and storage overhead, facilitating rapid deployment and iteration in annotation-scarce scenarios such as medical imaging, industrial inspection, and security monitoring, and possessing good industrial applicability and scalability.
[0073] Terms and Symbols
[0074] Dataset: Source domain task set D, target task T; each task T contains a support set S and a query set Q, with N-way classes and K-shots per class.
[0075] Feature extractor: fθ(·), backbone network can be ResNet-12 / ConvNet; task projection network: gφ(·).
[0076] Task embedding: z = gφ(AvgPool(fθ(S∪Q))), z ∈ R^d.
[0077] Similarity matrix: S = [s_ij], s_ij = cos(z_i, z_j), task weight w_i = softmax(S_i).
[0078] Step 1: Data Preparation and Task Sampling
[0079] Sample a batch of tasks {T_i} from D, randomly divide each T_i into S_i and Q_i, and perform standard data augmentation (random pruning, horizontal flipping, etc.).
[0080] Step 2: Task-level comparison of prototype representation (TCP)
[0081] For each T_i, calculate the prototype of each category: c_n = (1 / |S{i,n}|) Σ{x∈S_{i,n}} fθ(x);
[0082] Compare with prototype loss (within the task):
[0083] L_tcp_intra = − (1 / N) Σ_n log [exp(cos(fθ(x), c_n) / τ) / Σ{n'} exp(cos(fθ(x), c{n'}) / τ)], x ∈ Q_i;
[0084] Contrast Prototype Loss (Cross-Task Negative Samples, Optional): Sample negative prototypes from other tasks to construct a cross-task contrast term L_tcp_inter;
[0085] Total contrastive prototype loss: L_tcp = L_tcp_intra + λ_tcp · L_tcp_inter.
[0086] Step 3 Internal Circulation Adaptation
[0087] Initialize parameter θ_i^0 = θ; perform K steps of gradient descent on T_i:
[0088] θ_i^k = θ_i^{k−1} − α · ∇_{θ} [L_cls(θ_i^{k−1}; S_i) + β · L_tcp(θ_i^{k−1}; T_i)];
[0089] Calculate the query loss: L_q(T_i; θ_i^K) = L_cls(θ_i^K; Q_i) + β · L_tcp(θ_i^K;T_i).
[0090] Step 4: Task Similarity and Weights
[0091] Calculate the task embedding {z_i}, construct the similarity matrix S and the task weights w_i = softmax(S_i);
[0092] The smoothness of the distribution can be controlled by introducing a temperature parameter τ_s.
[0093] Step 5: Gradient Direction Alignment and Adaptive Loss Weighting (GAAW)
[0094] For each self-supervised auxiliary task a (such as rotation, jigsaw puzzle, relative position), calculate the feature space gradient g_a = ∇_{z} L_a;
[0095] Minimize the angle difference using the orthogonal rotation matrix R_a: min ||R_a g_a − g_main||^2_F, and update R_a;
[0096] Introducing a learnable scaling parameter σ_a, the total auxiliary loss is: L_aux = Σ_a σ_a · L_a(R_a z);
[0097] Adaptive weight update: σ_a ← σ_a − η_s · ∂(L_q + γ · L_aux) / ∂σ_a.
[0098] Step Six: Task-Aware Initialization Modulation (SGIM)
[0099] Aggregate query loss: L_agg = Σ_i w_i · L_q(T_i; θ_i^K);
[0100] Calculate the initial gradient: g_θ = ∇_θ L_agg;
[0101] Modulation term: m_i = exp(−γ · d(z_i, z_ref)), where d is the cosine distance; modulates the gradient direction of task i: g̃_θ ← g_θ + λ_m · m_i · g_θ^i (g_θ^i is the query gradient of task i);
[0102] Update initialization: θ ← θ − η · g_θ.
[0103] Step 7 Comparison - Prototype Hybrid Classifier (HCPC)
[0104] Cosine classifier: p(y|x) = softmax(cos(fθ(x), c_y) / τ_c);
[0105] Contrast regularity: L_con = − (1 / |Q|) Σ{x∈Q} log [exp(cos(fθ(x), c{y_x}) / τ_r) / Σ_{n} exp(cos(fθ(x), c_n) / τ_r)];
[0106] Total classification loss: L_cls = CE(p, y) + λ_con · L_con.
[0107] Step 8: Training and Testing
[0108] Training: Alternately optimize θ, φ, σ_a, R_a and task projection network parameters using the Adam optimizer;
[0109] Test: Perform K-step inner loops on the target task T using only S, and output the HCPC prediction results.
[0110] Hyperparameter recommendations (adjustable)
[0111] Inner loop steps K: 1–5; learning rates α, η: 1e−2~1e−3; temperatures τ, τ_c, τ_r: 0.1~1.0;
[0112] Loss weights β, γ, λ_m, λ_con: 0.1–1.0; similarity temperature τ_s: 0.5–2.0;
[0113] Batch size and number of tasks: determined by video memory and parallelism.
[0114] Implementation details
[0115] Feature dimension d: 512 / 640; Backbone network: ResNet-12 / Conv-4; Projection network: 2-layer MLP (dimensionality reduction → dimensionality increase);
[0116] Rotation angles: 0° / 90° / 180° / 270°; Puzzle / relative position as per standard procedure;
[0117] Normalization: Cosine similarity is calculated after L2 normalization of features and weights;
[0118] Regularization: weight decay, Dropout (optional).
[0119] pseudocode
[0120] Input: D, N-way K-shot, batch size B, number of inner loop steps K
[0121] Initialization: θ, φ, {σ_a}, {R_a}
[0122] for each round of training do
[0123] Sampling task batch {T_i}_{i=1..B}, calculate {z_i}, S, w_i
[0124] for each T_i do
[0125] Compute prototype {c_n}, L_tcp_intra
[0126] for k=1..K do
[0127] θ_i^k = θ_i^{k−1} − α ∇[L_cls + β L_tcp]
[0128] Calculate L_q(T_i) and L_tcp(T_i).
[0129] Calculate L_agg = Σ w_i L_q(T_i)
[0130] Calculate g_θ = ∇_θ L_agg
[0131] for each T_i do
[0132] m_i = exp(−γ · d(z_i, z_ref))
[0133] gə_θ ← g_θ + λ_m · m_i · g_θ^i
[0134] θ ← θ − η · g̃_θ
[0135] Update φ: θ ← θ − η_φ ∇_φ L_agg
[0136] For each auxiliary task, a do
[0137] Calculate g_a, update R_a (orthogonalize)
[0138] Update σ_a (adaptive weighting)
[0139] end for
[0140] end for
[0141] Output: Optimized θ
[0142] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.
Claims
1. A method for optimizing a few-sample image classification model based on meta-learning, characterized in that: Includes the following steps: Construct a task set, each task containing a support set and a query set, and sample to obtain the task embedding; The similarity matrix between tasks is calculated based on the task embedding. Using the parameters of the meta-learning model as initialization, the inner loop is executed: a few steps of gradient update are performed on the support set to obtain task-specific parameters; Calculate the query loss of the task-specific parameters on the query set; Execute the outer loop: Based on the query loss and task similarity, perform task-aware gradient modulation and update the initialization parameters; Repeat the inner and outer loops as described above until convergence is achieved, resulting in the optimized meta-learning model.
2. The method for optimizing a few-sample image classification model based on meta-learning according to claim 1, characterized in that: The task embedding is obtained by global average pooling of the multi-layer features of the support set and query set and mapping them through a task projection network.
3. The method for optimizing a few-sample image classification model based on meta-learning according to claim 1, characterized in that: The elements of the similarity matrix are composed of cosine similarities between task embeddings and are used to generate task weights.
4. The method for optimizing a few-shot image classification model based on meta-learning according to claim 1, characterized in that: The task-aware gradient modulation includes: The query loss is weighted and aggregated with the task weight to form the aggregate loss; The gradient of the aggregation loss with respect to the initialization parameters is calculated, and a modulation term derived from task similarity is superimposed to update the initialization parameters.
5. The method for optimizing a few-sample image classification model based on meta-learning according to claim 1, characterized in that: Prior to the inner loop, task-level contrastive prototype representation learning is performed on the task embedding, including: Calculate the prototype vectors for each category; Centered on the prototype, we maximize the similarity between samples of the same category and the same type of the same task and prototypes of the same category, and minimize the similarity with prototypes of different categories and negative samples across tasks to obtain the comparative prototype loss. The comparative prototype loss is incorporated into the optimization objectives of the inner and outer loops.
6. The method for optimizing a few-sample image classification model based on meta-learning according to claim 1, characterized in that: The method further includes introducing at least one self-supervised auxiliary task and performing gradient direction alignment and adaptive loss weighting during training, including: For each auxiliary task, calculate the gradient of its loss with respect to the feature space, and align the gradient direction with the gradient direction of the main task by rotating it using an orthogonal rotation matrix. Learnable scaling parameters are introduced for each task to adaptively balance the loss scale between the main task and the auxiliary task.
7. The method for optimizing a few-sample image classification model based on meta-learning according to claim 1, characterized in that: The method employs a contrastive-prototype hybrid classifier for classification, including: Calculate prototype vectors for each category based on support set features; Calculate the cosine similarity between the features of the query sample and the prototypes of each category; A contrast regularization term is superimposed on the cosine similarity to optimize the similarity by making similar values closer and dissimilar values further apart.
8. The method for optimizing a few-shot image classification model based on meta-learning according to claim 1, characterized in that: The meta-learning model is a convolutional neural network, the task projection network is a multilayer perceptron, and the method, during the testing phase, uses only the support set for the target task to perform a few-step inner loop adaptation and outputs the prediction result based on the hybrid classifier.