Iterative unsupervised domain adaptation method and apparatus
By using an iterative unsupervised domain adaptation method, and leveraging data augmentation and dynamic decay momentum to adjust model parameters, the dependence of unsupervised domain adaptation methods on a large amount of test data is resolved, achieving efficient adaptation and accuracy of the model with a small number of samples.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- XINQIAO (BEIJING) SEMICONDUCTOR CO LTD
- Filing Date
- 2023-02-20
- Publication Date
- 2026-04-28
AI Technical Summary
Existing unsupervised domain adaptation methods require a large amount of test data to achieve stable and optimal results, which cannot meet the needs of practical application scenarios and development requirements.
An iterative unsupervised domain adaptation method is adopted. By extracting a preset number of image samples from the domain transfer test set, the parameters of the pre-trained model are adjusted using an iterative optimization algorithm, including data augmentation, normalization of feature data, dynamic decay momentum, and classification error calculation, to reduce the number of image samples to adapt to the domain transfer test set.
With a limited number of image samples, the model can adapt to the domain transfer test set, meeting the needs of practical application scenarios and development requirements, without the need for retraining, thus improving training efficiency and accuracy.
Smart Images

Figure CN116246126B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of transfer learning technology, and in particular to an iterative unsupervised domain adaptation method and apparatus. Background Technology
[0002] Transfer learning is a machine learning method that refers to reusing a pre-trained model for another task. When the target domain shifts or the test set becomes inconsistent with the source domain due to the addition of unlabeled data, the performance of the pre-trained model will significantly decrease, and its generalization ability will deteriorate.
[0003] To address the issue of degraded model performance, one of the simplest and most direct methods is to obtain labeled data from the target domain and retrain the model. Another approach is Dynamic Unsupervised Domain Adaptation (UDA), which involves obtaining labeled training data and a large number of unlabeled transfer samples to retrain the network, enabling the model to adapt to the new data distribution in an unsupervised learning manner.
[0004] Existing unsupervised domain adaptation methods require a large amount of test data to achieve stable and optimal results, which cannot meet the needs of practical application scenarios and development requirements. Summary of the Invention
[0005] This invention provides an iterative unsupervised domain adaptation method and apparatus to address the shortcomings of existing unsupervised domain adaptation methods, which require a large amount of test data to achieve stable and optimal results, thus failing to meet the needs of practical application scenarios and development requirements.
[0006] This invention provides an iterative unsupervised domain adaptation method, comprising:
[0007] A predetermined number of image samples are extracted from the domain migration test set;
[0008] The image samples are input into a preset iterative optimization algorithm, and the parameters of the pre-trained model are adjusted according to the calculation results of the iterative optimization algorithm so that the adjusted model can adapt to the domain transfer test set.
[0009] The preset iterative optimization algorithm includes:
[0010] Data augmentation processing is performed on each of the image samples to obtain a batch of images of the target size;
[0011] Based on the batch of images, determine the parameter values of the model;
[0012] The model with determined parameter values is tested using the domain transfer test set to obtain the classification error.
[0013] After traversing all the image samples, the average classification error of the image samples is obtained based on the classification error.
[0014] According to an iterative unsupervised domain adaptive method provided by the present invention, determining the parameter values of the model based on the batch images includes:
[0015] The features of the batch of images are normalized to obtain normalized feature data;
[0016] Based on the normalized feature data, the mean and variance of the features of the batch of images are obtained;
[0017] The parameter values of the model are obtained based on the mean and variance of the features of the batch of images.
[0018] According to an iterative unsupervised domain adaptive method provided by the present invention, the step of obtaining the mean and variance of the features of the batch images based on the normalized feature data includes:
[0019] Based on the normalized feature data and dynamic decay momentum, the mean and variance of the features of the batch of images are obtained;
[0020] The dynamic decay momentum is obtained based on the dynamic decay coefficient, and the dynamic decay system is related to the number of iterations.
[0021] An iterative unsupervised domain adaptation method provided by the present invention further includes:
[0022] The dynamic decay momentum is updated based on the dynamic decay coefficient;
[0023] If the average classification error meets the set conditions, the iteration ends.
[0024] According to an iterative unsupervised domain adaptive method provided by the present invention, the step of normalizing the features of the batch images to obtain normalized feature data includes:
[0025] The batch of images is divided into multiple sub-batch images, and the features of the sub-batch images are normalized to obtain normalized feature data.
[0026] An iterative unsupervised domain adaptation method provided by the present invention further includes:
[0027] Data augmentation processing is performed on each image sample based on the first preset enhancement algorithm to obtain a batch of images of the target size;
[0028] The batch images are subjected to data enhancement processing based on the second preset enhancement algorithm to obtain the data-enhanced batch images.
[0029] The present invention also provides an iterative unsupervised domain adaptive device, comprising:
[0030] The acquisition module is used to extract a preset number of image samples from the domain migration test set;
[0031] An adjustment module is used to input the image samples into a preset iterative optimization algorithm and adjust the parameters of the pre-trained model according to the calculation results of the iterative optimization algorithm, so that the adjusted model can adapt to the domain transfer test set.
[0032] The preset iterative optimization algorithm includes:
[0033] Data augmentation processing is performed on each of the image samples to obtain a batch of images of the target size;
[0034] Based on the batch of images, determine the parameter values of the model;
[0035] The model with determined parameter values is tested using the domain transfer test set to obtain the classification error.
[0036] After traversing all the image samples, the average classification error of the image samples is obtained based on the classification error.
[0037] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the iterative unsupervised domain adaptation method as described above.
[0038] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the iterative unsupervised domain adaptation method as described above.
[0039] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the iterative unsupervised domain adaptation method as described above.
[0040] The iterative unsupervised domain adaptive method and apparatus provided by this invention process image samples based on a preset iterative optimization algorithm. It can meet the needs of practical application scenarios and development requirements with a small number of image samples, without the need for retraining. This solves the defect of existing unsupervised domain adaptive methods that require a large number of test data to achieve stable and optimal results. Attached Figure Description
[0041] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0042] Figure 1 This is a flowchart illustrating the iterative unsupervised domain adaptive method provided by the present invention;
[0043] Figure 2 This is a flowchart illustrating the preset iterative optimization algorithm provided by the present invention;
[0044] Figure 3 This invention provides Figure 2 A flowchart illustrating step S122;
[0045] Figure 4 This is a schematic diagram of the structure of the iterative unsupervised domain adaptive device provided by the present invention;
[0046] Figure 5 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation
[0047] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0048] In the description of the embodiments of this application, it should be noted that the terms "center," "longitudinal," "lateral," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "top," "bottom," "inner," and "outer," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are only for the convenience of describing the embodiments of this application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on the embodiments of this application. In addition, the terms "first," "second," and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance.
[0049] In the description of the embodiments of this application, it should be noted that, unless otherwise explicitly specified and limited, the terms "connected" and "linked" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium. Those skilled in the art can understand the specific meaning of the above terms in the embodiments of this application based on the specific circumstances.
[0050] In the embodiments of this application, unless otherwise expressly specified and limited, "above" or "below" the second feature can mean that the first feature is in direct contact with the second feature, or that the first feature is in indirect contact with the second feature through an intermediate medium. Furthermore, "above," "on top of," and "over" the second feature can mean that the first feature is directly above or diagonally above the second feature, or simply that the first feature is at a higher horizontal level than the second feature. "Below," "below," and "under" the second feature can mean that the first feature is directly below or diagonally below the second feature, or simply that the first feature is at a lower horizontal level than the second feature.
[0051] 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 the embodiments 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.
[0052] Figure 1 This is a flowchart illustrating the iterative unsupervised domain adaptive method provided by the present invention, as shown below. Figure 1 As shown, this invention provides an iterative unsupervised domain adaptive method, comprising:
[0053] S110, Extract a preset number of image samples from the domain migration test set;
[0054] S120, the image samples are input into a preset iterative optimization algorithm, and the parameters of the pre-trained model are adjusted according to the calculation results of the iterative optimization algorithm so that the adjusted model can adapt to the domain transfer test set.
[0055] Figure 2 This is a flowchart illustrating the preset iterative optimization algorithm provided by the present invention, as shown below. Figure 2 As shown, the preset iterative optimization algorithm includes:
[0056] S121, Perform data augmentation processing on each of the image samples to obtain a batch of images of the target size;
[0057] S122, Determine the parameter values of the model based on the batch of images;
[0058] S123, Test the model with determined parameter values according to the domain transfer test set to obtain the classification error;
[0059] S124, after traversing all the image samples, the average classification error of the image samples is obtained based on the classification error.
[0060] Optionally, in step S110, the test set X is migrated from the domain. tar Randomly select 0.5% to 0.8% of the image samples N = (n1, n2, ..., nn) n (n) represents the total number of image samples; the images in the domain migration test set are all unlabeled test data. The smaller the extraction ratio, the fewer the number of image samples extracted, which better meets the needs of real-world applications, and the less time and computation are required to implement the entire process.
[0061] Optionally, in step S120, the pre-trained model can be a ResNet-26 classification model trained on the ResNet classification network using the CIFAR-10 dataset, which can be applied to fields such as medical imaging and autonomous driving.
[0062] In this invention, the parameters of the model specifically refer to the BN layer statistical parameters. That is, the embodiments of this invention adjust the BN layer statistical parameters of the model. Specifically, if the model has not yet been iterated, the initial BN layer statistical parameters of the model are used as prior information. After iteration, the BN layer statistical parameters corresponding to the model weights after iteration are used as prior information.
[0063] In step S121, data augmentation processing is performed on each image sample to obtain a batch of 64*64 pixel images.
[0064] In step S122, the parameter values of the model are determined based on the expectation and variance of the features of the batch images, so that the batch images can gradually approach the domain migration distribution.
[0065] Here, the features of a batch of images refer to the feature maps of the batch of images, the intermediate layers of the network, and so on.
[0066] In step S123, each time the model's parameter values are obtained, the classification error of the model on the domain transfer test set is calculated. After traversing all image samples, the statistical parameters of all BN layers of the model are updated n times, generating n classification errors. The average of the n classification errors is calculated to obtain the average classification error of the current iteration. The average classification error is used to determine the condition for ending the iteration.
[0067] It is understood that the present invention processes image samples based on a preset iterative optimization algorithm, which can reduce the number of image samples required, meet the needs of actual application scenarios and development requirements, and eliminate the need for retraining. This solves the defect of existing unsupervised domain adaptive methods that require a large amount of test data to achieve stable and optimal results.
[0068] Figure 3 This invention provides Figure 2 The flowchart of step S122 is as follows: Figure 3 As shown, based on the above embodiments, as an optional embodiment, determining the parameter values of the model according to the batch images includes:
[0069] S310, Normalize the features of the batch images to obtain normalized feature data;
[0070] S320, Based on the normalized feature data, obtain the mean and variance of the features of the batch images;
[0071] S330, Based on the mean and variance of the features of the batch of images, obtain the parameter values of the model.
[0072] Optionally, the features of the batch images are normalized, and the resulting normalized feature data is equivalent to the output feature data of the BN layer of the model. Calculating the mean and variance of the features of the batch images is equivalent to calculating the parameter values of the BN layer of the model. The parameters of the BN layer of the model include the running mean and the running variance.
[0073] The formula for normalization is as follows:
[0074]
[0075] in, For normalized feature data, γ and β are the scaling coefficient and scaling factor, respectively, ∈ is a stable value to prevent the denominator from being 0, x is the feature of the image sample, and μ pop For the moving average, σ pop Let be the sliding variance.
[0076] It is understood that the embodiments of the present invention provide a technical solution for determining the parameter values of a model based on a batch of images, which can calculate the parameter values of the model using a small number of image samples, so that the model can be adapted to the domain transfer test set and meet the needs of actual application scenarios and development requirements.
[0077] Based on the above embodiments, as an optional embodiment, obtaining the mean and variance of the features of the batch images according to the normalized feature data includes:
[0078] Based on the normalized feature data and dynamic decay momentum, the mean and variance of the features of the batch of images are obtained;
[0079] The dynamic decay momentum is obtained based on the dynamic decay coefficient, and the dynamic decay system is related to the number of iterations.
[0080] Optionally, the expected features of the current batch of images. The calculation formula is as follows:
[0081]
[0082] The formula for calculating the variance Var[X] of the features of the current batch of images is as follows:
[0083]
[0084] in, and It is the mean and variance estimated from the features of the current batch of images, μ k and σ k The mean and variance of the features of the input batch of images are represented by μ. pop and σ pop , k represents the input batch, ρ is momentum, which determines the degree to which the existing statistical estimates are affected by the statistical information of the input batch images. A larger momentum value will essentially give greater weight to the calculated statistical data of the input batch images.
[0085] Optionally, the expected value of features of a batch of images can be calculated based on dynamic decay momentum. The formula for calculating the variance Var[X] is as follows:
[0086]
[0087]
[0088]
[0089]
[0090] ρ k =ρk-1 ·ω·(1-τ·m);
[0091] Where, ρ k =0.2, The dynamic decay coefficient of momentum is ω·(1-τ·m), where τ ranges from (2×10⁻⁶) / (1-τ·m). -5 5×10 -5 ), Define a lower bound for momentum, with ω ranging from (0.9, 0.99). m is the iteration number in Step 6, M ∈ (0, 1, ..., m-1).
[0092] Understandably, by setting a dynamic decay momentum, this invention can stabilize and optimize the running mean and running variance with fewer iterations, while ensuring that the average classification error is reduced to the minimum.
[0093] Based on the above embodiments, as an optional embodiment, the iterative unsupervised domain adaptation method provided by the present invention further includes:
[0094] The dynamic decay momentum is updated based on the dynamic decay coefficient;
[0095] If the average classification error meets the set conditions, the iteration ends.
[0096] Optionally, if the average classification error between two consecutive iterations is less than 5*10 -4 The iteration ends when the condition is met. The above values can be customized in the embodiments, but this invention does not limit them.
[0097] It is understandable that by updating the BN parameters of the current model after each iteration, this invention can reduce the number of iterations and improve efficiency.
[0098] Based on the above embodiments, as an optional embodiment, the normalization processing of the batch images to obtain normalized feature data includes:
[0099] The batch of images is divided into multiple sub-batch images, and the features of the sub-batch images are normalized to obtain normalized feature data.
[0100] Optional, the expected features of the input batch of images. The variance Var[X] is calculated by performing Precise BN statistics on the input batch using a sub-batch of size B. This requires calculation... (B should be divisible by 64, so it can be 1, 2, or 4).
[0101] The statistical aggregation formula for the features of the input batch of images is as follows:
[0102]
[0103]
[0104] Where, μ B This represents the expected value of the sub-batch images.
[0105] It is understood that by dividing a batch of images into multiple sub-batches of images, with each sub-batch as input to a batch and output of an intermediate layer of the network, the present invention can reduce the number of image samples required and improve training efficiency.
[0106] Based on the above embodiments, as an optional embodiment, the iterative unsupervised domain adaptation method provided by the present invention further includes:
[0107] Data augmentation processing is performed on each image sample based on the first preset enhancement algorithm to obtain a batch of images of the target size;
[0108] Specifically, the following data augmentation is performed on each image sample: random cropping -> random vertical flipping -> random horizontal flipping -> affine transformation, etc., to expand a single image into a batch of images of the target size.
[0109] The batch images are subjected to data enhancement processing based on the second preset enhancement algorithm to obtain the data-enhanced batch images.
[0110] Optionally, the second preset enhancement algorithm is the random cutout enhancement algorithm.
[0111] The proportion of Cutout enhancement used in each batch p C (0≤p C ≤1) is random. This processing aims to enhance the model's classification performance and generalization ability for the transfer data. The number of samples cut out in each batch is random.
[0112] The formula for the second preset enhancement algorithm is as follows:
[0113] N C =p C ×N;
[0114] Where, N C The enhanced batch images.
[0115] It is understandable that enhancing image samples can improve training accuracy.
[0116] The technical effects of the present invention will be described in detail below with reference to a specific embodiment.
[0117] Dataset: CIFAR-10 Level 5 Destruction Dataset
[0118] Model: ResNet-26 classification model
[0119] Domain migration test sets: CIFAR-10-C includes Gaussian Noise, Shot Noise, Impulse Noise, Defocus Blur, Glass Blur, Motion Blur, Zoom Blur, and Snow. Each sub-test set has 10,000 samples. The first seven domain migration test sets are caused by sensor-introduced noise; the latter four are caused by weather factors.
[0120] The method proposed in this invention does not require retraining the model. It only applies less than 0.5% of unlabeled domain transfer test data and updates the statistical parameters of the Batch Normalization (BN) layer online to adapt to the test set with almost no more than three iterations, thereby improving the model's performance on the test set. As shown in the table below, the method proposed in this invention achieves the minimum Top-1 classification error on the aforementioned sub-test sets and the minimum average error on the eight domain transfer datasets in Table 1.
[0121] Table 1 compares the Top-1 mean classification error of TTT, PTBN, DUA, and IUDA on eight CIFAR-10-C test sets with the mean error of the four methods.
[0122]
[0123]
[0124] Among them, TTT (Test-Time Training) adjusts network parameters before testing by using an auxiliary task on each (out-of-distribution) data sample. PTBN (Prediction-Time Batch Normalization) is a method based on test set statistics, ignoring the statistics of training samples and updating the batchnorm statistics of the entire test set in a large batch. DUA (Dynamic Unsupervised Domain Adaptation) is a dynamic unsupervised domain adaptation method.
[0125] The iterative unsupervised domain adaptive device provided by the present invention is described below. The iterative unsupervised domain adaptive device described below can be referred to in correspondence with the iterative unsupervised domain adaptive method described above.
[0126] Figure 4This is a schematic diagram of the iterative unsupervised domain adaptive device provided by the present invention, as shown below. Figure 4 As shown, the present invention also provides an iterative unsupervised domain adaptive device, comprising:
[0127] The acquisition module 410 is used to extract a preset number of image samples from the domain migration test set;
[0128] The adjustment module 420 is used to input the image samples into a preset iterative optimization algorithm and adjust the parameters of the pre-trained model according to the calculation results of the iterative optimization algorithm so that the adjusted model can adapt to the domain transfer test set.
[0129] The preset iterative optimization algorithm includes:
[0130] Data augmentation processing is performed on each of the image samples to obtain a batch of images of the target size;
[0131] Based on the batch of images, determine the parameter values of the model;
[0132] The model with determined parameter values is tested using the domain transfer test set to obtain the classification error.
[0133] After traversing all the image samples, the average classification error of the image samples is obtained based on the classification error.
[0134] As one embodiment, the adjustment module 420 is further configured to:
[0135] The features of the batch of images are normalized to obtain normalized feature data;
[0136] Based on the normalized feature data, the mean and variance of the features of the batch of images are obtained;
[0137] The parameter values of the model are obtained based on the mean and variance of the features of the batch of images.
[0138] As one embodiment, the adjustment module 420 is further configured to:
[0139] Based on the normalized feature data and dynamic decay momentum, the mean and variance of the features of the batch of images are obtained;
[0140] The dynamic decay momentum is obtained based on the dynamic decay coefficient, and the dynamic decay system is related to the number of iterations.
[0141] As one embodiment, the adjustment module 420 is further configured to:
[0142] The dynamic decay momentum is updated based on the dynamic decay coefficient.
[0143] If the average classification error meets the set conditions, the iteration ends.
[0144] As one embodiment, the adjustment module 420 is further configured to:
[0145] The batch of images is divided into multiple sub-batch images, and the features of the sub-batch images are normalized to obtain normalized feature data.
[0146] As one embodiment, the adjustment module 420 is further configured to:
[0147] Data augmentation processing is performed on each image sample based on the first preset enhancement algorithm to obtain a batch of images of the target size;
[0148] The batch images are subjected to data enhancement processing based on the second preset enhancement algorithm to obtain the data-enhanced batch images.
[0149] Figure 5 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 5 As shown, the electronic device may include: a processor 510, a communication interface 520, a memory 530, and a communication bus 540, wherein the processor 510, the communication interface 520, and the memory 530 communicate with each other through the communication bus 540. The processor 510 can call logical instructions in the memory 530 to execute an iterative unsupervised domain adaptive method, which includes:
[0150] A predetermined number of image samples are extracted from the domain migration test set;
[0151] The image samples are input into a preset iterative optimization algorithm, and the parameters of the pre-trained model are adjusted according to the calculation results of the iterative optimization algorithm so that the adjusted model can adapt to the domain transfer test set.
[0152] The preset iterative optimization algorithm includes:
[0153] Data augmentation processing is performed on each of the image samples to obtain a batch of images of the target size;
[0154] Based on the batch of images, determine the parameter values of the model;
[0155] The model with determined parameter values is tested using the domain transfer test set to obtain the classification error.
[0156] After traversing all the image samples, the average classification error of the image samples is obtained based on the classification error.
[0157] Furthermore, the logical instructions in the aforementioned memory 530 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0158] On the other hand, the present invention also provides a computer program product, the computer program product comprising a computer program that can be stored on a non-transitory computer-readable storage medium, wherein when the computer program is executed by a processor, the computer is capable of executing the iterative unsupervised domain adaptive method provided by the above methods, the method comprising:
[0159] A predetermined number of image samples are extracted from the domain migration test set;
[0160] The image samples are input into a preset iterative optimization algorithm, and the parameters of the pre-trained model are adjusted according to the calculation results of the iterative optimization algorithm so that the adjusted model can adapt to the domain transfer test set.
[0161] The preset iterative optimization algorithm includes:
[0162] Data augmentation processing is performed on each of the image samples to obtain a batch of images of the target size;
[0163] Based on the batch of images, determine the parameter values of the model;
[0164] The model with determined parameter values is tested using the domain transfer test set to obtain the classification error.
[0165] After traversing all the image samples, the average classification error of the image samples is obtained based on the classification error.
[0166] In another aspect, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to perform the iterative unsupervised domain adaptation method provided by the methods described above, the method comprising:
[0167] A predetermined number of image samples are extracted from the domain migration test set;
[0168] The image samples are input into a preset iterative optimization algorithm, and the parameters of the pre-trained model are adjusted according to the calculation results of the iterative optimization algorithm so that the adjusted model can adapt to the domain transfer test set.
[0169] The preset iterative optimization algorithm includes:
[0170] Data augmentation processing is performed on each of the image samples to obtain a batch of images of the target size;
[0171] Based on the batch of images, determine the parameter values of the model;
[0172] The model with determined parameter values is tested using the domain transfer test set to obtain the classification error.
[0173] After traversing all the image samples, the average classification error of the image samples is obtained based on the classification error.
[0174] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0175] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0176] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. An iterative unsupervised domain adaptive method, characterized in that, include: A predetermined number of image samples are extracted from the domain migration test set; The image samples are input into a preset iterative optimization algorithm, and the parameters of the pre-trained model are adjusted according to the calculation results of the iterative optimization algorithm so that the adjusted model can adapt to the domain transfer test set. The preset iterative optimization algorithm includes: Data augmentation processing is performed on each of the image samples to obtain a batch of images of the target size; Based on the batch images, the parameter values of the model are determined; the parameters of the model are BN layer statistical parameters. If the model has not yet been iterated, the initial BN layer statistical parameters of the model are used as prior information. After iteration, the BN layer statistical parameters corresponding to the model weights after iteration are used as prior information. The model with determined parameter values is tested using the domain transfer test set to obtain the classification error. After traversing all the image samples, the average classification error of the image samples is obtained based on the classification error. The average classification error is used to determine the condition for ending the iteration.
2. The iterative unsupervised domain adaptive method according to claim 1, characterized in that, Determining the parameter values of the model based on the batch of images includes: The features of the batch of images are normalized to obtain normalized feature data; Based on the normalized feature data, the mean and variance of the features of the batch of images are obtained; The parameter values of the model are obtained based on the mean and variance of the features of the batch of images.
3. The iterative unsupervised domain adaptive method according to claim 2, characterized in that, The step of obtaining the mean and variance of the features of the batch images based on the normalized feature data includes: Based on the normalized feature data and dynamic decay momentum, the mean and variance of the features of the batch of images are obtained; The dynamic decay momentum is obtained based on the dynamic decay coefficient, which is related to the number of iterations.
4. The iterative unsupervised domain adaptive method according to claim 3, characterized in that, Also includes: The dynamic decay momentum is updated based on the dynamic decay coefficient; If the average classification error meets the set conditions, the iteration ends.
5. The iterative unsupervised domain adaptive method according to claim 2, characterized in that, The normalization process for the features of the batch of images to obtain normalized feature data includes: The batch of images is divided into multiple sub-batch images, and the features of the sub-batch images are normalized to obtain normalized feature data.
6. The iterative unsupervised domain adaptive method according to claim 1, characterized in that, Also includes: Data augmentation processing is performed on each image sample based on the first preset enhancement algorithm to obtain a batch of images of the target size; The batch images are subjected to data enhancement processing based on the second preset enhancement algorithm to obtain the data-enhanced batch images.
7. An iterative unsupervised domain adaptive device, characterized in that, include: The acquisition module is used to extract a preset number of image samples from the domain migration test set; An adjustment module is used to input the image samples into a preset iterative optimization algorithm and adjust the parameters of the pre-trained model according to the calculation results of the iterative optimization algorithm, so that the adjusted model can adapt to the domain transfer test set. The preset iterative optimization algorithm includes: Data augmentation processing is performed on each of the image samples to obtain a batch of images of the target size; Based on the batch images, the parameter values of the model are determined; the parameters of the model are BN layer statistical parameters. If the model has not yet been iterated, the initial BN layer statistical parameters of the model are used as prior information. After iteration, the BN layer statistical parameters corresponding to the model weights after iteration are used as prior information. The model with determined parameter values is tested using the domain transfer test set to obtain the classification error. After traversing all the image samples, the average classification error of the image samples is obtained based on the classification error. The average classification error is used to determine the condition for ending the iteration.
8. 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, it implements the iterative unsupervised domain adaptive method as described in any one of claims 1 to 6.
9. 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, it implements the iterative unsupervised domain adaptive method as described in any one of claims 1 to 6.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the iterative unsupervised domain adaptive method as described in any one of claims 1 to 6.