A sparse domain generalization method and device based on meta-adaptive task sampling

The sparse domain generalization method based on meta-adaptive task sampling utilizes the semantic similarity and domain offset similarity of the basic task for adaptive sampling and pre-training, which solves the problem of low recognition accuracy of machine learning models in unknown target domains and achieves efficient distributional out-generalization under finite training domains.

CN122634261APending Publication Date: 2026-08-25TSINGHUA UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611032393.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-13
Publication Date
2026-08-25

AI Technical Summary

Technical Problem

Existing machine learning models struggle to maintain high recognition accuracy in unknown target domains when training and testing data do not satisfy independent and identically distributed conditions. This is especially true in scenarios with high data acquisition costs, strict privacy protection requirements, limited annotation resources, or scarce domain labels, where existing domain generalization methods are unable to effectively improve the model's out-of-distribution generalization ability.

Method used

A sparse domain generalization method based on meta-adaptive task sampling is adopted. By obtaining the prediction model of the basic task, training and calculating the loss function using the source domain dataset, and combining the meta-test loss for model optimization, semantic similarity and domain offset similarity are calculated, adaptive sampling and pre-training are performed, and finally fine-tuning is performed on the source domain dataset of the new task to obtain the final prediction model of the new task.

Benefits of technology

When the number of training domains is limited and target domain data is unavailable, the model significantly improves the out-of-distribution generalization performance, enhances the model's recognition accuracy and stability in unknown target domains, and is applicable to scenarios such as visual recognition, medical image recognition, industrial visual inspection, and remote sensing target recognition.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122634261A_ABST
    Figure CN122634261A_ABST
Patent Text Reader

Abstract

The application provides a sparse field generalization method and device based on meta-adaptive task sampling, which comprises the following steps: training corresponding prediction models by using a basic task source domain data set to obtain a source domain loss function value, calculating a meta test loss on a basic task target domain, and then obtaining model parameters of the basic task through joint optimization; based on the model parameters, calculating the overall similarity between the basic task and a new task; after adaptive sampling of the basic task according to the overall similarity, pre-training prediction models of each basic task; after pre-training, based on a feature extractor shared by each prediction model and an initialized new task classifier, fine-tuning a new task prediction model on a new task source domain data set to obtain a final model. The application significantly improves the out-of-distribution generalization performance of the model under the condition of a sparse field, improves the basic task knowledge transfer efficiency, and does not depend on target domain data, and is suitable for generalization and application of various classification tasks.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of artificial intelligence and deep learning technology, and specifically relates to a sparse domain generalization method and apparatus based on meta-adaptive task sampling. Background Technology

[0002] Existing machine learning models typically rely on the assumption that training and test data are independently and identically distributed. However, in practical technical scenarios such as visual recognition, medical image recognition, industrial quality inspection, and remote sensing image recognition, the data that can be collected during the training phase often only covers a limited range of imaging equipment, shooting environments, image styles, or production conditions. When the model is deployed to new equipment, hospitals, sensors, lighting conditions, background environments, or image styles, the distribution of input data will change significantly relative to the training data, leading to a significant decrease in the model's recognition accuracy in unknown target domains. For example, in image classification tasks, the model may have only seen training images of real photographs and painting styles, but deployment requires recognizing line drawings, cartoon images, low-light images, or new images from new cameras. In medical imaging scenarios, different hospitals, different scanners, or different scanning protocols can cause differences in image distribution, and the data from the target hospital may not be available in advance due to privacy, annotation costs, or collection cycle limitations.

[0003] Domain generalization techniques aim to improve model performance on unknown target domains through training in multiple domains. However, existing methods typically rely on a large number and variety of training domains, which is difficult to achieve in scenarios with high data acquisition costs, strict privacy requirements, limited annotation resources, or scarce domain labels. In recent years, although generalization research based on single or few domains has emerged, models still struggle to learn stable and transferable representations due to limited observable heterogeneity. Therefore, effectively improving the out-of-distribution generalization ability of models under conditions of extremely limited training domains and inability to use target domain data remains a pressing technical problem. Summary of the Invention

[0004] The purpose of this invention is to overcome the shortcomings of existing technologies and propose a sparse domain generalization method and apparatus based on meta-adaptive task sampling. This invention can improve the classification accuracy and stability of the model in unknown target domains, reduce dependence on large amounts of multi-source training and target domain data, improve the efficiency of historical task knowledge transfer, and make the model more suitable for practical scenarios such as medical image recognition, industrial visual inspection, remote sensing target recognition, and smart terminal visual recognition, where training data acquisition costs are high or domain labels are scarce.

[0005] A first aspect of this invention proposes a sparse domain generalization method based on meta-adaptive task sampling, comprising:

[0006] Obtain prediction models for each basic task; wherein, the prediction model includes: a task classifier corresponding to the basic task, and a feature extractor shared by all basic tasks and new tasks;

[0007] In the meta-training phase, the prediction model corresponding to the basic task is trained using the source domain dataset of the basic task to obtain the updated model parameters and calculate the source domain loss function value.

[0008] During the meta-testing phase, the updated model parameters are used to calculate the meta-testing loss in the target domain of the basic task.

[0009] By jointly optimizing the source domain loss function value and the meta-test loss, the optimized model parameters corresponding to the basic task are obtained.

[0010] Based on the feature extractor parameters in the optimized model parameters corresponding to the basic task, the semantic vector of the source domain of the basic task, the semantic vector of the target domain of the basic task, and the semantic vector of the overall source domain of the new task are calculated to obtain the semantic similarity between the basic task and the new task, as well as the domain offset similarity between the basic task and the new task. The semantic similarity and the domain offset similarity are weighted and summed to obtain the overall similarity between the basic task and the new task.

[0011] Adaptive sampling is performed on the basic task for predictive model pre-training based on the overall similarity; wherein, in each round of pre-training, the parameters of the corresponding predictive model are updated using the sampled basic task; after pre-training is completed, the pre-trained feature extractor is obtained.

[0012] Using the pre-trained feature extractor and the re-initialized new task classifier, the new task prediction model is fine-tuned on the source domain dataset of the new task to obtain the final new task prediction model.

[0013] In one specific embodiment of the present invention, it further includes:

[0014] During the meta-training phase, the first... Source domain datasets for each basic task Predictive model for this basic task Update model parameters ;in, These are the parameters for the feature extractor. For the task classifier parameters of the m-th basic task;

[0015] parameter The source domain is updated using the following loss function:

[0016]

[0017] in, Represents the source domain dataset The number of source domains in Indicates the first The number of samples in each source domain; Indicates the first In the source domain, the first Input data for each sample; Indicates the first In the source domain, the first The category labels corresponding to each sample; Representation Model For source domain samples The output prediction result; ℓ(·,·) represents the classification loss function.

[0018] In one specific embodiment of the present invention, it further includes:

[0019] During the meta-testing phase, the updated model parameters are used. Calculate the meta-test loss over the target domain:

[0020]

[0021] in, Represents the target domain dataset The number of target domains in the data; Let be the sample size of the k-th target domain. , These are the input data and corresponding category label of the j-th sample in the k-th target domain, respectively; Indicates the use of model parameters The next Predictive models for basic tasks; Representation Model For target domain samples The output prediction results;

[0022] The inner learning rate for meta-training; Represents the source domain loss function Regarding the first Basic task model parameters The gradient; This represents the first [unit / type] obtained after training based on the source domain. The model parameters after updating the basic tasks.

[0023] In one specific embodiment of the present invention, it further includes:

[0024] The objective function expression for the joint optimization is as follows:

[0025]

[0026] in, Hyperparameters used to control the ratio of meta-training to meta-testing.

[0027] In one specific embodiment of the present invention, it further includes:

[0028] The semantic vector calculation expression for the basic task source domain is as follows:

[0029]

[0030] in, Indicates the first The first basic task The average feature representation of each source domain Indicates a shared feature extractor; Indicates the first The overall task-level semantic representation of the source domain of each basic task;

[0031] The semantic vector calculation expression for the basic task target domain is as follows:

[0032]

[0033] in, Indicates the first The first basic task Average feature representation of each target domain; Indicates the first The overall task-level semantic representation of the basic task target domain;

[0034] The semantic vector calculation expression for the entire source domain of the new task is as follows:

[0035]

[0036]

[0037] in, Indicates the new task number The number of samples in each source domain; Indicates the new task number The first in the source domain Input data for each sample; Indicates a new task No. Average feature representation of each source domain; Indicates a new task The number of source domains; Indicates a new task Task-level semantic representation of the entire source domain.

[0038] In one specific embodiment of the present invention, it further includes:

[0039] The semantic similarity calculation expression between the basic task and the new task is as follows:

[0040]

[0041] in, Indicates cosine similarity; Indicates the first Semantic similarity between basic tasks and new tasks;

[0042] The expression for calculating the domain offset similarity between the basic task and the new task is as follows:

[0043]

[0044] in, This indicates the direction of the domain offset observed between the two source domains of the new task; Indicates the first The domain offset direction of each basic task from the source domain to the target domain; Indicates the domain offset pattern between the new task source domains and the first The maximum similarity between the offset patterns of the source domain to the target domain of each basic task;

[0045] The expression for calculating the overall similarity between the basic task and the new task is as follows:

[0046]

[0047] in, is a weighting coefficient used to control the weight of domain offset similarity in the overall similarity.

[0048] In one specific embodiment of the present invention, it further includes:

[0049] During the adaptive sampling, the basic task The sampling probability is:

[0050]

[0051] Where M is the number of basic tasks; Indicates the first The probability of each basic task being sampled during pre-training.

[0052] A second aspect of the present invention provides a sparse domain generalization device based on meta-adaptive task sampling, comprising:

[0053] The basic task prediction model acquisition module is used to acquire prediction models for each basic task; wherein, the prediction model includes: a task classifier corresponding to the basic task, and a feature extractor shared by all basic tasks and new tasks;

[0054] The meta-training module is used to train the corresponding prediction model using the source domain dataset of the basic task during the meta-training phase, obtain the updated model parameters, and calculate the source domain loss function value.

[0055] The meta-testing module is used to calculate the meta-testing loss on the target domain of the basic task using the updated model parameters during the meta-testing phase.

[0056] The basic task model parameter optimization module is used to obtain the optimized model parameters corresponding to the basic task by jointly optimizing the source domain loss function value and the meta-test loss.

[0057] The overall similarity calculation module is used to calculate the semantic vector of the source domain of the basic task, the semantic vector of the target domain of the basic task, and the semantic vector of the overall source domain of the new task based on the feature extractor parameters in the optimized model parameters corresponding to the basic task, thereby obtaining the semantic similarity between the basic task and the new task and the domain offset similarity between the basic task and the new task; the semantic similarity and the domain offset similarity are weighted and summed to obtain the overall similarity between the basic task and the new task;

[0058] An adaptive sampling module is used to perform adaptive sampling of the basic task for predictive model pre-training based on the overall similarity; wherein, in each round of pre-training, the parameters of the corresponding predictive model are updated using the sampled basic task; after pre-training is completed, the pre-trained feature extractor is obtained.

[0059] The new task prediction model fine-tuning module is used to fine-tune the new task prediction model on the source domain dataset of the new task using the pre-trained feature extractor and the re-initialized new task classifier, so as to obtain the final new task prediction model.

[0060] A third aspect of the present invention provides an electronic device comprising:

[0061] At least one processor; and a memory communicatively connected to said at least one processor;

[0062] The memory stores instructions that can be executed by the at least one processor, and the instructions are configured to execute the above-described sparse domain generalization method based on meta-adaptive task sampling.

[0063] A fourth aspect of the present invention provides a computer-readable storage medium storing computer instructions for causing the computer to execute the above-described sparse domain generalization method based on meta-adaptive task sampling.

[0064] Features and beneficial effects of the present invention:

[0065] This invention addresses visual classification and other pattern recognition scenarios where the number of training domains is limited and target domain data is unavailable. It introduces historical tasks as a base task and adaptively samples the base task based on semantic and domain shift similarities between the base and new tasks. This allows the model to prioritize utilizing historical task experience more relevant to the new task during pre-training, learning more robust feature representations to domain shifts. Subsequently, the pre-trained model is fine-tuned using a small amount of source domain data from the new task, resulting in a final prediction model suitable for the unknown target domain of the new task. This invention solves the problems of limited training domains, unavailability of target domain data in advance, and decreased model accuracy due to different acquisition environments or image styles in target application scenarios. Its specific advantages are as follows:

[0066] 1) It can still significantly improve the model's out-of-distribution generalization performance even with a very small number of training domains.

[0067] 2) Improve the efficiency and relevance of basic task knowledge transfer through an adaptive task sampling mechanism.

[0068] 3) It does not depend on the target domain data of new tasks, and is suitable for situations where the target domain is unavailable in real-world scenarios.

[0069] 4) The method is highly versatile and can be applied to various visual or other modal classification tasks.

[0070] 5) This invention can alleviate the domain shift problem caused by differences in equipment, shooting environment, image style, sensor, or production conditions in specific visual recognition or pattern recognition scenarios. It can improve the model's recognition accuracy of unknown target domains without using new task target domain data, and has high engineering deployment value. Attached Figure Description

[0071] Figure 1 This is a flowchart of a sparse domain generalization method based on meta-adaptive task sampling, according to an embodiment of the present invention. Detailed Implementation

[0072] This invention proposes a sparse domain generalization method and apparatus based on meta-adaptive task sampling. The invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0073] The first aspect of this invention proposes a sparse domain generalization method based on meta-adaptive task sampling, the overall process of which is as follows: Figure 1 As shown, it includes:

[0074] Obtain prediction models for each basic task; wherein, the prediction model includes: a task classifier corresponding to the basic task, and a feature extractor shared by all basic tasks and new tasks;

[0075] In the meta-training phase, the prediction model corresponding to the basic task is trained using the source domain dataset of the basic task to obtain the updated model parameters and calculate the source domain loss function value.

[0076] During the meta-testing phase, the updated model parameters are used to calculate the meta-testing loss in the target domain of the basic task.

[0077] By jointly optimizing the source domain loss function value and the meta-test loss, the optimized model parameters corresponding to the basic task are obtained.

[0078] Based on the feature extractor parameters in the optimized model parameters corresponding to the basic task, the semantic vector of the source domain of the basic task, the semantic vector of the target domain of the basic task, and the semantic vector of the overall source domain of the new task are calculated to obtain the semantic similarity between the basic task and the new task, as well as the domain offset similarity between the basic task and the new task. The semantic similarity and the domain offset similarity are weighted and summed to obtain the overall similarity between the basic task and the new task.

[0079] Adaptive sampling is performed on the basic task for predictive model pre-training based on the overall similarity; wherein, in each round of pre-training, the parameters of the corresponding predictive model are updated using the sampled basic task; after pre-training is completed, the pre-trained feature extractor is obtained.

[0080] Using the pre-trained feature extractor and the re-initialized new task classifier, the new task prediction model is fine-tuned on the source domain dataset of the new task to obtain the final new task prediction model.

[0081] In a specific embodiment of the present invention, the sparse domain generalization method based on meta-adaptive task sampling includes the following steps:

[0082] 1) Obtain the prediction model for each basic task; wherein the prediction model includes: a task classifier corresponding to the basic task and a feature extractor shared by all basic tasks and new tasks.

[0083] In this embodiment, let the prediction model for the m-th basic task be denoted as... ,in As a feature extractor, it can be shared across tasks. For the task classifier corresponding to the m-th basic task, This represents the input sample. Let it be... , where represents the model parameters corresponding to the m-th basic task, These are the parameters for the feature extractor, which is shared across different underlying tasks. These are the task classifier parameters for the m-th basic task.

[0084] This embodiment does not limit the prediction model to a fixed network structure, only requiring that it can be divided into two parts: a feature extractor and a classifier. In a specific embodiment of the invention, the feature extractor... Convolutional neural networks, ResNet residual networks, visual Transformers, or other deep feature extraction networks can be used; task classifiers A linear classifier or a multilayer perceptron can be used. Since the label spaces for different basic tasks and new tasks can be different, a corresponding task classifier should be set for each basic task. Shared feature extractor Used to learn transferable general representations.

[0085] 2) In the meta-training phase, the prediction model is trained using the source domain dataset of the basic task to obtain the updated model parameters and calculate the source domain loss function.

[0086] In this embodiment, for any basic task Its source domain dataset is denoted as , It must contain at least one source domain; The target domain dataset is denoted as , It must contain at least one target domain.

[0087] In this embodiment, the source domain is used for meta-training, and the target domain is used for meta-testing to simulate the process of the prediction model generalizing from seen domains to unseen domains. The basic task refers to a historical task with multi-domain labeled data, such as animal classification, furniture classification, vehicle classification, or medical image classification; the number of basic tasks is denoted as [missing information]. ,generally , The larger the scale, the richer the historical mission experience available for migration.

[0088] During the meta-training phase, for the first... Prediction models for each basic task Using its source domain dataset Update model parameters Among them, parameters The source domain is updated using the following loss function:

[0089]

[0090] in, Represents the source domain dataset The number of source domains in Indicates the first The number of samples in each source domain; Indicates the first In the source domain, the first Input data for each sample; Indicates the first In the source domain, the first The category labels corresponding to each sample; Representation Model For source domain samples The output prediction result; ℓ(·,·) represents the classification loss function, such as cross-entropy loss.

[0091] It should be noted that step 2) above refers to each time a certain basic task is sampled. Then, the meta-training steps are performed for this basic task.

[0092] 3) In the meta-testing phase, the meta-testing loss is calculated on the target domain of the basic task using the model parameters updated in step 2).

[0093] In this embodiment, the first Model parameters updated for each basic task (in The inner learning rate for meta-training is usually set to 1e-4, representing the source domain loss. Represents the source domain loss function Regarding the first Basic task model parameters The gradient; This represents the intermediate parameters obtained after training in the source domain, i.e., the updated model parameters within the source domain. Then, these intermediate model parameters are used... In the The target domain dataset for each basic task Calculate the meta-test loss:

[0094]

[0095] in, Represents the target domain dataset The number of target domains in the data; Let be the sample size of the k-th target domain. , These are the input data and corresponding category label of the j-th sample in the k-th target domain, respectively; Indicates the use of intermediate model parameters The next Predictive models for basic tasks; Representation Model For target domain samples The output is the prediction result.

[0096] 4) Based on the results of steps 2) and 3), update the model parameters corresponding to the basic task by jointly optimizing the objective function.

[0097] In this embodiment, the objective function is updated by jointly optimizing the first... The model parameters corresponding to each basic task are expressed as follows:

[0098]

[0099] in, The hyperparameter used to control the ratio of meta-training to meta-testing is usually set to 1, and the value is usually the same for different basic tasks.

[0100] Finally, the optimized version was obtained. .

[0101] 5) Based on the results of step 4), calculate the semantic vector of each basic task source domain.

[0102] In this embodiment, this step uses the current shared feature extractor. The samples are feature-encoded, therefore the updated feature extractor parameters obtained after step 4) are expressed in the following formula. reflect.

[0103] For the Basic tasks The Each source domain has its domain-level semantic vector defined as:

[0104]

[0105] No. The semantic vector of the entire source domain of each basic task is defined as follows:

[0106]

[0107] in, Indicates the first The first basic task Average feature representation of each source domain; Indicates the first The overall task-level semantic representation of the source domain of each basic task.

[0108] 6) Based on the results of step 4), calculate the semantic vector of the target domain of each basic task.

[0109] In this embodiment, this step also uses the current shared feature extractor. Feature encoding of target domain samples:

[0110]

[0111] in, Indicates the first The first basic task Average feature representation of each target domain; Indicates the first The overall task-level semantic representation of the basic task target domain.

[0112] 7) Based on the results of step 4), calculate the semantic vectors of each source domain of the new task, and then obtain the overall semantic vector of the source domain of the new task by averaging.

[0113] In this embodiment, the new task This refers to the target task that needs to be actually deployed, such as an animal classification task, medical image classification task, or industrial defect classification task to be deployed. Unlike basic tasks, new tasks only have a small amount of source domain data during the training phase. The target domain data is not used; the new task and the base task can have different class label spaces, but should have the same or compatible data modality in order to share the feature extractor. It can perform feature encoding on its input samples. The calculation expression is as follows:

[0114]

[0115]

[0116] in, Indicates the new task number The number of samples in each source domain; Indicates the new task number The first in the source domain Input data for each sample; Indicates the new task number Average feature representation of each source domain; Indicates the number of source domains for the new task; This represents the task-level semantic representation of the entire source domain of the new task.

[0117] 8) Based on the results of steps 5) and 7), calculate the semantic similarity between the base task and the new task.

[0118] In this embodiment, the basic task With new mission The expression for calculating the semantic similarity between them is as follows:

[0119]

[0120] in, This represents the cosine similarity. Indicates the first Semantic similarity between basic tasks and new tasks The larger the value, the higher the value. The closer a base task is to a new task in semantic space, the more likely the historical experience of the base task is to contribute to the feature transfer of the new task.

[0121] 9) Based on the results of steps 5)-7), calculate the domain offset similarity between the base task and the new task.

[0122] In this embodiment, the basic task With new mission The expression for calculating the domain offset similarity between them is as follows:

[0123]

[0124] in, This indicates the direction of the domain offset observed between the two source domains of the new task; Indicates the first The domain offset direction of each basic task from the source domain to the target domain; Indicates the domain offset pattern between the new task source domains and the first The maximum similarity between the offset patterns of the source domain to the target domain of each basic task.

[0125] In this embodiment, if the new task has only one source domain and it is impossible to form an offset direction between source domains, then it can be set as follows: Alternatively, when calculating the overall similarity later, let the weighting coefficient of the domain offset similarity be... This allows sampling to be primarily based on semantic similarity.

[0126] 10) Based on the results of steps 8) and 9), the overall similarity between the basic task and the new task is obtained by combining semantic similarity and domain offset similarity.

[0127] In this embodiment, the basic task With new mission The formula for calculating the overall similarity between them is as follows:

[0128]

[0129] in, This is a weighting coefficient used to control the weight of domain offset similarity in the overall similarity, and is usually set to 2.

[0130] 11) Based on the results of step 10), adaptive sampling is performed on the basic task according to the overall similarity, and the sampling results are used to pre-train the prediction model to obtain the pre-trained feature extractor.

[0131] In this embodiment, the basic task The sampling probability is:

[0132]

[0133] M represents the number of basic tasks. Indicates the first The probability of each basic task being sampled during pre-training.

[0134] In this embodiment, if the actual calculation results are... If non-positive values ​​exist, the overall similarity can be non-negated first, or normalized using softmax to ensure... This represents the effective probability.

[0135] After obtaining the sampling probabilities, during pre-training, the probabilities are distributed in each iteration. Sample a basic task from the basic task set. The basic tasks with higher sampling probabilities will be selected more frequently during pre-training, or given greater training weights in the equivalent implementation. Then, steps 2) through 4) are performed on the sampled basic tasks to update the shared feature extractor parameters. and corresponding basic task classifier parameters Repeat the above process until pre-training converges, resulting in the pre-trained feature extractor. .

[0136] 12) Based on the results of step 11), utilize the pre-trained feature extractor and the newly initialized task classifier In the new mission Source domain dataset The new task prediction model is then fine-tuned to obtain the final new task prediction model.

[0137] Specifically, the training samples from each source domain of the new task are merged or sampled in batches. The Adam optimizer is used to update the parameters of the feature extractor and the new task classifier, with the learning rate typically set to 1e-4. After fine-tuning, the final prediction model for the new task is obtained. .in, This represents the feature extractor after pre-training and fine-tuning on a new task. This represents the classifier corresponding to the new task. The final model is used to predict unknown target domain samples for the new task, thereby achieving out-of-distribution generalization under the condition of a limited number of training domains.

[0138] The following section provides a more detailed explanation of the sparse domain generalization method based on meta-adaptive task sampling described in this embodiment, using the animal image classification scenario of a smart terminal as an example.

[0139] The new task in this embodiment is animal image classification, aiming to identify animal categories such as dogs, horses, giraffes, and cats. Due to limited data acquisition for this new task, only a small amount of source domain data, such as real photographs and paintings, can be obtained during the training phase. After actual deployment, the model may face unseen domains such as line drawings, cartoon images, low-light photography, or images from new camera equipment. Since this unknown target domain data cannot be obtained in advance during training, if the model is trained using only a small amount of source domain data for the new task, the model's classification accuracy in unknown target domains is likely to decrease.

[0140] This embodiment sets up multiple historical tasks as a set of basic tasks, such as furniture image classification, vehicle image classification, fruit image classification, and pet image classification. Each basic task has labeled data for multiple domains, such as real photographs, paintings, cartoons, and line drawings. For each basic task, a subset of these domains is used as the source domain dataset, and the remaining domains are used as the target domain dataset to simulate the process of generalizing from known domains to unseen domains on the basic task. This embodiment includes the following steps.

[0141] 1) Obtain the prediction model for each basic task; wherein the prediction model includes: a task classifier corresponding to the basic task and a feature extractor shared by all basic tasks and new tasks.

[0142] Where, let be the prediction model for the m-th basic task. ,in As a feature extractor, it can be shared across tasks. For the task classifier corresponding to the m-th basic task, This represents the input sample. Let it be... , where represents the model parameters corresponding to the m-th basic task, These are the parameters for the feature extractor, which is shared across different underlying tasks. These are the task classifier parameters for the m-th basic task.

[0143] In this embodiment, the feature extractor can be a convolutional neural network, a residual network (ResNet), a visual Transformer, or other deep feature extraction networks; the classifier can be a linear classifier or a multilayer perceptron. Since the class label spaces of different basic tasks and new tasks can be different, a corresponding task classifier is set for each basic task, while a shared feature extractor is used to learn a transferable general representation.

[0144] 2) In the meta-training phase, the prediction model is trained using the source domain dataset of the basic task to obtain the updated model parameters and calculate the source domain loss function value.

[0145] In this context, for any basic task Its source domain dataset is denoted as , It must contain at least one source domain; The target domain dataset is denoted as , Each target domain must contain at least one target domain. The source domain is used for meta-training, and the target domain is used for meta-testing to simulate the process of the prediction model generalizing from seen domains to unseen domains. For example, for a basic task of pet image classification, the real photo domain and the painting image domain can be used as the source domain, and the cartoon image domain and the line drawing image domain can be used as the target domain.

[0146] During the meta-training phase, for the first... Prediction models for each basic task Using its source domain dataset Update model parameters Among them, parameters The source domain is updated using the following loss function:

[0147]

[0148] in, Represents the source domain dataset The number of source domains in Indicates the first The number of samples in each source domain; Indicates the first In the source domain, the first Input data for each sample; Indicates the first In the source domain, the first The category labels corresponding to each sample; Representation Model For source domain samples The output prediction result; ℓ(·,·) represents the classification loss function, such as cross-entropy loss.

[0149] 3) In the meta-testing phase, the meta-testing loss is calculated on the target domain of the basic task using the model parameters updated in step 2).

[0150] Specifically, based on the source domain loss function in step 2), the first... Model parameters for each basic task Perform an inner gradient update to obtain intermediate model parameters:

[0151]

[0152] in, The inner learning rate for meta-training is typically set to 1e-4; Represents the source domain loss function Regarding the first Basic task model parameters The gradient; This represents the intermediate model parameters obtained after training in the source domain, which are also the updated model parameters within the source domain.

[0153] Then, using intermediate model parameters In the The target domain dataset for each basic task Calculate the meta-test loss:

[0154]

[0155] in, Represents the target domain dataset The number of target domains in the data; Let be the sample size of the k-th target domain. , These are the input data and corresponding category label of the j-th sample in the k-th target domain, respectively; Indicates the use of model parameters The next Predictive models for basic tasks; Representation Model For target domain samples The output is the prediction result.

[0156] 4) Based on the results of steps 2) and 3), update the model parameters corresponding to the basic task by jointly optimizing the objective function.

[0157] In this embodiment, the objective function is updated by jointly optimizing the first... The model parameters corresponding to each basic task are expressed as follows:

[0158]

[0159] in, The hyperparameter for controlling the relative weights between meta-training and meta-testing is typically set to 1, and its value is usually the same for different base tasks. This results in the optimized... .

[0160] 5) Based on the results of step 4), calculate the semantic vector of each basic task source domain.

[0161] In this embodiment, this step uses the current shared feature extractor. The samples are feature-encoded.

[0162] For the Basic tasks The Each source domain has its domain-level semantic vector defined as:

[0163]

[0164] No. The semantic vector of the entire source domain of each basic task is defined as follows:

[0165]

[0166] in, Indicates the first The first basic task Average feature representation of each source domain; Indicates the first The overall task-level semantic representation of the source domain of each basic task.

[0167] 6) Based on the results of step 4), calculate the semantic vector of the target domain of each basic task.

[0168] For the Basic tasks The For each target domain, its domain-level semantic vector is defined as:

[0169]

[0170] No. The semantic vector of the entire basic task target domain is defined as follows:

[0171]

[0172] in, Indicates the first The first basic task Average feature representation of each target domain; Indicates the first The overall task-level semantic representation of the basic task target domain.

[0173] 7) Based on the results of step 4), calculate the semantic vectors of each source domain of the new task, and then obtain the overall semantic vector of the source domains of the new task by averaging.

[0174] In this embodiment, the new task This is for an animal image classification task to be deployed. Unlike the basic task, the new task has only a small amount of source domain data during the training phase. For example, real photograph domains and painting image domains are used, while target domain data such as line drawing domains and cartoon image domains are not used; new tasks and basic tasks can have different category label spaces, but should have the same or compatible data modalities so that the shared feature extractor can encode features of its input samples.

[0175] For the new task The Each source domain has a semantic vector defined as follows:

[0176]

[0177] The semantic vector of the entire new task source domain is defined as follows:

[0178]

[0179] in, Indicates the new task number The number of samples in each source domain; Indicates the new task number The first in the source domain Input data for each sample; Indicates a new task No. Average feature representation of each source domain; Indicates a new task The number of source domains; Indicates a new task Task-level semantic representation of the entire source domain.

[0180] 8) Based on the results of steps 5) and 7), calculate the semantic similarity between the base task and the new task.

[0181] In this embodiment, the semantic similarity between the basic task and the new task is defined as:

[0182]

[0183] in, Indicates cosine similarity; Indicates the first Semantic similarity between basic tasks and new tasks. The larger the value, the higher the value. The closer a base task is to a new task in semantic space, the more likely the historical experience of the base task is to contribute to feature transfer in the new task. For example, a base task of pet image classification typically has a higher semantic similarity to a new task of animal image classification than a base task of furniture image classification.

[0184] 9) Based on the results of steps 5) to 7), calculate the domain offset similarity between the base task and the new task.

[0185] In this embodiment, the basic task With new mission The expression for calculating the domain offset similarity between them is as follows:

[0186]

[0187] in, This indicates the direction of the domain offset observed between the two source domains of the new task; Indicates the first The domain offset direction of each basic task from the source domain to the target domain; Indicates the domain offset pattern between the new task source domains and the first The maximum similarity between the offset patterns of the source domain to the target domain of each basic task.

[0188] In this embodiment, if the new task has only one source domain and it is impossible to form an offset direction between source domains, then it can be set as follows: Alternatively, when calculating overall similarity, the weighting coefficient of domain offset similarity can be set. This allows sampling to be primarily based on semantic similarity.

[0189] 10) Based on the results of steps 8) and 9), the overall similarity between the basic task and the new task is obtained by combining semantic similarity and domain offset similarity.

[0190] In this embodiment, the basic task With new mission The formula for calculating the overall similarity between them is as follows:

[0191]

[0192] in, This is a weighting coefficient used to control the weight of domain offset similarity in the overall similarity, and is usually set to 2.

[0193] 11) Based on the results of step 10), adaptive sampling is performed on the basic task according to the overall similarity, and the sampling results are used to pre-train the prediction model to obtain the pre-trained feature extractor.

[0194] In this embodiment, the basic task The sampling probability is:

[0195]

[0196] M represents the number of basic tasks. Indicates the first The probability of each basic task being sampled during pre-training.

[0197] In this embodiment, if the actual calculation results are... If non-positive values ​​exist, the overall similarity can be non-negated first, or normalized using softmax to ensure... This represents the effective probability.

[0198] After obtaining the sampling probabilities, during pre-training, the probabilities are distributed in each iteration. Sample a basic task from the basic task set. The basic tasks with higher sampling probabilities will be selected more frequently during pre-training, or given greater training weights in the equivalent implementation. Then, steps 2) through 4) are performed on the sampled basic tasks to update the shared feature extractor parameters. and corresponding basic task classifier parameters Repeat the above process until pre-training converges, resulting in the pre-trained feature extractor. .

[0199] 12) Based on the results of step 11), the new task prediction model is fine-tuned on the source domain dataset of the new task using the pre-trained feature extractor and the re-initialized new task classifier, so as to obtain the final new task prediction model.

[0200] Specifically, the training samples from each source domain of the new task are merged or sampled in batches, and the Adam optimizer is used to update the parameters of the feature extractor and the new task classifier. The learning rate is usually set to [value missing]. After fine-tuning, the final prediction model for the new task is obtained:

[0201]

[0202] in, This represents the feature extractor after pre-training and fine-tuning on a new task; This represents the classifier corresponding to the new task; This indicates that the final new task prediction model is based on the input samples. The output is the prediction result.

[0203] In this embodiment, the fine-tuned final model is used to classify animal images in the unknown target domain of a new task, such as animal images in the sketch domain, cartoon image domain, low-light image domain, or new camera equipment image domain. Compared to models that are directly trained using only a small amount of source domain data for the new task, this embodiment uses basic task pre-training and meta-adaptive task sampling to enable the model to prioritize the use of historical task experience that is semantically closer to the new task and has a more similar domain offset pattern, thereby improving the classification accuracy and stability of the new task in the unknown target domain.

[0204] To implement the above embodiments, a second aspect of the present invention proposes a sparse domain generalization device based on meta-adaptive task sampling, comprising:

[0205] The basic task prediction model acquisition module is used to acquire prediction models for each basic task; wherein, the prediction model includes: a task classifier corresponding to the basic task, and a feature extractor shared by all basic tasks and new tasks;

[0206] The meta-training module is used to train the corresponding prediction model using the source domain dataset of the basic task during the meta-training phase, obtain the updated model parameters, and calculate the source domain loss function value.

[0207] The meta-testing module is used to calculate the meta-testing loss on the target domain of the basic task using the updated model parameters during the meta-testing phase.

[0208] The basic task model parameter optimization module is used to obtain the optimized model parameters corresponding to the basic task by jointly optimizing the source domain loss function value and the meta-test loss.

[0209] The overall similarity calculation module is used to calculate the semantic vector of the source domain of the basic task, the semantic vector of the target domain of the basic task, and the semantic vector of the overall source domain of the new task based on the feature extractor parameters in the optimized model parameters corresponding to the basic task, thereby obtaining the semantic similarity between the basic task and the new task and the domain offset similarity between the basic task and the new task; the semantic similarity and the domain offset similarity are weighted and summed to obtain the overall similarity between the basic task and the new task;

[0210] An adaptive sampling module is used to perform adaptive sampling of the basic task for predictive model pre-training based on the overall similarity; wherein, in each round of pre-training, the parameters of the corresponding predictive model are updated using the sampled basic task; after pre-training is completed, the pre-trained feature extractor is obtained.

[0211] The new task prediction model fine-tuning module is used to fine-tune the new task prediction model on the source domain dataset of the new task using the pre-trained feature extractor and the re-initialized new task classifier, so as to obtain the final new task prediction model.

[0212] In one specific embodiment of the present invention, it further includes:

[0213] During the meta-training phase, the first... Source domain datasets for each basic task Predictive model for this basic task Update model parameters ;in, These are the parameters for the feature extractor. For the task classifier parameters of the m-th basic task;

[0214] parameter The source domain is updated using the following loss function:

[0215]

[0216] in, Represents the source domain dataset The number of source domains in Indicates the first The number of samples in each source domain; Indicates the first In the source domain, the first Input data for each sample; Indicates the first In the source domain, the first The category labels corresponding to each sample; Representation Model For source domain samples The output prediction result; ℓ(·,·) represents the classification loss function.

[0217] In one specific embodiment of the present invention, it further includes:

[0218] During the meta-testing phase, the updated model parameters are used. Calculate the meta-test loss over the target domain:

[0219]

[0220] in, Represents the target domain dataset The number of target domains in the data; Let be the sample size of the k-th target domain. , These are the input data and corresponding category label of the j-th sample in the k-th target domain, respectively; Indicates the use of model parameters The next Predictive models for basic tasks; Representation Model For target domain samples The output prediction results;

[0221] The inner learning rate for meta-training; Represents the source domain loss function Regarding the first Basic task model parameters The gradient; This represents the first [unit / type] obtained after training based on the source domain. The model parameters after updating the basic tasks.

[0222] In one specific embodiment of the present invention, it further includes:

[0223] The objective function expression for the joint optimization is as follows:

[0224]

[0225] in, Hyperparameters used to control the ratio of meta-training to meta-testing.

[0226] In one specific embodiment of the present invention, it further includes:

[0227] The semantic vector calculation expression for the basic task source domain is as follows:

[0228]

[0229] in, Indicates the first The first basic task The average feature representation of each source domain Indicates a shared feature extractor; Indicates the first The overall task-level semantic representation of the source domain of each basic task;

[0230] The semantic vector calculation expression for the basic task target domain is as follows:

[0231]

[0232] in, Indicates the first The first basic task Average feature representation of each target domain; Indicates the first The overall task-level semantic representation of the basic task target domain;

[0233] The semantic vector calculation expression for the entire source domain of the new task is as follows:

[0234]

[0235]

[0236] in, Indicates the new task number The number of samples in each source domain; Indicates the new task number The first in the source domain Input data for each sample; Indicates a new task No. Average feature representation of each source domain; Indicates a new task The number of source domains; Indicates a new task Task-level semantic representation of the entire source domain.

[0237] In one specific embodiment of the present invention, it further includes:

[0238] The semantic similarity calculation expression between the basic task and the new task is as follows:

[0239]

[0240] in, Indicates cosine similarity; Indicates the first Semantic similarity between basic tasks and new tasks;

[0241] The expression for calculating the domain offset similarity between the basic task and the new task is as follows:

[0242]

[0243] in, This indicates the direction of the domain offset observed between the two source domains of the new task; Indicates the first The domain offset direction of each basic task from the source domain to the target domain; Indicates the domain offset pattern between the new task source domains and the first The maximum similarity between the offset patterns of the source domain to the target domain of each basic task;

[0244] The expression for calculating the overall similarity between the basic task and the new task is as follows:

[0245]

[0246] in, is a weighting coefficient used to control the weight of domain offset similarity in the overall similarity.

[0247] In one specific embodiment of the present invention, it further includes:

[0248] During the adaptive sampling, the basic task The sampling probability is:

[0249]

[0250] Where M is the number of basic tasks; Indicates the first The probability of each basic task being sampled during pre-training.

[0251] This can improve the model's classification accuracy and stability in unknown target domains, reduce dependence on a large amount of multi-source training domain and target domain data, improve the efficiency of knowledge transfer from historical tasks, and make the model more suitable for practical scenarios with high training data acquisition costs or scarce domain labels, such as medical image recognition, industrial visual inspection, remote sensing target recognition, and smart terminal visual recognition.

[0252] To implement the above embodiments, a third aspect of the present invention provides an electronic device, comprising:

[0253] At least one processor; and a memory communicatively connected to said at least one processor;

[0254] The memory stores instructions that can be executed by the at least one processor, and the instructions are configured to execute the above-described sparse domain generalization method based on meta-adaptive task sampling.

[0255] To implement the above embodiments, a fourth aspect of the present invention provides a computer-readable storage medium storing computer instructions for causing the computer to execute the above-described sparse domain generalization method based on meta-adaptive task sampling.

[0256] It should be noted that the computer-readable medium described in this disclosure can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this disclosure, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in connection with an instruction execution system, apparatus, or device. In this disclosure, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.

[0257] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device. The aforementioned computer-readable medium carries one or more programs, which, when executed by the electronic device, cause the electronic device to perform a sparse domain generalization method based on meta-adaptive task sampling according to the above embodiments.

[0258] Computer program code for performing the operations of this disclosure can be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, and C++, and conventional procedural programming languages ​​such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0259] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.

[0260] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this application, "multiple" means at least two, such as two, three, etc., unless otherwise explicitly specified.

[0261] Any process or method described in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more executable instructions for implementing a particular logical function or process, and the scope of the preferred embodiments of this application includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the function involved, as will be understood by those skilled in the art to which embodiments of this application pertain.

[0262] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-included system, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of computer-readable media include: an electrical connection having one or more wires (electronic device), a portable computer disk drive (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Furthermore, computer-readable media can even be paper or other suitable media on which programs can be printed, because programs can be obtained electronically, for example, by optically scanning the paper or other media, followed by editing, interpreting, or otherwise processing as necessary, and then stored in computer memory.

[0263] It should be understood that various parts of this application can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented using software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.

[0264] Those skilled in the art will understand that all or part of the steps of the methods in the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, the program includes one or a combination of the steps of the method embodiments.

[0265] Furthermore, the functional units in the various embodiments of this application can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into a module. The integrated module can be implemented in hardware or as a software functional module. If the integrated module is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium.

[0266] The storage medium mentioned above can be a read-only memory, a disk, or an optical disk, etc. Although embodiments of this application have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting this application. Those skilled in the art can make changes, modifications, substitutions, and variations to the above embodiments within the scope of this application.

Claims

1. A sparse domain generalization method based on meta-adaptive task sampling, characterized in that, include: Obtain prediction models for each basic task; wherein, the prediction model includes: a task classifier corresponding to the basic task, and a feature extractor shared by all basic tasks and new tasks; In the meta-training phase, the prediction model corresponding to the basic task is trained using the source domain dataset of the basic task to obtain the updated model parameters and calculate the source domain loss function value. During the meta-testing phase, the updated model parameters are used to calculate the meta-testing loss in the target domain of the basic task. By jointly optimizing the source domain loss function value and the meta-test loss, the optimized model parameters corresponding to the basic task are obtained. Based on the feature extractor parameters in the optimized model parameters corresponding to the basic task, the semantic vector of the source domain of the basic task, the semantic vector of the target domain of the basic task, and the semantic vector of the overall source domain of the new task are calculated to obtain the semantic similarity between the basic task and the new task, as well as the domain offset similarity between the basic task and the new task. The semantic similarity and the domain offset similarity are weighted and summed to obtain the overall similarity between the basic task and the new task. Adaptive sampling is performed on the basic task for predictive model pre-training based on the overall similarity; wherein, in each round of pre-training, the parameters of the corresponding predictive model are updated using the sampled basic task; after pre-training is completed, the pre-trained feature extractor is obtained. Using the pre-trained feature extractor and the re-initialized new task classifier, the new task prediction model is fine-tuned on the source domain dataset of the new task to obtain the final new task prediction model.

2. The method according to claim 1, characterized in that, Also includes: During the meta-training phase, the first... Source domain datasets for each basic task Predictive model for this basic task Update model parameters ;in, These are the parameters for the feature extractor. For the task classifier parameters of the m-th basic task; parameter The source domain is updated using the following loss function: in, Represents the source domain dataset The number of source domains in Indicates the first The number of samples in each source domain; Indicates the first In the source domain, the first Input data for each sample; Indicates the first In the source domain, the first The category labels corresponding to each sample; Representation Model For source domain samples The output prediction result; ℓ(·,·) represents the classification loss function.

3. The method according to claim 2, characterized in that, Also includes: During the meta-testing phase, the updated model parameters are used. Calculate the meta-test loss over the target domain: in, Represents the target domain dataset The number of target domains in the data; Let be the sample size of the k-th target domain. , These are the input data and corresponding category label of the j-th sample in the k-th target domain, respectively; Indicates the use of model parameters The next Predictive models for basic tasks; Representation Model For target domain samples The output prediction results; The inner learning rate for meta-training; Represents the source domain loss function Regarding the first Basic task model parameters The gradient; This represents the first [unit / type] obtained after training based on the source domain. The model parameters after updating the basic tasks.

4. The method according to claim 3, characterized in that, Also includes: The objective function expression for the joint optimization is as follows: in, Hyperparameters used to control the ratio of meta-training to meta-testing.

5. The method according to claim 4, characterized in that, Also includes: The semantic vector calculation expression for the basic task source domain is as follows: in, Indicates the first The first basic task The average feature representation of each source domain Indicates a shared feature extractor; Indicates the first The overall task-level semantic representation of the source domain of each basic task; The semantic vector calculation expression for the basic task target domain is as follows: in, Indicates the first The first basic task Average feature representation of each target domain; Indicates the first The overall task-level semantic representation of the basic task target domain; The semantic vector calculation expression for the entire source domain of the new task is as follows: in, Indicates the new task number The number of samples in each source domain; Indicates the new task number The first in the source domain Input data for each sample; Indicates a new task No. Average feature representation of each source domain; Indicates a new task The number of source domains; Indicates a new task Task-level semantic representation of the entire source domain.

6. The method according to claim 5, characterized in that, Also includes: The semantic similarity calculation expression between the basic task and the new task is as follows: in, Indicates cosine similarity; Indicates the first Semantic similarity between basic tasks and new tasks; The expression for calculating the domain offset similarity between the basic task and the new task is as follows: in, This indicates the direction of the domain offset observed between the two source domains of the new task; Indicates the first The domain offset direction of each basic task from the source domain to the target domain; Indicates the domain offset pattern between the new task source domains and the first The maximum similarity between the offset patterns of the source domain to the target domain of each basic task; The expression for calculating the overall similarity between the basic task and the new task is as follows: in, is a weighting coefficient used to control the weight of domain offset similarity in the overall similarity.

7. The method according to claim 6, characterized in that, Also includes: During the adaptive sampling, the basic task The sampling probability is: Where M is the number of basic tasks; Indicates the first The probability of each basic task being sampled during pre-training.

8. A sparse domain generalization device based on meta-adaptive task sampling, characterized in that, include: The basic task prediction model acquisition module is used to acquire prediction models for each basic task; wherein, the prediction model includes: a task classifier corresponding to the basic task, and a feature extractor shared by all basic tasks and new tasks; The meta-training module is used to train the corresponding prediction model using the source domain dataset of the basic task during the meta-training phase, obtain the updated model parameters, and calculate the source domain loss function value. The meta-testing module is used to calculate the meta-testing loss on the target domain of the basic task using the updated model parameters during the meta-testing phase. The basic task model parameter optimization module is used to obtain the optimized model parameters corresponding to the basic task by jointly optimizing the source domain loss function value and the meta-test loss. The overall similarity calculation module is used to calculate the semantic vector of the source domain of the basic task, the semantic vector of the target domain of the basic task, and the semantic vector of the overall source domain of the new task based on the feature extractor parameters in the optimized model parameters corresponding to the basic task, thereby obtaining the semantic similarity between the basic task and the new task and the domain offset similarity between the basic task and the new task; the semantic similarity and the domain offset similarity are weighted and summed to obtain the overall similarity between the basic task and the new task; An adaptive sampling module is used to perform adaptive sampling of the basic task for predictive model pre-training based on the overall similarity; wherein, in each round of pre-training, the parameters of the corresponding predictive model are updated using the sampled basic task; after pre-training is completed, the pre-trained feature extractor is obtained. The new task prediction model fine-tuning module is used to fine-tune the new task prediction model on the source domain dataset of the new task using the pre-trained feature extractor and the re-initialized new task classifier, so as to obtain the final new task prediction model.

9. An electronic device, characterized in that, include: At least one processor; And, a memory communicatively connected to the at least one processor; The memory stores instructions executable by the at least one processor, the instructions being configured to perform the method described in any one of claims 1-7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions for causing the computer to perform the method according to any one of claims 1-7.