Domain generalization method based on model sample matching
Through linear label space transformation and model feature matching network, the pre-trained model is dynamically recommended to adapt to the target domain, which solves the problem of tedious identification process of form-changing recognition objects, improves the adaptability and generalization ability of the model, and achieves more stable predictions. performance.
Patent Information
- Application Number
- CN202410988490.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-23
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2044-07-23
AI Technical Summary
When the existing technology handles recognition objects that change in form, new data sets need to be prepared, resulting in a cumbersome process, and the data set preparation process between the source domain and target domain data sets is inflexible.
Through linear label space transformation and matching network of model characteristics, the pre-trained model is dynamically recommended to adapt to the target domain, and the convergence stability of the model is improved through the loss function to achieve domain generalization.
It improves the adaptability and generalization ability of the pre-trained model, enhances the prediction performance of the model on unknown samples, and improves the convergence stability of the model.
Smart Images

Figure CN118779669A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of pattern recognition and computer vision, and in particular relates to a domain generalization method based on model sample matching. Background Art
[0002] The development of artificial intelligence has greatly changed the pace of life and lifestyle of modern people, among which neural networks have received more and more attention. At present, most neural networks rely on training on large data sets to obtain a model for various tasks. However, in some tasks, the object to be identified remains unchanged, but the form of expression changes. For example, a real car and a car in a painting are both cars but in different forms. At this time, if there is a data set of one type and you want to identify another form, you need to prepare another data set, which is a cumbersome process. Therefore, the domain generalization method came into being. Domain generalization can predict the target domain data set when there is only a source domain data set and a small amount of target domain data, thereby reducing the intermediate data set preparation process and increasing the flexibility of application. Summary of the invention
[0003] Therefore, in response to actual needs and gaps in the prior art, the present invention provides a domain generalization method based on model sample matching, which can effectively solve the domain generalization problem.
[0004] The technical solution specifically adopted by the present invention to solve the technical problem is:
[0005] A domain generalization method based on model sample matching includes the following steps:
[0006] Step S1: Obtain a dataset and adapt the predictions of the pre-trained model to the target domain through a linear label space transformation;
[0007] Step S2: Dynamically recommend a pre-trained model to predict each test sample through a matching network of model characteristics;
[0008] Step S3: Improve the stability of model convergence through the loss function.
[0009] Furthermore, step S1 specifically includes the following steps:
[0010] Step S11: Obtain a public domain adaptive image dataset and obtain relevant annotations of the training data;
[0011] Step S12: Use a label space adapter to make the label space shared by the source and target domains consistent; the adapter is a linear mapping between the two label spaces: pre-trained → source / target.
[0012] Further, in step S12, given the pre-trained model f k, and the adaptive model h φ ; Through the label adapter, pre-trained model f k The output of is transformed and adapted to the target domain as follows:
[0013] y ik =h φ (f k (x i ))
[0014] where x i represents the i-th sample, y ik represents the prediction of the i-th sample output by the k-th model.
[0015] Furthermore, step S2 specifically includes the following steps:
[0016] Step S21: define a model scheduler with parameter p and sample x i As input, and determine the assignment to sample x i Model f k The weight w k ,in Among them, w k Represents the model f in the model pool k The relative match between the samples is estimated; based on the constructed model pool and model scheduler, the prediction of each test sample is a collection of the predictions of the scheduling model; the final prediction y' i The calculation method is:
[0017]
[0018] The final loss function L D The calculation method of (φ,p) is as follows:
[0019]
[0020] Where φ represents the parameters of the adaptive model, and D represents the total number of samples;
[0021] Step S22: Using the neural collaborative filtering recommendation algorithm, the matching score m i =[m i1 ,…,m ik ]∈R K , m ik Represents the prediction of the i-th sample output by the k-th model: sample x i and Model According to the potential features c={c1,…,c K} is calculated, where K represents the number of models; the samples and models are first embedded and then converted to a joint latent space; a pre-trained model from the model pool The feature extractor for the sample x i Generate sample embedding e i ; For each model f k embedding, introducing learnable embedding e k , fitness matching scoring is performed by mapping to the same space;
[0022] Step S23: After constructing a series of ranking models according to the matching metric; normalizing the matching scores through the Softmax function; and further selecting the models with the highest matching scores before inferring the given sample.
[0023] Furthermore, step S3 specifically includes the following steps:
[0024] The loss L learned by ensemble ens Update matching network and adapter:
[0025] L ens (φ,p)=l(y′ i ,y i )
[0026] Compute the loss L for label space adapter learning ada :
[0027]
[0028] where w k represents the weight of the k-th model;
[0029] The total loss L that needs to be minimized is defined as follows:
[0030] L=L ens (φ,p)+L ada (φ).
[0031] And, an electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of a domain generalization method based on model sample matching as described above are implemented.
[0032] A non-transitory computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of a domain generalization method based on model sample matching as described above.
[0033] Compared with the prior art, the present invention and its preferred embodiments have at least the following outstanding effects:
[0034] 1. It can improve the adaptability of the pre-trained model, adapt the prediction of the pre-trained model to the target domain through linear label space transformation, and improve the generalization ability of the model.
[0035] 2. It can improve the model's ability to adaptively predict samples, by dynamically recommending appropriate pre-trained models to predict each test sample, thereby improving the model's prediction performance on unknown samples;
[0036] 3. It can improve the convergence stability of the model. The model sample matching learning loss function improves the stability of model convergence. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] The present invention is further described in detail below with reference to the accompanying drawings and specific embodiments:
[0038] Figure 1 The figure is a flow chart of a method according to an embodiment of the present invention. DETAILED DESCRIPTION
[0039] In order to make the features and advantages of this patent more obvious and easy to understand, the following embodiments are specifically described in detail as follows:
[0040] It should be noted that the following detailed descriptions are illustrative and are intended to provide further explanation of the present application. Unless otherwise specified, all technical and scientific terms used in this specification have the same meanings as those commonly understood by those skilled in the art to which the present application belongs.
[0041] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit the exemplary embodiments according to the present application. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that when the terms "comprise" and / or "include" are used in this specification, it indicates the presence of features, steps, operations, devices, components and / or combinations thereof.
[0042] like Figure 1 As shown, this embodiment provides a domain generalization method based on model sample matching, comprising the following steps:
[0043] Step S1: Obtain a dataset and adapt the predictions of the pre-trained model to the target domain via a linear label space transformation.
[0044] In this embodiment, step S1 specifically includes the following steps:
[0045] Step S11: Obtain a public domain adaptive image dataset, office-31 dataset, from the Internet, and obtain relevant annotations of the training data;
[0046] Step S12: Use a label space adapter to make the label space shared by the source and target domains consistent. The adapter is a linear mapping between the two label spaces (pre-trained → source / target). Specifically, given a pre-trained model f k, and the adaptive model h φ . Through the label adapter, the pre-trained model f k The output of can be transformed and adapted to the target domain as follows:
[0047] y ik =h φ (f k (x i ))
[0048] where x i represents the i-th sample, y ik represents the prediction of the i-th sample output by the k-th model.
[0049] Step S2: Dynamically recommend an appropriate pre-trained model to predict each test sample through a matching network of model characteristics.
[0050] In this embodiment, step S2 specifically includes the following steps:
[0051] Step S21: Define a model scheduler with parameter p, which takes samples x i As input, and determine the assignment to sample x i Model f k The weight w k ,in Here k Represents the model f in the model pool k An estimate of the relative match between the samples. Based on the constructed model pool and model scheduler, the prediction of each test sample is a collection of the predictions of the scheduling model. The final prediction y' i The calculation method is:
[0052]
[0053] The final loss function L D The calculation method of (φ,p) is as follows:
[0054]
[0055] Where φ represents the parameters of the adaptive model and D represents the total number of samples.
[0056] Step S22: Using the neural collaborative filtering recommendation algorithm, the matching score m i =[m i1 ,…,m ik ]∈R K , m ik represents the prediction of the i-th sample output by the k-th model. Sample x i and Model It is based on its potential characteristics c = {c1,…,cK}, where K represents the number of models. First, the sample and model are embedded, and then transformed into a joint latent space. A pre-trained model from the model pool The feature extractor for the sample x i Generate sample embedding e i For each model f k The embedding of k , by mapping to the same space for fitness matching scoring.
[0057] Step S23: After constructing a series of ranking models according to the matching metric, the matching scores are normalized by the Softmax function. Before inference is performed on a given sample, the models with the highest 5 matching scores are further selected.
[0058] Step S3: Improve the stability of model convergence through the loss function.
[0059] In this embodiment, step S3 specifically includes the following steps:
[0060] The loss L learned by ensemble ens Update matching network and adapter:
[0061] L ens (φ,p)=l(y′ i ,y i )
[0062] Compute the loss L for label space adapter learning ada :
[0063]
[0064] where w k represents the weight of the k-th model;
[0065] The total loss L to be minimized is defined as follows:
[0066] L=L ens (φ,p)+L ada (φ).
[0067] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0068] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0069] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0070] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0071] It should be noted that, unless otherwise defined, the technical terms or scientific terms used in the present invention should be understood by people with ordinary skills in the field to which the present invention belongs. The "first", "second" and similar words used in the present invention do not indicate any order, quantity or importance, but are only used to distinguish different components. "Include" or "comprise" and similar words mean that the elements or objects appearing before the word include the elements or objects listed after the word and their equivalents, without excluding other elements or objects. "Connect" or "connected" and similar words are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. "Up", "down", "left", "right" and the like are only used to indicate relative positional relationships. When the absolute position of the described object changes, the relative positional relationship may also change accordingly.
[0072] The above is only a preferred embodiment of the present invention, and does not limit the present invention in other forms. Any technician familiar with the profession may use the above disclosed technical content to change or modify it into an equivalent embodiment with equivalent changes. However, any simple modification, equivalent change and modification made to the above embodiment according to the technical essence of the present invention without departing from the technical solution of the present invention still belongs to the protection scope of the technical solution of the present invention.
[0073] This patent is not limited to the above-mentioned optimal implementation mode. Anyone can derive other forms of a domain generalization method based on model sample matching under the inspiration of this patent. All equal changes and modifications made according to the scope of the patent application of the present invention should be covered by this patent.
Claims
1. A domain generalization method based on model sample matching, characterized in that: The following steps are involved: Step S1: Obtain a dataset and adapt the predictions of the pre-trained model to the target domain through a linear label space transformation; Step S2: Dynamically recommend a pre-trained model to predict each test sample through a matching network of model characteristics; Step S3: Improve the stability of model convergence through the loss function.
2. The domain generalization method based on model sample matching according to claim 1, characterized in that: Step S1 specifically includes the following steps: Step S11: Obtain a public domain adaptive image dataset and obtain relevant annotations of the training data; Step S12: Use a label space adapter to make the label space shared by the source and target domains consistent; the adapter is a linear mapping between the two label spaces: pre-trained → source / target.
3. The domain generalization method based on model sample matching according to claim 2, characterized in that: In step S12, given the pre-trained model f k , and the adaptive model h φ ; Through the label adapter, pre-trained model f k The output of is transformed and adapted to the target domain as follows: y ik =h φ (f k (x i )) where x i represents the i-th sample, y ik represents the prediction of the i-th sample output by the k-th model.
4. The domain generalization method based on model sample matching according to claim 3, characterized in that: Step S2 specifically includes the following steps: Step S21: define a model scheduler parameter p, with sample x i As input, and determine the assignment to sample x i Model f k The weight w k ,in Among them, w k Represents the model f in the model pool k The relative match between the samples is estimated; based on the constructed model pool and model scheduler, the prediction of each test sample is a collection of the predictions of the scheduling model; the final prediction y' i The calculation method is: The final loss function L D The calculation method of (φ,p) is as follows: Where φ represents the parameters of the adaptive model, and D represents the total number of samples; Step S22: Using the neural collaborative filtering recommendation algorithm, the matching score m i =[m i1 ,…,m ik ]∈R K , m ik Represents the prediction of the i-th sample output by the k-th model: sample x i and Model According to the potential features c={c1,…,c K } is calculated, where K represents the number of models; the samples and models are first embedded and then converted to a joint latent space; a pre-trained model from the model pool The feature extractor for the sample x i Generate sample embedding e i ; For each model f k embedding, introducing learnable embedding e k , fitness matching scoring is performed by mapping to the same space; Step S23: After constructing a series of ranking models according to the matching metric; normalizing the matching scores through the Softmax function; and further selecting the models with the highest matching scores before inferring the given sample.
5. The domain generalization method based on model sample matching according to claim 4, characterized in that: Step S3 specifically includes the following steps: The loss L learned by ensemble ens Update matching network and adapter: L ens (φ,p)=l(y' i ,y i ) Compute the loss L for label space adapter learning ada : where w k represents the weight of the k-th model; The total loss L that needs to be minimized is defined as follows: L=L ens (φ,p)+L ada (f)。 6. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps of a domain generalization method based on model sample matching as described in any one of claims 1 to 5 are implemented.
7. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of a domain generalization method based on model sample matching as described in any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
Unsupervised domain adaptive method based on adversarial residual error transform network
CN111191686A
Universal domain generalization method
CN116882456A
Data generalization for predictive models
US20210042629A1
