Domain self-adaption method during testing based on memory playback and weighted entropy minimization
By introducing memory playback and weighted entropy minimization technology into the field adaptive method of testing, the impact of outliers on the model optimization process is solved, the classification ability of conventional samples and outliers are improved, and the stability and security of the model are ensured.
Patent Information
- Application Number
- CN202411935146.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-26
- Publication Date
- 2025-04-08
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing test-time domain adaptive methods are difficult to effectively identify and process when facing outliers, resulting in the misleading of model optimization process, impairing the ability to identify samples of known categories, and may bring safety risks.
Using a test-time domain adaptive method based on memory playback and weighted entropy minimization, filter outliers through comparison of data augmentation and source probability distribution, maintain a memory to store reliable samples, and use these samples to perform calculations of weighted entropy minimization losses to optimize the model.
It effectively reduces the impact of outliers on model updates, enhances the model's ability to classify conventional samples, improves the ability to identify outliers samples, avoids error optimization, and better distinguishes between normal samples and outliers without increasing costs.
Smart Images

Figure CN119782907A_ABST
Abstract
Description
Background Art
[0002] With the development of data and computing power, deep neural networks have achieved remarkable results in various fields. However, the effectiveness of deep networks is often based on the assumption that training data and test data come from the same distribution. In practical applications, distribution shift is usually unavoidable, which greatly reduces the effectiveness of the model after deployment. In order to solve the problem of distribution shift, domain adaptation during test time was proposed, which aims to use unlabeled test data to adjust the model during the test period to adapt to the distribution of test data.
[0003] Although previous test-time domain adaptation works have solved the problem of distribution shift well, they all assume that the test data and training data share a category space. However, in open scenarios, the test-time data is likely to contain samples from new semantic categories - outliers. The emergence of outliers usually brings two new problems: 1. Since test-time domain adaptation is usually based on unsupervised optimization objectives (such as entropy minimization, pseudo-labeling, etc.), the existence of outliers is likely to mislead the optimization process of the model, thereby damaging the model's ability to recognize samples of known categories; 2. Directly classifying outliers as normal samples will bring safety hazards. For example, in an autonomous driving system, directly classifying abnormal samples on the road (such as wild animals, falling rocks, etc.) as normal samples (such as cars) is likely to cause the system to operate incorrectly and cause traffic accidents. At this time, a better approach should be to identify abnormal samples and seek manual help. Although the harm caused by outliers is very serious, previous test-time domain adaptation works have mostly ignored this problem, so when encountering outliers, the algorithm is likely to fail or even produce worse results than the unadapted model. Summary of the invention
[0004] In order to solve the above problems, the present invention proposes a test-time domain adaptation method based on memory playback and weighted entropy minimization, which eliminates the influence of outliers on model updating to a great extent, thereby enhancing the model's classification ability for regular samples when there is a domain gap.
[0005] To achieve the above purpose, the technical solution adopted by the present invention is as follows:
[0006] A test-time domain adaptation method based on memory replay and weighted entropy minimization:
[0007] Step S1, select the pre-trained source model , online update model (which is optimized online and used for prediction) The current batch of data that needs to be predicted ;
[0008] Step S2, the current batch of data Perform data augmentation and input the augmented data into the online update model Get the augmented mean probability distribution :
[0009] ,
[0010] in, For data augmentation operations, To increase the total number of times;
[0011] Step S3: the current batch data Input source model Get the source probability distribution;
[0012] Step S4, filter the current batch data Augmented mean probability distribution Samples whose predicted categories are inconsistent with the source probability distribution, and the filtered augmented mean probability distribution For samples whose entropy is higher than the preset threshold, the entropy is calculated as follows:
[0013] ,
[0014] in, is entropy, Indicates category.
[0015] Step S5, add the samples filtered in step S4 to the memory. If the memory is full, remove the samples of the class with the highest class frequency in the memory to ensure the balance of samples in the memory. Through steps S1-S5, a memory is maintained, and the samples in the memory are reliable. Next, use the samples in the memory to optimize the model.
[0016] Step S6: Take out the memory samples and update the model online Perform forward prediction on the memory samples to obtain the predicted probability distribution of the memory samples;
[0017] Step S7, assign a weight to each memory sample according to the entropy of the predicted probability distribution of the memory sample, and calculate the weighted entropy minimization loss for the memory sample :
[0018] ,
[0019] Among them, M is the memory sample, represents the parameters of the online update model, is the weight of each memory sample, , Represents the i-th sample in the memory, represents the calculation of entropy;
[0020] Step S8, updating the model online based on the sharpness-aware minimization optimizer To optimize:
[0021] ,
[0022] In the formula, represents the sharpness-aware loss. represents the L-2 norm of a vector, represents the maximum radius of the neighborhood, Indicates the size of parameter change. It can be understood that while minimizing the loss function, it also minimizes the sharpness around the model parameter space, making the model's loss function plane as smooth as possible.
[0023] The beneficial effects of the present invention are:
[0024] The present invention proposes a test-time domain adaptation method based on memory playback and weighted entropy minimization, which reduces the impact of outliers on the optimization process of the test-time domain adaptation framework, reduces erroneous optimization and enhances the recognition ability of outlier samples.
[0025] The present invention is fast to implement and can better identify normal samples and outliers without additional cost, and can eliminate the influence of outliers on model updating to a great extent, thereby enhancing the model's classification ability for regular samples when there is a domain gap. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] Figure 1 This is a schematic diagram of the test-time domain adaptation method based on memory playback and weighted entropy minimization of the present invention. DETAILED DESCRIPTION
[0027] The present application is further described in detail below in conjunction with the embodiments. It should be understood that the specific embodiments described herein are only used to explain the relevant invention, rather than to limit the invention.
[0028] It should be noted that, in the absence of conflict, the embodiments of the present invention and the features in the embodiments can be combined with each other. The present invention will be described in detail with reference to the embodiments below.
[0029] The starting point of this invention is to explore how to stably perform domain adaptation during testing when outliers exist. Through analysis, it is found that the previous domain adaptation methods during testing cannot eliminate the influence of outliers very well and it is difficult to improve the ability to identify abnormal samples. Therefore, it is necessary to design a new algorithm to eliminate the influence of outliers on model updates and improve the system's ability to detect outliers.
[0030] The present invention provides a test-time domain adaptation method based on memory playback and weighted entropy minimization, the method comprising the following steps:
[0031] Step S1, select the pre-trained source model , online update model (which is optimized online and used for prediction) The current batch of data that needs to be predicted ;
[0032] Step S2, the current batch of data Perform data augmentation and input the augmented data into the online update model Get the augmented mean probability distribution :
[0033] ,
[0034] in, For data augmentation operations, To increase the total number of times;
[0035] Step S3: the current batch data Input source model Get the source probability distribution;
[0036] Step S4, filter the current batch data Augmented mean probability distribution Samples whose predicted categories are inconsistent with the source probability distribution, and the filtered augmented mean probability distribution For samples whose entropy is higher than the preset threshold, the entropy is calculated as follows:
[0037] ,
[0038] in, is entropy, Indicates category.
[0039] Step S5, add the samples filtered in step S4 to the memory. If the memory is full, remove the samples of the class with the highest class frequency in the memory to ensure the balance of samples in the memory. Through steps S1-S5, a memory is maintained, and the samples in the memory are reliable. Next, use the samples in the memory to optimize the model.
[0040] Step S6: Take out the memory samples and update the model online Perform forward prediction on the memory samples to obtain the predicted probability distribution of the memory samples;
[0041] Step S7, assign a weight to each memory sample according to the entropy of the predicted probability distribution of the memory sample, and calculate the weighted entropy minimization loss for the memory sample :
[0042] ,
[0043] Among them, M is the memory sample, represents the parameters of the online update model, is the weight of each memory sample, , Represents the i-th sample in the memory, represents the calculation of entropy;
[0044] Step S8, updating the model online based on the sharpness-aware minimization optimizer To optimize:
[0045] ,
[0046] In the formula, represents the sharpness-aware loss. represents the L-2 norm of a vector, represents the maximum radius of the neighborhood, Indicates the size of parameter change. It can be understood that while minimizing the loss function, it also minimizes the sharpness around the model parameter space, making the model's loss function plane as smooth as possible.
[0047] A computer-readable storage medium according to an embodiment of the present invention stores computer instructions, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to be executed by the computer to implement the above-mentioned test-time domain adaptation method based on memory playback and weighted entropy minimization.
[0048] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process and related instructions of the storage device and processing device described above can refer to the corresponding process in the aforementioned method embodiment and will not be repeated here.
[0049] In particular, according to an embodiment of the present disclosure, the process described above can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing a method. In such an embodiment, the computer program can be downloaded and installed from a network through a communication part, and / or installed from a removable medium. When the computer program is executed by a central processing unit (CPU), the above functions defined in the method of the present invention are executed. It should be noted that the above-mentioned computer-readable medium of the present invention can be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium can be, for example, - but not limited to - an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device, or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in combination with an instruction execution system, device, or device. The program code contained on the computer-readable medium may be transmitted using any suitable medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0050] Computer program code for carrying out the operations of the present invention may be written in one or more programming languages, or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, or as a stand-alone software package.
[0051] The terms "first", "second", etc. are used to distinguish similar objects rather than to describe or indicate a particular sequence or order.
[0052] The term "comprise" or any other similar term is intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus / device that includes a list of elements includes not only those elements but also other elements not expressly listed, or also includes elements inherent to such process, method, article, or apparatus / device.
[0053] So far, the technical solutions of the present invention have been described, but it is easy for those skilled in the art to understand that the protection scope of the present invention is obviously not limited to these specific embodiments. Without departing from the principle of the present invention, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions after these changes or substitutions will fall within the protection scope of the present invention.
Claims
1. A test-time domain adaptation method based on memory playback and weighted entropy minimization, characterized in that Minimizing the impact of outliers on model optimization, the method comprising: Step S1, select the pre-trained source model , online update model , the current batch of data that needs to be predicted ; Step S2, the current batch of data Perform data augmentation and input the augmented data into the online update model Get the augmented mean probability distribution : , in, For data augmentation operations, To increase the total number of times; Step S3: The current batch data Input source model Get the source probability distribution; Step S4, filter the current batch data Augmented mean probability distribution Samples whose predicted categories are inconsistent with the source probability distribution, and the filtered augmented mean probability distribution For samples whose entropy is higher than the preset threshold, the entropy is calculated as follows: , in, is entropy, Indicates category; Step S5, adding the samples filtered in step S4 to the memory. If the memory is full, remove the samples of the class with the highest class frequency in the memory to ensure the balance of the samples in the memory. Step S6: Take out the memory samples and update the model online Perform forward prediction on the memory samples to obtain the predicted probability distribution of the memory samples; Step S7, assign a weight to each memory sample according to the entropy of the predicted probability distribution of the memory sample, and calculate the weighted entropy minimization loss for the memory sample : , Among them, M is the memory sample, represents the parameters of the online update model, is the weight of each memory sample, , Represents the i-th sample in the memory, represents the calculation of entropy; Step S8, updating the model online based on the sharpness-aware minimization optimizer To optimize: , In the formula, represents the sharpness minimization loss, represents the L-2 norm of a vector, represents the maximum radius of the neighborhood, Indicates the size of parameter change.
2. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to be executed by the computer to implement the test-time domain adaptation method based on memory playback and weighted entropy minimization as described in claim 1.
Citation Information
Patent Citations
Abnormal signal semi-supervised classification method and system, and data processing terminal
CN113541834A
Memory resource peak parallel scheduling system
CN118152143A
Method for constructing clustering model, device, medium, and program product
WO2023045925A1