Image classification method and system based on cross-domain small sample learning, electronic device and storage medium

By using a variational generative network to generate a dynamic learning rate in few-shot learning, and combining gradient descent and KL distance constraints to optimize the classifier network parameters, the problem of insufficient domain adaptation ability in cross-domain tasks is solved, and better recognition performance and generalization ability are achieved.

CN114936598BActive Publication Date: 2025-12-05GUANGDONG UNIV OF PETROCHEMICAL TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210581200.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-26
Publication Date
2025-12-05
Estimated Expiration
2042-05-26

AI Technical Summary

Technical Problem

Existing few-shot learning methods suffer from insufficient domain adaptation in cross-domain tasks, resulting in poor recognition performance, especially when the sample data comes from different domains, the system performance deteriorates.

Method used

By generating a dynamic learning rate distribution through a variational generative network, the learning rate is dynamically adjusted to adapt to different tasks. Combined with gradient descent and KL distance constraints, the classifier network parameters are optimized to enhance the domain generalization ability.

Benefits of technology

It improves the recognition performance and domain generalization ability of few-shot learning, enabling it to better adapt to new tasks and reduce the recognition impact of cross-domain tasks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114936598B_ABST
    Figure CN114936598B_ABST
Patent Text Reader

Abstract

The application discloses a cross-domain small sample learning method. A training sample set contains multiple samples, and each sample is a task. In the task, samples in a query set in the task are identified according to samples in a support set in the task, and the method comprises the following steps. i S11, a first distribution of a learning rate β of a variational generation network g is generated according to sample data of a support set S of a task i and initial classifier network parameters of a classifier network f, the first distribution is sampled to obtain the learning rate β of the task i i , and the classifier network parameters θ i of the task i are obtained by using the learning rate β i ; and step S12, new variational generation network parameters and classifier network parameters θ are generated according to sample data of a query set Q i of the task i and the classifier network parameters θ i '. The method can consider small sample learning and a cross-domain situation, adapt to new tasks, cover different tasks, and enhance system field generalization ability and self-adaptation ability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of machine learning, specifically to a cross-domain few-shot learning method, learning system, electronic device, and storage medium. Background Technology

[0002] Research in the field of Artificial Intelligence (AI) includes robotics, speech recognition, image recognition, natural language processing, and expert systems.

[0003] The core of artificial intelligence is machine learning. In machine learning, the algorithm learns from training data (also known as learning data) with known labels, optimizes the parameters of the algorithm model, and identifies test data with unknown labels.

[0004] In machine learning, few-shot learning is receiving increasing attention. The problem it addresses is how to utilize limited training data to learn effectively, thus mitigating the issue of insufficient model learning due to limited sample size and ensuring good recognition performance.

[0005] The MAML (Model-Agnostic Meta-Learning) method is a solution for few-shot learning. It employs a meta-learning algorithm and is applicable to any model trained based on gradient descent. Its basic idea is to train the model's initial parameters so that the model can perform several (one to more) gradient updates on the parameters using limited data from a new task, ultimately obtaining the optimal algorithmic model parameters.

[0006] Meta-learning uses each task as a training sample. For example, it might use a task that involves identifying and classifying test data based on a training dataset as a training sample. In few-shot learning, although the number of training data samples is small, there are many tasks that involve identifying and classifying test data based on a small training dataset. By using each identification task as a training sample, a large training dataset can be generated. During the learning process, the model continuously adapts to various specific tasks, optimizing the way the network model's parameters are determined and enabling the network to possess abstract learning capabilities.

[0007] In the MAML method, the learning rate is the same for different tasks. However, due to the need to consider both few-shot learning and cross-domain situations, the gradient initialization method in MAML is highly correlated with the task. The similarity between cross-domain tasks is poor. Using the same learning rate for different tasks will eliminate the differences between tasks, resulting in poor domain adaptation ability of the constructed network.

[0008] The existing few-shot learning methods described above are suitable for sample data originating from the same domain. However, in practical applications, few-shot data may come from different domains, resulting in significant domain bias. In such cases, existing methods exhibit considerable uncertainty when performing recognition on the target domain, impacting system performance. Summary of the Invention

[0009] This invention provides a cross-domain few-shot learning method, learning system, electronic device, and storage medium, which can improve domain generalization ability in few-shot learning.

[0010] In a first aspect, the present invention provides a cross-domain few-shot learning method, wherein the training sample set contains multiple samples, each sample representing a task, and in the task, samples in the query set of the task are identified based on samples in the support set of that task.

[0011] The method includes the following steps:

[0012] Step S11, based on the support set S of task i i Given the sample data and the initial classifier network parameters of classifier network f, variational generator network g generates a first distribution of learning rate β. Sampling is then performed on this first distribution to obtain the learning rate β for task i. i Using the learning rate β i Obtain the classifier network parameters θ′ for task i i ;

[0013] Step S12, based on the query set Q of task i i Sample data and classifier network parameters θ′ i Generate new variational generator network parameters And the classifier network parameters θ.

[0014] In the above invention, for different tasks i, a first distribution of the learning rate β is generated by the variational generator network g, and the first distribution is sampled to obtain the learning rate β corresponding to different tasks i. i That is, in this invention, the learning rate is not a fixed value, but follows a distribution generated by a variational generative network. The learning rate is obtained by sampling this distribution. Therefore, the learning rate can be dynamically adjusted according to the task, thereby reducing the impact of domain differences in sample data on the recognition results. This improves the performance of small sample learning while enhancing the generalization performance of the system and making it easier to adapt to new tasks.

[0015] As an example, for task i, steps S11 and S12 are repeated a specified number of times J, and the variational generator network parameters of task i are updated multiple times. And the classifier network parameters θ.

[0016] In the above embodiments, for each task i, step S11 is executed a specified number of times J, that is, an inner loop is formed, and the classifier network parameters θ′ related to task i are continuously updated using the sample data of the support set. i For each task i, step S12 is executed a specified number of times J, forming an outer loop that continuously updates the variational generation network parameters using sample data from the query set. And the parameters obtained from the classifier network parameters θ. Furthermore, the parameter θ encompasses information from all tasks, exhibits good few-sample recognition performance, and demonstrates good domain generalization ability.

[0017] As an example, in step S11, according to the support set S of task i i Given the sample data and the initial classifier network parameters of classifier network f, calculate the objective function L for task i. Si gradient ▽L Si According to this gradient ▽L Si The variational generative network g generates a first distribution of the learning rate β;

[0018] In step S12, based on the query set Q of task i i Sample data and classifier network parameters θ′ i Calculate the objective function L for task i. Qi gradient ▽L Qi According to gradient ▽L Qi Generate new variational generator network parameters And the classifier network parameters θ.

[0019] In the above embodiments, according to the support set S i gradient ▽L on Si Generate the first distribution of the learning rate β and update the classifier network parameters θ′ for task i. i According to query set Q i gradient ▽L on Qi Update variational generator network parameters The classifier network parameters θ are iteratively updated; that is, this embodiment trains based on gradient descent and uses a variational generative network to generate the distribution of the learning rate β. Compared with existing technologies, this embodiment has better few-shot recognition performance and domain generalization performance.

[0020] As an example, step S12 includes the following steps:

[0021] Step 121, based on gradient ▽L Qi The variational generative network g generates a second distribution of the learning rate β.

[0022] Step 122: Calculate the KL distance between the first distribution and the second distribution, and update the variational generator network parameters by minimizing the KL distance. And the classifier network parameters θ.

[0023] In the above embodiments, according to gradient ▽L Qi The variational generative network g generates a second distribution with a learning rate β. The KL distance between the first and second distributions is calculated; that is, the first and second distributions are compared to maximize their likelihood. This is achieved by using the KL distance D... K Update the variational generator network parameters as a constraint. Including the classifier network parameters θ, can improve the system's small sample recognition performance and domain generalization performance.

[0024] As an example, for different tasks i, the query set Q is computed. i The loss function L for each task i Qi The loss function L for task i Qi Adding the KL distances to task i yields the objective function L for task i. i-ELBO Calculate the objective function L for all tasks. i-ELBO The sum of these yields the overall objective function L on the query set. ELBO According to the overall objective function L ELBO Update variational generator network parameters And the classifier network parameters θ.

[0025] In the above embodiments, the variational generation network parameters are updated by using the KL distance as a constraint. In addition, the classifier network parameters θ can improve the system's small sample recognition performance while also improving its domain generalization performance.

[0026] As an example, in step S12,

[0027] For variational generator network parameters Calculate the objective function L for task i Qi gradient▽ φ L Qi According to gradient ▽ φ L Qi Generate new variational generator network parameters

[0028] For the classifier network parameters θ, calculate the objective function L for task i. Qi gradient▽ θ L Qi According to gradient ▽ θ L Qi Generate new classifier network parameters θ.

[0029] In the above embodiments, the network parameters are generated on the query set. Calculate gradient Calculate the gradient for the classifier network parameters θ These are used to update the generated network parameters. And the classifier network parameters θ, the updated classifier network parameters θ, and the variational generator network parameters It covers information for all tasks i, has good few-sample recognition performance, and has good domain generalization ability.

[0030] Secondly, this invention provides a cross-domain few-shot learning system, comprising: a variational generative network unit and a classifier network unit, wherein the classifier network unit receives a support set S for task i. i Sample data,

[0031] Variational generative network units are based on the support set S of task i i Given the sample data and the initial classifier network parameters of the classifier network units, a first distribution of the learning rate β is generated.

[0032] The classifier network unit samples the first distribution to obtain the learning rate β for task i. i ,

[0033] The classifier network unit utilizes the learning rate β i Obtain the classifier network parameters θ′ for task i i ;

[0034] The classifier network unit receives the query set Q of task i. i The sample data, based on the query set Q of task i i Sample data and classifier network parameters θ′ i Generate new variational generator network parameters And the classifier network parameters θ.

[0035] As an example, the classifier network unit is based on the support set S of task i. i Given the sample data and the initial classifier network parameters of the classifier network units, calculate the objective function L for task i. Si gradient ▽L Si ,

[0036] Variational generative network units based on this gradient ▽L Si Generate the first distribution of the learning rate β;

[0037] The classifier network unit is based on the query set Q of task i. i Sample data and classifier network parameters θ′ i Calculate the objective function L for task i.Qi gradient ▽L Qi According to gradient ▽L Qi Generate new variational generator network parameters And the classifier network parameters θ.

[0038] As an example, the variational generative network unit is based on the gradient ▽L Qi Generate a second distribution of the learning rate β.

[0039] The classifier network unit calculates the KL distance between the first and second distributions, and updates the variational generator network parameters by minimizing the KL distance. And the classifier network parameters θ.

[0040] As an example, the classifier network unit computes the query set Q. i The loss function L for each task i Qi The loss function L for task i Qi Adding the KL distances to task i yields the objective function L for task i. i-ELBO Calculate the objective function L for all tasks. i-ELBO The sum of these yields the overall objective function L. ELBO According to the overall objective function L ELBO Update variational generator network parameters And the classifier network parameters θ.

[0041] As an example, the classifier network unit is based on the variational generator network parameters. Calculate the objective function L for task i Qi gradient▽ φ L Qi According to gradient ▽ φ L Qi Generate new variational generator network parameters

[0042] And for the classifier network parameters θ, calculate the objective function L for task i. Qi gradient▽ θ L Qi According to gradient ▽ θ L Qi Generate new classifier network parameters θ.

[0043] Thirdly, the present invention provides an electronic device, including one or more processors and a memory, wherein one or more computer programs are stored in the memory, and when one or more processors execute one or more computer programs, the cross-domain few-shot learning method of any one of the first aspects of the present invention is implemented.

[0044] Fourthly, the present invention provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the cross-domain few-shot learning method of any one of the first aspects of the present invention. Attached Figure Description

[0045] The technical solutions of the embodiments of this application are described below with reference to the accompanying drawings. The drawings are for illustrative purposes only and are not intended to limit the scope of this application. Furthermore, the same reference numerals denote the same components throughout the drawings.

[0046] Figure 1 This is a schematic diagram illustrating small sample data and meta-learning data examples according to an embodiment of the present invention;

[0047] Figure 2 This is a flowchart of the cross-domain few-shot learning method according to an embodiment of the present invention;

[0048] Figure 3 This is a schematic diagram of the cross-domain few-shot learning method according to an embodiment of the present invention;

[0049] Figure 4 This is a schematic diagram of the cross-domain few-shot learning system structure according to an embodiment of the present invention. Detailed Implementation

[0050] The embodiments of the technical solution of this application will be described in detail below with reference to the accompanying drawings. The following embodiments are only used to clearly illustrate the technical solution of this application, and should not be used to limit the scope of protection of this application.

[0051] Unless otherwise defined, all technical and scientific terms used in this specification have the same meaning as commonly understood by one of ordinary skill in the art; the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the application; the terms “comprising” and “having”, and any variations thereof, in the specification, claims and foregoing description of the drawings are intended to cover non-exclusive inclusion.

[0052] In the description of the specification, technical terms such as "first" and "second" are used only to distinguish different objects and should not be construed as indicating or implying relative importance or implicitly indicating the number, specific order, or primary and secondary relationship of the indicated technical features.

[0053] The various embodiments described in the specification are not mutually exclusive, and those skilled in the art can combine the various embodiments based on the technical concept and common knowledge of this application.

[0054] In the description of this specification, the term "and / or" is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. Additionally, the character " / " in this document generally indicates that the preceding and following related objects have an "or" relationship.

[0055] The cross-domain few-shot learning method, cross-domain few-shot learning system, electronic device, and computer-readable storage medium of the present invention can solve the problem of insufficient model learning in few-shot learning, improve few-shot recognition performance, and also improve the system's domain generalization performance when there is a large domain offset in the sample data.

[0056] The cross-domain few-shot learning method and system of the present invention can be applied to the recognition of graphic data, speech data, or text data. The following embodiments mainly use graphic data recognition as an example for illustration.

[0057] Figure 1 This is an example of small sample data and a data diagram illustrating meta-learning, which is an embodiment of the present invention.

[0058] Figure 1 The example shown is a small sample dataset. The support set is the typical training set, and the query set is the typical test set.

[0059] Figure 1 The support set S contains only five categories of sample data, with only one data point per category. Specifically, the first row of support set S contains image data for each of the five categories: bird, tank, dog, singer, and piano. The second row of support set S contains image data for each of the five different categories, and the third row of support set S also contains image data for each of the five different categories.

[0060] Typically, training data is represented by “common”, which means different categories of graphical data. 5-way means that the training data contains five categories, and 1-shot means that there is one data point for each category.

[0061] Few-shot learning involves learning from such training data and accurately classifying each data point contained in the query set Q.

[0062] Meta-learning is a method for solving few-shot learning. In meta-learning, each task is used as a training sample, for example... Figure 1In this context, the task of recognizing and classifying graphic samples from the corresponding query set is based on commemorative learning of graphic samples from a support set, and this task is used as a training sample. Figure 1 Each row in the matrix represents a sample in the meta-learning process. Although each support set has a small number of samples, as... Figure 1 As shown, there are many tasks that identify and classify a query set based on a support set, so a large training dataset can be generated for learning.

[0063] Figure 1 In this context, meta-training refers to the training set for meta-learning. Each training sample consists of a task, and the categories of the graph samples in the support set S and query set Q of each training sample are known.

[0064] Figure 1 In meta-learning, the meta-test refers to the test set. That is, learning is performed using the sample data of the support set S in the meta-test to identify and classify each graphic sample data in the query set Q in the meta-test.

[0065] like Figure 1 As shown, the classes of the support set S and the query set Q in each training sample (i.e., each task) during meta-training may differ, and the classes of the individual support sets S and query sets Q in the training samples (i.e., each task) may also differ from the classes of the graphical sample data in the support set during meta-testing. In the case of such training data, few-shot learning... Figure 1 The training samples shown in the meta-training are used to learn and train, obtaining the optimal initial values ​​of the classifier model's parameters. When classifying each graphic sample data in the query set Q of the meta-test, the sample data in the support set S of the meta-test are used to learn and train, obtaining the optimal parameters of the classifier model for the meta-test task. These parameters are then used to classify the graphic samples in the query set Q of the meta-test.

[0066] Therefore, in order to ensure good training results during the testing phase, it is necessary to simulate as many possible situations as possible during the learning phase. That is, during the training process, a large number of training samples (tasks) need to be generated for learning.

[0067] As mentioned above, in existing technologies, the Model-Agnostic Meta-Learning (MAML) method is one approach to address few-shot learning. In MAML, the learning rate is the same for different tasks, but in reality, there are differences between tasks, and using the same learning rate leads to insufficient system performance. However, when cross-domain scenarios exist in few-shot learning, the adaptive capabilities of these existing technologies are insufficient.

[0068] The cross-domain few-shot learning method and system of the present invention improve the learning process, thereby enhancing the few-shot learning performance and domain generalization ability, and making it easier to adapt to new few-shot tasks.

[0069] In this invention, a distribution 101 of the learning rate β is generated by the variational generator network g. By sampling this distribution 101, the learning rate β of each task i is obtained. i Using this learning rate β i The variational generator network parameters of the variational generator network g are updated iteratively. And the classifier network parameters θ of the classifier network f, thereby improving few-shot learning ability and enhancing the system's domain generalization ability.

[0070] The following is for reference Figure 2 , Figure 3 The cross-domain few-shot learning method 100 of the present invention is described in detail.

[0071] Figure 2 This is a flowchart of a cross-domain few-shot learning method 100 according to an embodiment of the present invention.

[0072] Figure 3 This is a schematic diagram of the cross-domain few-shot learning method 100 according to an embodiment of the present invention.

[0073] Figure 3 S i and Q i This represents the support set and query set for task i. Let L represent the gradient symbol and L represent the objective function. Here, θ represents the variational generation network parameters, and θ′ represents the classifier network parameters. i β represents the classifier network parameters for task i. i This represents the learning rate for task i.

[0074] like Figure 3 As shown, in the cross-domain few-shot learning method 100 of the present invention, the support set S i and query set Q i A task i (i = 1, T) is constructed, and T tasks constitute a training set containing T training samples. In each task i, the support set S is used. i Learn from the samples in the dataset to identify the query set Q. i The samples in.

[0075] like Figure 2 , Figure 3 As shown, the cross-domain few-shot learning method 100 includes the following steps:

[0076] Step S11, based on the support set S of task i iThe sample data and the initial classifier network parameters of the classifier network f, and the distribution of the learning rate β generated by the variational generator network g (for convenience, the following will be based on the support set S) i The calculated learning rate β is distributed as follows (referred to as the "first distribution"). Sampling is then performed on this first distribution to obtain the learning rate β for task i. i Using the learning rate β i Obtain the classifier network parameters θ for task i i ′;

[0077] by Figure 1 Taking the sampling of the network parameters of the classifier in the example to obtain sample data, in step S11, the support set S of task i (i=1,T) is... i Five graphical data (e.g., Figure 1 The first row of five graphs and samples in the meta-training (the five graphs and samples) are input to the classifier network f, and the classifier network f is trained on the support set S. i Five graphical data points and the initial classifier network parameters of classifier network f are used for calculation. The calculation results are input into variational generation network g embedded in classifier network f. Variational generation network g generates a first distribution of learning rate β based on the input calculation results. Classifier network f samples the first distribution to obtain the learning rate β for task i. i The classifier network f uses a learning rate β i Calculations are performed to obtain the classifier network parameters θ′ for task i. i .

[0078] Here, the initial parameters of the classifier network f can be values ​​obtained by random initialization of the classifier network parameters θ.

[0079] Step S12, based on the query set Q of task i i Sample data and classifier network parameters θ′ i Generate new variational generator network parameters And the classifier network parameters θ.

[0080] For example, combining Figure 1 In step S12, the query set Q of task i is... i Two graphical sample classifier networks f, classifier network f for query set Q i Two graphic samples and the classifier network parameters θ′ obtained in step S11 i Perform calculations and generate new variational generator network parameters based on the calculation results. And the classifier network parameters θ.

[0081] The variational generator network parameters obtained in step S12 The classifier network parameters θ are the network parameters obtained during the learning phase and serve as the initial network parameters during the testing phase. During the testing phase, a small amount of sample data from the meta-test support set is used to refine the parameters. After θ performs several updates, network parameters adapted to the test task are obtained, and category recognition is performed on the graphical data of the query set of the meta-test.

[0082] In the above embodiments, for different tasks i, a distribution of the learning rate β is generated by the variational generator network g, and the learning rate β corresponding to each task i is obtained by sampling the distribution. i In other words, by adjusting the learning rate according to different tasks—that is, adjusting the learning speed and direction—the network can be optimized quickly regardless of the initial position of the parameters, reducing the impact of small samples and cross-domain tasks on the recognition results. Instead of using a fixed learning rate, a variational generative network g is used to generate the distribution of the hyperparameter 101 of the learning rate, allowing for dynamic adjustment of the learning rate β for different tasks i. i In cross-domain few-shot learning, it can effectively enhance generalization performance, make the system more adaptable to new tasks, and improve the recognition performance of few-shot cross-domain tasks.

[0083] As an example, for task i, steps S11 and S12 are executed repeatedly (e.g., J times, where J is a positive number), and the variational generator network parameters of task i are updated repeatedly. And the classifier network parameters θ.

[0084] like Figure 3 As shown, the support set S for task i (i = 1, T) i The graphical data and the initial classifier network parameters of classifier network f are used to calculate the classifier network parameters θ′ for task i. i The steps are repeated multiple times, continuously updating the classifier network parameters θ′ related to task i. i This loop operation is called the inner loop. Through the inner loop, for each task i, the distribution of the learning rate β is generated iteratively, and this distribution is sampled multiple times to update the learning rate β corresponding to task i. i This allows for better adjustment of the learning rate β for different tasks i. i This enhances the system's domain generalization ability.

[0085] The query set Q for task i i The graphic sample data and the classifier network parameters θ′ obtained in step S11 i Generate new variational generator network parameters The steps involving classifier network parameters θ are executed repeatedly to continuously update the variational generation network parameters. And the classifier network parameters θ, this loop operation is called the outer loop. The parameters obtained after the outer loop... Furthermore, the parameter θ encompasses information from all tasks, exhibiting good few-sample recognition performance and good domain generalization ability.

[0086] This embodiment uses gradient descent for training. Specifically, in step S11, based on the support set S of task i... i Given the sample data and the initial classifier network parameters of classifier network f, calculate the objective function L for task i. Si Then calculate the objective function L. Si gradient ▽L Si , the gradient ▽L Si Input the variational generator network g, and the variational generator network g calculates the gradient ▽L based on this gradient. Si Generate the distribution of the learning rate β.

[0087] In step S12, based on the query set Q of task i i Sample data and classifier network parameters θ′ i Calculate the objective function L for task i. Qi Then calculate the objective function L. Qi gradient ▽L Qi Using gradient ▽L Qi Generate new variational generator network parameters And the classifier network parameters θ.

[0088] This embodiment is trained using the gradient descent method, and the learning rate β is generated by the variational generator network g. Compared with the prior art, this embodiment has better small sample recognition performance and domain generalization performance.

[0089] In this embodiment, based on query set Q i The objective function L for calculating task i from sample data. Qi Then calculate the objective function L. Qi gradient ▽L Qi , the gradient ▽L Qi Input the variational generator network g, and the variational generator network g calculates the gradient ▽L based on this gradient. Qi The distribution of the learning rate β is generated (hereinafter, the distribution 101 of the learning rate β calculated based on the query set is referred to as the "second distribution").

[0090] For gradient computation, the support set S i With query set Q iThe same principle applies; the first and second distributions of the learning rate β should be very close. In this embodiment, the KL distance between the first and second distributions is calculated. KL distance is short for Kullback-Leibler Divergence, also called relative entropy, used to express the degree of difference between two probability distributions. In this embodiment, the goal is to minimize the KL distance between the first and second distributions, that is, to maximize the likelihood between them, and this condition is used as a constraint to update the variational generator network parameters. And the classifier network parameters.

[0091] That is, step S12 includes the following steps:

[0092] Step 121, based on gradient ▽L Qi The variational generative network g generates a second distribution of the learning rate β.

[0093] Step 122: Calculate the KL distance between the first distribution and the second distribution, and update the variational generator network parameters by minimizing the KL distance. And the classifier network parameters θ.

[0094] The variational generator network parameters are updated using the KL distance as a constraint. Including the classifier network parameters θ, can improve generalization ability.

[0095] In this embodiment, the objective function is calculated and the network parameters are updated as follows. and θ.

[0096] For different tasks i, compute the query set Q. i The loss function L for each task i Qi The loss function L for task i Qi Adding the KL distances to task i yields the objective function L for task i. i-ELBO Calculate the objective function L for all tasks. i-ELBO The sum of these yields the overall objective function L on the query set. ELBO According to the overall objective function L ELBO Update variational generator network parameters And the classifier network parameters θ.

[0097] That is, the KL distance is added as a constraint to the overall objective function to update the variational generator network parameters. And the classifier network parameters θ, thereby improving the system's small sample recognition performance while also improving its domain generalization performance.

[0098] In this embodiment, on the query set, for the variational generation network parameters Calculate the objective function L for task i Qi gradient▽ φ L Qi According to gradient ▽ φ L Qi Used to update the variational generator network parameters For the classifier network parameters θ, calculate the objective function L for task i. Qi gradient▽ θ L Qi According to gradient ▽ θ L Qi This is used to update the classifier network parameters θ. The classifier network parameters θ and variational generator network parameters are updated in the outer loop. It covers information for all tasks i, and has good few-sample recognition performance and domain generalization ability.

[0099] The following details an embodiment of the cross-domain few-shot learning method 100 of the present invention.

[0100] In this embodiment, two network parameters need to be estimated: one is the classifier network parameter θ, and the other is the variational generation network parameter. In addition, this embodiment contains three types of gradients, one of which is based on the supporting dataset S. i Based on this, the gradient is calculated for the classifier network parameters θ. The other two are in the query set Q. i Above, regarding the parameters of the variational generator network. Calculated gradient and the gradient calculated with respect to the classifier network parameters θ These are used to update the variational generation network parameters. And the classifier network parameters θ.

[0101] First, define the learning rate β = {β i}

[0102] In the typical gradient descent method, the formula for updating from θ to θ′ is as follows:

[0103]

[0104] Where α is the learning rate.

[0105] Perform L2 regularization on it and add If the factor is added, the above equation becomes:

[0106]

[0107] Right now,

[0108] That is, the learning rate α is transformed into two parameters λ and α.

[0109] Incorporating directional control and expanding λ and α into vectors, the above equation becomes:

[0110]

[0111] in, This represents element-wise operations. In this case, the learning rate β = {β...} i} includes the parameters associated with each task i during gradient iteration, i.e., β = {β} i |γ i ,α i}

[0112] During the learning phase, the data input to the system includes: the support set S for different tasks i. i and query set Q i , inner loop count J, classifier network structure f, variational generator network structure g.

[0113] The system outputs data including: classifier network parameters θ and variational generator network parameters. These correspond to parameters λ and α, respectively.

[0114] During the learning process, follow these steps.

[0115] Step 1: Execute the following loop until convergence.

[0116] Step 2, Random Initialization Right now in These are the network parameters that generate γ. These are the network parameters that generate α.

[0117] Step 3: For task i, iterate, i = 1: T, and specifically perform the following steps.

[0118] Step 3.1, randomly initialize θ i,1 , where i is the task index and 1 represents the initial value of the first iteration;

[0119] Step 3.2, for the inner loop iterations j = 1: J-1, execute:

[0120] Step 3.2.1, for the support set S i Calculate the cross-entropy loss function using the data. as follows:

[0121]

[0122] Where x represents the input support set Si Sample data, where y represents the category label of x.

[0123] Step 3.2.2, calculate the intermediate variable d. i,j as follows:

[0124]

[0125] Step 3.2.3: The variational generator network g generates the mean and variance of the distribution 101 (i.e., the first distribution, assumed to be Gaussian) corresponding to γ ​​and α respectively, as follows:

[0126]

[0127] in,

[0128] Step 3.2.4, for query set Q i Calculate the cross-entropy loss function using the data. as follows:

[0129]

[0130] Where x represents the input query set Q i The sample data is y, where y represents the category label of x.

[0131] Step 3.2.5, calculate the intermediate variable d. i,j 'as follows:

[0132]

[0133] Step 3.2.6: The variational generator network g generates the mean and variance of the distribution 101 (i.e., the second distribution, assumed to be Gaussian) corresponding to γ ​​and α respectively, as follows:

[0134]

[0135] Step 3.2.7: Calculate the KL distance between the first distribution of the support set and the second distribution of the query set in the j-th iteration. as follows:

[0136]

[0137] Step 3.2.8, obtain γ by sampling from the first distribution. i,j α i,j The parameter θ is generated according to the iterative formula of the gradient descent method. i,j+1 :

[0138]

[0139] Step 3.3, let θ′ i=θ i,J .

[0140] That is, the result of the last step (step J) of the inner loop is used as the updated classifier network parameters θ′ related to task i. i .

[0141] Step 3.4, calculate the loss function for task i on the query set. as follows:

[0142]

[0143] Step 3.5, calculate the overall objective function of task i. as follows:

[0144]

[0145] Step 4, calculate the overall objective function for all tasks as follows:

[0146]

[0147] Step 5, update the network parameters as follows:

[0148]

[0149] In summary, the cross-domain few-shot learning method 100 of the present invention addresses both few-shot learning and cross-domain sample problems. It utilizes the variational generator network g to generate the distribution of the hyperparameter of the learning rate, and selects the learning rate corresponding to the task through sampling, rather than using a fixed learning rate, thereby enhancing the domain generalization performance of the model. At the same time, it can solve the few-shot problem and achieve two-layer optimization.

[0150] Figure 4 This is a schematic diagram of the structure of a cross-domain few-shot learning system 10 according to an embodiment of the present invention.

[0151] like Figure 4 As shown, a cross-domain few-shot learning system 10 according to an embodiment of the present invention includes a variational generative network unit and a classifier network unit. The classifier network unit receives the support set S of task i. i Based on the sample data, the variational generator network unit uses the support set S for task i. i Using the sample data and the initial classifier network parameters of the classifier network unit, a first distribution of the learning rate β is generated. The classifier network unit samples from the first distribution to obtain the learning rate β for task i. i The classifier network unit utilizes the learning rate β i Obtain the classifier network parameters θ′ for task i i The classifier network unit receives the query set Q of task i. iThe sample data, based on the query set Q of task i i Sample data and classifier network parameters θ′ i Generate new variational generator network parameters And the classifier network parameters θ.

[0152] As an example, the classifier network unit is based on the support set S of task i. i Given the sample data and the initial classifier network parameters of the classifier network units, calculate the objective function L for task i. Si gradient ▽L Si The variational generator network unit is based on this gradient ▽L Si Generate the first distribution of the learning rate β; the classifier network unit is based on the query set Q of task i. i Sample data and classifier network parameters θ′ i Calculate the objective function L for task i. Qi gradient ▽L Qi According to gradient ▽L Qi Generate new variational generator network parameters And the classifier network parameters θ.

[0153] As an example, the variational generative network unit is based on the gradient ▽L Qi A second distribution with learning rate β is generated. The classifier network unit calculates the KL distance between the first and second distributions. By minimizing the KL distance, the variational generator network parameters are updated. And the classifier network parameters θ.

[0154] As an example, the classifier network unit computes the query set Q. i The loss function L for each task i Qi The loss function L for task i Qi Adding the KL distances to task i yields the objective function L for task i. i-ELBO Calculate the objective function L for all tasks. i-ELBO The sum of these yields the overall objective function L. ELBO According to the overall objective function L ELBO Update variational generator network parameters And the classifier network parameters θ.

[0155] As an example, the classifier network unit is based on the variational generator network parameters. Calculate the objective function L for task i Qi gradient▽ φ L Qi According to gradient ▽ φ L Qi Generate new variational generator network parameters And for the classifier network parameters θ, calculate the objective function L for task i. Qi gradient▽ θ L Qi According to gradient ▽ θ L Qi Generate new classifier network parameters θ.

[0156] The electronic device of this application embodiment includes one or more processors and a memory. The memory stores one or more computer programs. When one or more processors execute one or more computer programs, the cross-domain few-shot learning method 100 described in any one of the embodiments of this application is implemented.

[0157] The computer-readable storage medium of this application embodiment stores a computer program, which, when executed by a processor, implements the cross-domain few-shot learning method 100 described in any one of the embodiments of this application.

[0158] The above embodiments are merely illustrative of the technical solutions of this application and are not intended to limit them. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing embodiments or replace some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application, and all should fall within the protection scope of this invention. In particular, as long as there is no structural conflict, the various technical features mentioned in the embodiments can be combined in any way. This invention is not limited to the specific embodiments disclosed herein, but includes all technical solutions falling within the scope of the claims.

Claims

1. A method for image classification based on cross-domain few-shot learning, characterized in that, a training sample set contains a plurality of samples, each sample being a task, in which task, according to the samples in the support set in the task, the samples in the query set in the task are identified, and the sample data of the training sample set, the support set and the query set are graphic data, the method comprising the following steps: Step S11, according to the support set S of the task i i and the initial classifier network parameters of the classifier network f of the sample data, the variational generation network g generates a first distribution of the learning rate β, samples the first distribution to obtain the learning rate β of the task i i , and uses the learning rate β i to obtain the classifier network parameters θ i ′ of the task i; Step S12, according to the query set Q of task i i Sample data and classifier network parameters θ i of task i, calculate the gradient of the objective function L Qi of task i According to the gradient The second distribution of learning rate β is generated by the variational generation network g, the KL distance between the first distribution and the second distribution is calculated, and the new variational generation network parameters And the classifier network parameters θ are generated by minimizing the KL distance.

2. The method for image classification based on cross-domain few-shot learning according to claim 1, characterized in that, For task i, the steps S11, S12 are repeatedly performed for a predetermined number of times J, and the variational generation network parameters of task i are updated multiple times and the classifier network parameters θ.

3. The method for image classification based on cross-domain few-shot learning according to claim 1, characterized in that, In step S11, a gradient of the objective function L i of task i is calculated according to the sample data and the initial classifier network parameters θ0 of the classifier network f of task i Si According to the gradient The first distribution of learning rate β is generated by the variational generation network g.​ 4. The method for image classification based on cross-domain few-shot learning according to claim 3, characterized in that, For different tasks i, compute query set Q i Loss function L for each task i Qi , The loss function L for task i Qi Adding the KL distances to task i yields the objective function L for task i. i-ELBO Calculate the objective function L for all tasks. i-ELBO The sum of these yields the overall objective function L on the query set. ELBO According to the overall objective function L ELBO Update variational generator network parameters And the classifier network parameters θ.

5. The method for image classification based on cross-domain few-shot learning according to claim 1, characterized in that, in step S12, for the variational generative network parameters a target function L for the computational task i Qi a gradient according to the gradient generating new variational generative network parameters For the classifier network parameters θ, the objective function L for task i is computed Qi the gradient According to the gradient The new classifier network parameters θ are generated.

6. An image classification system based on cross-domain few-shot learning, characterized in that, comprising: a variational generative network unit, and a classifier network unit that receives support set S of sample data for task i i of sample data for task i The variational generative network unit generates a first distribution of learning rates β according to the support set S of the task i and the initial classifier network parameters of the classifier network unit, i sample data of the task i and the initial classifier network parameters of the classifier network unit, The classifier network unit samples the first distribution to obtain a learning rate β of task i i , The classifier network unit utilizes the learning rate β i Obtain the classifier network parameters θ' i of task i; The classifier network unit receives a query set Q i of sample data according to the query set Q i of sample data of the task i and the classifier network parameters θ i ', calculates the gradient of the objective function L Qi of the task i the variational generative network unit generates the second distribution of learning rate β according to the gradient the variational generative network unit generates the second distribution of learning rate β according to the gradient the classifier network unit computes a KL distance between the first distribution and the second distribution, generates new variational generative network parameters by minimizing the KL distance and classifier network parameters θ; wherein the support set S i and the query set Q i The sample data is graph data.

7. The system for image classification based on cross-domain few-shot learning according to claim 6, characterized in that, The classifier network unit computes a gradient of the objective function L i for task i based on the sample data and the initial classifier network parameters of the classifier network unit Si for task i The variational generative network unit generates the first distribution of the learning rate β according to the gradient generates a first distribution of a learning rate β.

8. The system for image classification based on cross-domain few-shot learning according to claim 7, characterized in that, The classifier network unit calculates a query set Q i The loss function L of each task i Qi The loss function L of task i is calculated Qi The KL distance of task i is added to obtain the target function L of task i i-ELBO The target function L of all tasks is calculated i-ELBO The sum is the overall target function L ELBO According to the overall target function L ELBO Update the variational generation network parameters And the classifier network parameters θ.

9. The system for image classification based on cross-domain few-shot learning according to claim 6, characterized in that, the classifier network unit for the variational generative network parameters a target function L for the computational task i Qi a gradient of a new variational generative network parameter according to the gradient a new variational generative network parameter according to the gradient And for the classifier network parameters θ, the gradient of the objective function L of task i is calculated Qi According to the gradient The new classifier network parameters θ are generated.​ 10. An electronic device, comprising: comprising one or more processors and memories, the memories having one or more computer programs stored thereon, and when the one or more processors execute the one or more computer programs, the method for image classification based on cross-domain few-shot learning according to any one of claims 1-5 is implemented.

11. A computer readable storage medium, characterized in that, The computer readable storage medium has a computer program stored therein, and the computer program is run by a processor to implement the method for image classification based on cross-domain few-shot learning according to any one of claims 1-5.