Model test adaptive method, device, terminal and computer readable storage medium
By iteratively updating the model and optimizing the feature translation during the testing phase, the problem of insufficient optimization of the prediction results of the current batch of images by the model adaptation method in the existing technology is solved, and higher image classification accuracy and efficiency are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-19
- Publication Date
- 2026-04-07
AI Technical Summary
In existing technologies, the adaptive methods used by the model during testing do not adequately optimize the prediction results for the current batch of images, resulting in insignificant improvements in test performance.
By acquiring a pre-trained source domain model and a batch sequence of test images, the model is iteratively updated using the entropy loss function. The linear features before and after the update are determined, and translation optimization is performed to obtain the optimized features of the current batch. Finally, these features are input into the frozen classifier for prediction.
It improves the test accuracy of image classification, avoids the overfitting problem of the model on small-scale samples, and improves test efficiency and accuracy.
Smart Images

Figure CN119107522B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of deep learning and machine vision, and particularly relates to a model test adaptive method and device, a terminal and a computer readable storage medium. BACKGROUND
[0002] For deep learning vision analysis tasks, due to the distribution deviation between source domain data for training and target domain data for testing, the model trained by the source domain data has low performance when directly tested and inferred on the target domain data. Therefore, under the condition of distribution deviation between training and testing data, test-time adaptation as an important technical strategy to improve the test performance of the model has attracted much attention. Test-time adaptation aims to improve the flexibility and optimize the performance of the model by responding to the dynamic changes of the environment in the model inference stage. In the actual testing process, the model may be sensitive to unknown data distribution, and needs to be adjusted by target data. In real-world applications, due to storage limitations, bandwidth restrictions or privacy requirements, only pre-trained models can be distributed, and training data cannot be transmitted.
[0003] At present, the test-time adaptive method updates the model parameters using the current batch of images. Once the model is updated, the new model will be directly used to predict the next batch of test images, instead of being used to predict the current batch of images. Intuitively, the model that learns the knowledge of the current sample should be more suitable for the current batch of images itself. However, in the existing method, when the new model after updating is used to predict the current batch of images, the test performance does not improve significantly. That is, the existing test-time adaptive method is not sufficient to optimize the prediction results of the current batch of images.
[0004] Therefore, the prior art has defects and needs to be improved and developed. SUMMARY
[0005] The technical problem to be solved by the present application is to provide a model test adaptive method, device, terminal and computer readable storage medium to solve the problem that the test-time adaptive method of the prior art is not sufficient to optimize the prediction results of the current batch of images, aiming at the above defects of the prior art.
[0006] The technical solution adopted by the present application to solve the technical problem is as follows:
[0007] A model test adaptive method, wherein the method comprises:
[0008] obtaining a pre-trained source domain model and a test image batch sequence;
[0009] In the iterative updating of the source domain model based on each test image batch in the test image batch sequence, the current model is updated based on the current test image batch and a preset entropy loss function, and the linear feature before updating and the linear feature after updating corresponding to the current test image batch are determined;
[0010] According to the linear feature before updating and the linear feature after updating, the linear feature after updating is translated to obtain the current batch optimization feature;
[0011] The current batch optimization feature is input into the frozen classifier in the source domain model to obtain the prediction result of the current test image batch.
[0012] In an implementation manner of the present application, the updating of the current model based on the current test image batch and the preset entropy loss function, and the determination of the linear feature before updating and the linear feature after updating corresponding to the current test image batch, comprises:
[0013] The current model is updated based on the current test image batch and the preset entropy loss function to obtain an updated model;
[0014] The linear feature of the current test image batch is extracted by using the feature extractor in the current model to obtain the linear feature before updating;
[0015] The linear feature of the current test image batch is extracted by using the feature extractor in the updated model to obtain the linear feature after updating.
[0016] In an implementation manner of the present application, according to the linear feature before updating and the linear feature after updating, the linear feature after updating is translated to obtain the current batch optimization feature, which comprises:
[0017] According to the linear feature before updating and the linear feature after updating, the linear feature translation direction and the linear feature translation scale of the current test image batch are obtained;
[0018] The linear feature after updating is translated based on the linear feature translation direction and the linear feature translation scale to obtain the current batch optimization feature.
[0019] In an implementation manner of the present application, according to the linear feature before updating and the linear feature after updating, the linear feature translation direction and the linear feature translation scale of the current test image batch are obtained, which comprises:
[0020] The linear feature translation direction of the current test image batch is obtained according to the feature change from the linear feature before updating to the linear feature after updating;
[0021] calculate a relative feature change rate according to the pre-update linear feature and the post-update linear feature;
[0022] obtain a slope hyperparameter of a predetermined current test image batch;
[0023] calculate a linear feature translation scale according to the slope hyperparameter and the relative feature change rate.
[0024] In an implementation manner of the present application, the step of determining the slope hyperparameter comprises:
[0025] obtain a preset initial slope hyperparameter, and randomly select sample images in the current test image batch to obtain a random sample set;
[0026] perform linear feature translation on the random sample set based on the initial slope hyperparameter, and calculate a first entropy value of the translated feature corresponding to the initial slope hyperparameter;
[0027] obtain a preset step parameter, calculate a difference between the initial slope hyperparameter and the step parameter to obtain a first slope hyperparameter, and calculate a sum of the initial slope hyperparameter and the step parameter to obtain a second slope hyperparameter;
[0028] calculate a second entropy value of the translated feature corresponding to the first slope hyperparameter, and calculate a third entropy value of the translated feature corresponding to the second slope hyperparameter;
[0029] determine a minimum value among the first, second and third entropy values, and take the slope hyperparameter corresponding to the minimum value as the slope hyperparameter of the current test image batch.
[0030] In an implementation manner of the present application, the linear feature translation scale is calculated according to the slope hyperparameter and the relative feature change rate, comprising:
[0031] calculate an inverse of the relative feature change rate;
[0032] take a product of the inverse and the slope hyperparameter as the linear feature translation scale.
[0033] In an implementation manner of the present application, the post-update linear feature is translated based on the linear feature translation direction and the linear feature translation scale to obtain the current batch optimization feature, comprising:
[0034] calculate a product of the linear feature translation direction and the linear feature translation scale;
[0035] calculate a sum of the product and the post-update linear feature to obtain the current batch optimization feature.
[0036] The application also provides a model test adaptive device, wherein the device comprises:
[0037] an acquisition module, configured to acquire a pre-trained source domain model and a test image batch sequence;
[0038] an update module, configured to update a current model based on a current test image batch and a preset entropy loss function when iteratively updating the source domain model based on each test image batch in the test image batch sequence, and determine a pre-update linear feature and a post-update linear feature corresponding to the current model;
[0039] a translation module, configured to translate the post-update linear feature based on the pre-update linear feature and the post-update linear feature, to obtain a current batch optimization feature;
[0040] a prediction module, configured to input the current batch optimization feature into a frozen classifier in the source domain model, to obtain a prediction result of the current test image batch.
[0041] The application also provides a terminal, comprising a memory, a processor, and a model test adaptive program stored in the memory and executable on the processor, wherein the model test adaptive program, when executed by the processor, implements the steps of the model test adaptive method.
[0042] The application also provides a computer readable storage medium, wherein the computer readable storage medium stores a computer program executable for implementing the steps of the model test adaptive method.
[0043] The application provides a model test adaptive method, device, terminal and computer readable storage medium, the method comprising: acquiring a pre-trained source domain model and a test image batch sequence; updating a current model based on a current test image batch and a preset entropy loss function when iteratively updating the source domain model based on each test image batch in the test image batch sequence, and determining a pre-update linear feature and a post-update linear feature corresponding to the current test image batch; translating the post-update linear feature based on the pre-update linear feature and the post-update linear feature, to obtain a current batch optimization feature; and inputting the current batch optimization feature into a frozen classifier in the source domain model, to obtain a prediction result of the current test image batch. The application translates the post-update linear feature generated by the current model by using an unsupervised entropy loss function, optimizes the classification prediction result of the current test image batch, and each batch prediction result is adaptively optimized, thereby improving the overall image classification test accuracy. BRIEF DESCRIPTION OF DRAWINGS
[0044] Figure 1 is the basic process of test-time adaptation;
[0045] Figure 2 is a flow chart of the preferred embodiment of the model test-time adaptation method of the present application;
[0046] Figure 3 is a schematic diagram of the linear feature shift algorithm of the preferred embodiment of the model test-time adaptation method of the present application;
[0047] Figure 4 is the relationship between the feature shift scale and the average entropy loss in each batch of test samples of the preferred embodiment of the model test-time adaptation method of the present application;
[0048] Figure 5 is a logic diagram of the predictive feature shift algorithm of the preferred embodiment of the model test-time adaptation method of the present application;
[0049] Figure 6 is a logic diagram of the algorithm for calculating the slope hyperparameter of the preferred embodiment of the model test-time adaptation method of the present application;
[0050] Figure 7 is the relationship between the optimal feature shift scale and the reciprocal of the relative change rate of the features of the preferred embodiment of the model test-time adaptation method of the present application;
[0051] Figure 8 is a functional principle block diagram of the preferred embodiment of the model test-time adaptation device of the present application;
[0052] Figure 9 is a functional principle block diagram of the preferred embodiment of the terminal of the present application. DETAILED DESCRIPTION
[0053] In order to make the objects, technical solutions and advantages of the present application clearer and more explicit, the present application will be further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific examples described herein are only used to explain the present application and do not limit the present application.
[0054] For deep learning visual analysis tasks, due to the distribution bias between the source domain data used for training and the target domain data used for testing, the model trained by the source domain data has low performance when directly tested and inferred on the target domain data. In order to improve the test performance of the model, the target domain data will be used to further update the trained model at the test stage, and the real-time updated model will be used for sample prediction. This process is called online test-time adaptation, and the basic process is as shown in Figure 1
[0055] That is, when there is a data distribution shift between the source domain of model training and the target domain of testing, the testing performance of the network model will be significantly reduced. In order to improve the testing performance of the model, it is crucial to further update the model using the test data so that it is more suitable for the test data. However, in actual application scenarios, due to privacy restrictions, the test end cannot access the training data of the training end, and can only access the trained source domain neural network model; at the same time, the actual test sample is completely unsupervised, that is, the test sample label is unknown; in addition, in the actual test process, the test sample appears in the form of an online data stream, that is, each test sample can only be accessed once.
[0056] In view of the above defects, the embodiment of the present application provides a model testing self-adaptive method, which adjusts the intermediate features generated by the model in real time and unsupervised manner only by using unlabeled test samples without accessing the training data, so as to give more accurate prediction results for each batch of test images, and further improves the accuracy of image classification in the testing stage.
[0057] Please refer to Figure 2 , Figure 2 is a flowchart of the model testing self-adaptive method in the present application. As Figure 2 shown, the model testing self-adaptive method described in the embodiment of the present application comprises:
[0058] Step S100, obtaining a pre-trained source domain model and a test image batch sequence.
[0059] The source domain model is a model trained by source domain data, and the test image batch sequence is a test sample of the target domain. In view of the setting that the test end cannot access the training data of the training end in actual application, the requirement that the actual test sample label is unknown, and the special setting that each test sample in the online test data stream can only be accessed once, the embodiment of the present application only uses the test sample of the target domain, that is, the test image in the test image batch sequence, to meet the requirement of not accessing the training data of the training end.
[0060] Specifically, given a pre-trained source domain model, it is composed of a feature extractor model Θ s and a classifier model Φ s . Given N t test data contains unknown labels , where P t (x,y)≠P s (x,y), that is, the target domain data distribution is different from the source domain data distribution. As Figure 1 shown, for the adaptation of the inference process in online testing, the sequence of test image batches is denoted as {x 0 ,x 1 ,…,xJ-1}, where J is the total number of data batches. The weights of the network model are from Adjust to Only the j-th test sample batch x j The adjustment process involves M backpropagations and model updates. The model adjusted using the current j-th batch is passed to the next batch for further adjustment using the test images from that batch. In the first batch, With source model Θ s The weights are equal. M is usually set to 1 to avoid the model overfitting on the current mini-batch of samples; C represents the number of classes.
[0061] like Figure 2 As shown, the model testing adaptive method described in this embodiment further includes:
[0062] Step S200: When iteratively updating the source domain model based on each test image batch in the test image batch sequence, the current model is updated based on the current test image batch and a preset entropy loss function, and the linear features before and after the update corresponding to the current test image batch are determined.
[0063] Specifically, the entropy loss function is used to update the model in one step for the current batch of test images. The formula for the entropy loss function is:
[0064]
[0065] In the formula, Let N represent the loss value, j represent the j-th batch, and N represent the loss value. j Let C represent the total number of samples in the batch, C represent the number of categories, c represent the c-th category, i represent the i-th sample in the batch, and p represent the probability distribution. This indicates the model's prediction result for this batch of data.
[0066] The embodiments of this application employ an unsupervised entropy loss function to adjust and update the model and the intermediate features generated by the model, thereby providing more accurate prediction results for each batch of test images and further improving the accuracy of image classification during the testing phase.
[0067] In the embodiment of the present application, the current model is updated based on the current test image batch and the preset entropy loss function, and the pre-update linear features and the post-update linear features corresponding to the current test image batch are determined, which comprises: updating the current model based on the current test image batch and the preset entropy loss function to obtain a post-update model; extracting linear features of the current test image batch by using a feature extractor in the current model to obtain pre-update linear features; and extracting linear features of the current test image batch by using a feature extractor in the post-update model to obtain post-update linear features.
[0068] Specifically, the existing online test adaptive method updates model parameters in the test stage, and then performs prediction. This method is feasible in the dynamic flow data scene. The knowledge obtained by the model from the previously tested small batches can be continuously accumulated and then used for prediction of the next batch. The existing method mainly focuses on updating the parameters of the model or the input of the model in the test stage. In terms of updating the parameters of the model, other network layers are frozen, and only the parameters of the normalization layer in the model network are updated, the domain-specific knowledge is encoded into the statistical information and affine parameters of the batch data, so as to improve the prediction adaptability to the target domain test data. In terms of updating the input of the model, the input is adjusted in the test stage, so that the input adapts to the fixed pre-trained model, so as to improve the inference performance. However, the existing method only performs one round of iterative update on the model using the test samples of each batch, and the model cannot fully learn the knowledge in the test samples. For each online test image batch, if the number of model iterative updates is increased, the model will be over-fitted to the current small batch of data, which will lead to a decrease in the test accuracy of the subsequent batch samples, thereby leading to a decrease in the overall test performance, and also consuming more time for multiple gradient back propagation operations, thereby reducing the model inference efficiency.
[0069] The embodiment of the present application only needs one round of model parameter update to obtain the information required for feature adjustment and perform feature update, without multiple rounds of iterative update of the parameters of the model, which can avoid the over-fitting problem of the model on small-scale samples, reduce the inference time in the test stage, and improve the test efficiency.
[0070] As shown in Figure 2 The model test adaptive method of the embodiment further comprises:
[0071] In step S300, the post-update linear features are translated based on the pre-update linear features and the post-update linear features to obtain current batch optimization features.
[0072] The embodiment of the present application further reduces the classification entropy loss of each batch of test images by directly modifying the intermediate features generated by the model, avoids the over-fitting problem of the model on small-scale samples, and further improves the image classification accuracy in the test stage.
[0073] As shown in Figure 3 , for the current test image batch x j , the linear feature of the current model before being updated by the current test image batch can be expressed as A one-step update of the model is performed on the current jth test sample batch by using the entropy loss function . The model after being updated by the current test image batch is expressed as The updated linear feature is
[0074] Embodiments of the present application aim to solve the problem that the optimization of the prediction result of the current test image batch in the prior art is insufficient. The intermediate feature generated by the model is adjusted based on the feedback of the feature change information before and after the model is updated. In this way, for each batch of test images, the adjusted feature has a lower classification entropy loss, and the use of the adjusted feature for the classification prediction of the current batch can obtain a more optimal prediction result. Each batch prediction result is adaptively optimized, thereby improving the test accuracy of the overall image classification.
[0075] In the embodiments of the present application, the step S300 specifically comprises:
[0076] Step S310, obtaining the linear feature translation direction and linear feature translation scale of the current test image batch according to the updated linear feature and the updated linear feature;
[0077] Step S320, translating the updated linear feature based on the linear feature translation direction and the linear feature translation scale to obtain the current batch optimization feature.
[0078] Specifically, the feature change from the updated linear feature f0 to the updated linear feature f1 indicates an effective entropy loss function reduction direction for the current batch feature, and therefore the embodiments of the present application make the current feature translate along this direction, thereby generating a feature with a lower corresponding entropy loss function value, which is used to obtain a more accurate classification prediction.
[0079] The embodiments of the present application perform linear translation on the feature of the test image based on the information of the model update feedback to directly optimize the feature.
[0080] In an embodiment of the present application, the step S310 specifically comprises:
[0081] Step S311, obtaining the linear feature translation direction of the current test image batch according to the feature change from the updated linear feature to the updated linear feature;
[0082] Step S312, calculating the relative feature change rate according to the updated linear feature and the updated linear feature.
[0083] Step S313: Obtain the slope hyperparameter of the current test image batch that has been predetermined;
[0084] Step S314: Calculate the linear feature translation scale based on the slope hyperparameter and the relative feature change rate.
[0085] Specifically, the direction of linear feature translation is Δ f =f1-f0. From Figure 4 It can be seen that as the translation scale λ increases, that is, the greater the degree of feature translation in the direction of translation, the entropy loss function first reaches a local minimum. This implies that there exists an optimal translation scale.
[0086] Because λ is located directly through numerical search. * This method is very time-consuming. To address this issue, this application proposes an adaptive linear feature translation scaling method. The relative feature change rate between features f1 and f0 in the j-th batch is defined as v. j :
[0087]
[0088] Where ||·|| is the L1 norm, and N j This is the total number of sample batches.
[0089] according to Figure 4 As shown, this invention is based on the optimal translation scale λ * The reciprocal of the relative rate of change of each batch characteristic The high correlation between linear features and translation scales is used for modeling and calculation.
[0090]
[0091] Where α is the slope hyperparameter.
[0092] The specific algorithm for predictive feature translation is as follows: Figure 5 As shown in the figure, the embodiments of this application enable the target entropy loss of the model update to be reduced to a local minimum along the linear feature translation direction, which helps to make more accurate predictions. At the same time, the linear feature translation scale is also modeled and calculated so that the features can be translated to the point of minimum loss, thereby improving prediction accuracy.
[0093] In this embodiment of the application, the step of determining the slope hyperparameter includes:
[0094] Obtain the preset initial slope hyperparameters and randomly select sample images from the current batch of test images to obtain a random sample set;
[0095] Based on the initial slope hyperparameter, linear feature shifting is performed on the random sample set, and a first entropy value of the shifted feature corresponding to the initial slope hyperparameter is calculated;
[0096] A preset step parameter is obtained, a difference between the initial slope hyperparameter and the step parameter is calculated to obtain a first slope hyperparameter, and a sum of the initial slope hyperparameter and the step parameter is calculated to obtain a second slope hyperparameter;
[0097] A second entropy value of the shifted feature corresponding to the first slope hyperparameter is calculated, and a third entropy value of the shifted feature corresponding to the second slope hyperparameter is calculated;
[0098] The minimum value among the first entropy value, the second entropy value, and the third entropy value is determined, and the slope hyperparameter corresponding to the minimum value is taken as the slope hyperparameter of the current test image batch.
[0099] Specifically, for online testing to adapt to the task, the data set cannot be completely accessed to calculate the exact slope. To solve this problem, the embodiments of the present application first use a few samples in each batch to estimate the alpha hyperparameter before applying the linear feature shifting method to the current real-time batch data. Specifically, for each batch, first, based on an initial slope hyperparameter alpha = 0.2, linear feature shifting is applied to a very small randomly selected sample set x sub (such as 5 samples). Then, the value of alpha is increased and decreased by a step parameter delta, that is, delta + alpha and delta - alpha, and the entropy values of the shifted features corresponding to them are calculated respectively. The embodiments of the present application select the item that can make the entropy minimum among alpha, delta + alpha, or delta - alpha as the final slope hyperparameter. The specific algorithm of the slope hyperparameter is as shown in Figure 6 .
[0100] In the embodiments of the present application, the step S314 specifically includes:
[0101] Step S3141, calculating the reciprocal of the relative feature change rate;
[0102] Step S3142, taking the product of the reciprocal and the slope hyperparameter as the linear feature shifting scale.
[0103] As shown in Figure 7 , the relationship between the optimal shifting scale and the reciprocal of the relative feature change rate. The embodiments of the present application calculate the linear feature shifting scale by using the formula, which avoids the problem that directly searching for the linear feature shifting scale by numerical method is very time-consuming.
[0104] In an embodiment of the present application, the step S320 specifically includes:
[0105] Step S321, calculating the product of the linear feature translation direction and the linear feature translation scale;
[0106] Step S322, calculating the product and the sum of the updated linear features to obtain the current batch of optimized features.
[0107] Specifically, the current batch of optimized features f after translation adjustment can be obtained along the linear feature translation direction PFS = f1+ λ·Δ f where λ is the feature translation scale.
[0108] The embodiment of the present application obtains the current batch of optimized features by translating the updated features, without multiple iterative updates of the model parameters, and can further optimize the prediction results of the real-time test data batch, while avoiding model overfitting and effectively improving the model inference efficiency.
[0109] As shown in Figure 2 , the model test adaptive method described in the embodiment further comprises:
[0110] Step S400, inputting the current batch of optimized features into the frozen classifier of the source domain model to obtain the prediction results of the current test image batch.
[0111] Specifically, the current batch of optimized features is input into the frozen classifier Φ s to obtain the final prediction results.
[0112] The embodiment of the present application further translates the updated features when updating the source domain model for each test image batch, which improves the accuracy of visual tasks such as image classification under the condition of data distribution offset without increasing the number of iterative updates, and not only improves the inference ability of the model for test data when there is a difference between the source domain data distribution and the target domain data distribution, but also effectively deals with the uncertainty and variability in actual scenarios.
[0113] In one embodiment, as shown in Figure 8 , based on the above model test adaptive method, the present application further provides a model test adaptive device, comprising:
[0114] The acquisition module 100 is configured to acquire a pre-trained source domain model and a test image batch sequence.
[0115] The update module 200 is configured to update the current model based on the current test image batch and a preset entropy loss function when updating the source domain model iteratively based on each test image batch in the test image batch sequence, and determine the linear features before and after updating corresponding to the current model.
[0116] The translation module 300 is configured to translate the updated linear features according to the pre-update linear features and the post-update linear features, to obtain current batch optimization features.
[0117] The prediction module 400 is configured to input the current batch optimization features into the frozen classifier of the source domain model, to obtain a prediction result of a current test image batch.
[0118] Figure 9 A structure schematic diagram of a terminal is provided in the embodiments of the present application. The terminal can include:
[0119] The memory 501, the processor 502, and a computer program stored in the memory 501 and executable on the processor 502.
[0120] The processor 502 implements the model test adaptive method provided in the above embodiments when executing the program.
[0121] Further, the terminal further includes:
[0122] The communication interface 503 is configured to communicate between the memory 501 and the processor 502.
[0123] The memory 501 is configured to store the computer program executable on the processor 502.
[0124] The memory 501 can include a high-speed RAM memory, and can also include a non-volatile memory, for example, at least one disk memory.
[0125] If the memory 501, the processor 502, and the communication interface 503 are independently implemented, the communication interface 503, the memory 501, and the processor 502 can be connected to each other through a bus and complete communication between each other. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For convenience of representation, only one line is shown in the figure, but it does not mean that there is only one bus or only one type of bus.
[0126] Optionally, in specific implementation, if the memory 501, the processor 502, and the communication interface 503 are integrated on a chip, the memory 501, the processor 502, and the communication interface 503 can complete communication between each other through an internal interface.
[0127] The processor 502 can be a central processing unit (CPU), or an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement one or more embodiments of the application.
[0128] The embodiments also provide a computer readable storage medium, having stored thereon a computer program, which when executed by a processor, implements the model testing and adaptation method as described above.
[0129] In the description of the specification, the description of the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the application. In the description of the specification, the illustrative description of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any appropriate manner in one or N embodiments or examples. In addition, the person skilled in the art can combine and combine the different embodiments or examples described in the specification and the features of the different embodiments or examples, without contradiction.
[0130] In addition, the terms "first", "second" are only for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined with "first", "second" can explicitly or implicitly include at least one of the features. In the description of the application, the meaning of "N" is at least two, for example, two, three, etc., unless otherwise specifically limited.
[0131] Any process or method descriptions in flow charts or described elsewhere herein can be understood as representing code modules, segments, or portions of code that include one or more executable instructions for performing steps associated with the functions described in the flow charts or elsewhere herein, and that the scope of preferred embodiments of the application encompasses alterations, modifications, and variations of these code modules, segments, or portions of code. It should be noted that the use of the term "one embodiment" or "some embodiments" or "one example" or "some examples" in the description herein is intended to present an example of an implementation, as opposed to a necessary limitation. Numerous specific details are set forth in order to provide a thorough understanding of the application. However, it is understood that the application can be practiced without these specific details. In other instances, well-known methods, procedures, components, and circuits have not been described in detail since it is understood that people skilled in the art are generally aware of such processes, procedures, components, and circuits.
[0132] The logic and / or steps represented in the flowcharts and / or described herein, for example, can be considered as a list of instructions to implement a logical function, and can be embodied in any computer-readable medium for use by or in connection with an instruction execution system, apparatus, or device, such as a computer-based system, processor- based system, or other system that can fetch the instructions from the instruction execution system, apparatus, or device and execute the instructions, or a combination of both. In the context of this specification, a "computer-readable medium" can be any means that can contain, store, communicate, propagate or transport the program for use by or in connection with the instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of the computer-readable medium include the following: an electronic connection having one or N wires (electronic devices), a portable computer diskette (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, and a portable compact disc read-only memory (CDROM). In addition, the computer-readable medium can even be paper or other suitable medium upon which the program can be printed, because the program can be electronically obtained from the paper or other suitable medium, by optically scanning the paper or other suitable medium, then by editing, interpreting, or otherwise processing the optically scanned program to generate electronic data, and then storing the electronic data in a computer memory.
[0133] It should be understood that portions of the present application can be realized with hardware, software, firmware or a combination thereof. In the foregoing embodiments, the N steps or methods can be realized with software or firmware stored in a memory and executed by a suitable instruction execution system. If realized with hardware, as in another embodiment, any one or a combination of the following technologies known in the art can be used: discrete logic circuitry having logic gates for implementing logic functions on data signals, application specific integrated circuits having appropriate combinational logic gates, programmable gate arrays (PGA), field programmable gate arrays (FPGA), etc.
[0134] Those skilled in the art of the present technology can understand that all or part of the steps carried out by the above-mentioned embodiment methods can be completed by a program instructing relevant hardware, which can be stored in a computer-readable storage medium. When the program is executed, it includes one of the steps of the method embodiment or a combination thereof.
[0135] In addition, each of the function units in each of the embodiments of the present application can be integrated in one processing module, or each unit can be physically present separately, or two or more units can be integrated in one module. The integrated module can be realized in the form of hardware or in the form of a software function module. When the integrated module is realized in the form of a software function module and sold or used as an independent product, it can also be stored in a computer readable storage medium.
[0136] The storage medium mentioned above can be a read-only memory, a magnetic disk or an optical disk, etc. Although the embodiments of the present application have been shown and described above, it should be understood that the above embodiments are exemplary and should not be construed as limiting the present application, and those skilled in the art can make changes, modifications, replacements and variations to the above embodiments within the scope of the present application.
[0137] In summary, the model test adaptive method, device, terminal and computer readable storage medium disclosed by the present application, the method comprises: obtaining a pre-trained source domain model and a test image batch sequence; when each test image batch in the test image batch sequence is iteratively updated based on the source domain model, the current model is updated based on the current test image batch and the preset entropy loss function, and the linear feature before updating and the linear feature after updating corresponding to the current test image batch are determined; according to the linear feature before updating and the linear feature after updating, the linear feature after updating is translated to obtain the current batch optimization feature; the current batch optimization feature is input into the frozen classifier in the source domain model to obtain the prediction result of the current test image batch. The present application translates the linear feature after updating generated by the current model by using the unsupervised entropy loss function, optimizes the classification prediction result of the current test image batch, and each batch prediction result is adaptively optimized, thereby improving the overall image classification test accuracy.
[0138] It should be understood that the application of the present application is not limited to the above examples, and those skilled in the art can make improvements or changes according to the above description, and all these improvements and changes should belong to the protection scope of the claims of the present application.
Claims
1. An adaptive method for model testing, characterized in that, The method includes: Obtain the pre-trained source domain model and the batch sequence of test images; When iteratively updating the source domain model based on each test image batch in the test image batch sequence, the current model is updated based on the current test image batch and the preset entropy loss function, and the linear features before and after the update corresponding to the current test image batch are determined. Based on the linear features before and after the update, the updated linear features are shifted to obtain the optimized features for the current batch. The optimized features of the current batch are input into the frozen classifier in the source domain model to obtain the prediction results for the current batch of test images. Based on the linear features before and after the update, the updated linear features are shifted to obtain the optimized features for the current batch, including: Based on the linear features before and after the update, the linear feature translation direction and linear feature translation scale of the current test image batch are obtained; Based on the linear feature translation direction and linear feature translation scale, the updated linear feature is translated to obtain the current batch optimized feature; Based on the linear features before and after the update, the linear feature translation direction and linear feature translation scale of the current test image batch are obtained, including: The linear feature translation direction of the current test image batch is obtained based on the feature changes from the linear features before the update to the linear features after the update; Calculate the relative feature change rate based on the linear features before and after the update; Obtain the slope hyperparameters of the current batch of test images from a predetermined set. The linear feature translation scale is calculated based on the slope hyperparameter and the relative feature change rate.
2. The model testing adaptive method according to claim 1, characterized in that, The step of updating the current model based on the current batch of test images and a preset entropy loss function, and determining the linear features before and after the update corresponding to the current batch of test images, includes: The current model is updated based on the current batch of test images and the preset entropy loss function to obtain the updated model; The linear features of the current batch of test images are extracted using the feature extractor in the current model to obtain the linear features before the update; The updated linear features are obtained by using the feature extractor in the updated model to extract the linear features of the current batch of test images.
3. The model testing adaptive method according to claim 1, characterized in that, The steps for determining the slope hyperparameter include: Obtain the preset initial slope hyperparameters and randomly select sample images from the current batch of test images to obtain a random sample set; Based on the initial slope hyperparameter, a linear feature translation is performed on the random sample set, and the first entropy value of the translated feature corresponding to the initial slope hyperparameter is calculated. Obtain a preset step size parameter, calculate the difference between the initial slope hyperparameter and the step size parameter to obtain the first slope hyperparameter, and calculate the sum of the initial slope hyperparameter and the step size parameter to obtain the second slope hyperparameter; Calculate the second entropy value of the translated feature corresponding to the first slope hyperparameter, and calculate the third entropy value of the translated feature corresponding to the second slope hyperparameter; The minimum value among the first entropy value, the second entropy value, and the third entropy value is determined, and the slope hyperparameter corresponding to the minimum value is used as the slope hyperparameter of the current test image batch.
4. The model testing adaptive method according to claim 1, characterized in that, The linear feature translation scale is calculated based on the slope hyperparameter and the relative feature change rate, including: Calculate the reciprocal of the rate of change of the relative characteristic; The product of the reciprocal and the slope hyperparameter is used as the linear feature translation scale.
5. The model testing adaptive method according to claim 1, characterized in that, The updated linear features are translated based on the linear feature translation direction and linear feature translation scale to obtain the current batch optimized features, including: Calculate the product of the linear feature translation direction and the linear feature translation scale; The product is summed with the updated linear features to obtain the optimized features for the current batch.
6. A model testing adaptive device, characterized in that, The device includes: The acquisition module is used to acquire the pre-trained source domain model and the batch sequence of test images; The update module is used to update the current model based on the current test image batch and a preset entropy loss function when iteratively updating the source domain model based on each test image batch in the test image batch sequence, and to determine the linear features before and after the update corresponding to the current model. The translation module is used to translate the updated linear features based on the linear features before and after the update to obtain the optimized features for the current batch. The prediction module is used to input the optimized features of the current batch into the frozen classifier in the source domain model to obtain the prediction results for the current batch of test images. Based on the linear features before and after the update, the updated linear features are shifted to obtain the optimized features for the current batch, including: Based on the linear features before and after the update, the linear feature translation direction and linear feature translation scale of the current test image batch are obtained; Based on the linear feature translation direction and linear feature translation scale, the updated linear feature is translated to obtain the current batch optimized feature; Based on the linear features before and after the update, the linear feature translation direction and linear feature translation scale of the current test image batch are obtained, including: The linear feature translation direction of the current test image batch is obtained based on the feature changes from the linear features before the update to the linear features after the update; Calculate the relative feature change rate based on the linear features before and after the update; Obtain the slope hyperparameters of the current batch of test images from a predetermined set. The linear feature translation scale is calculated based on the slope hyperparameter and the relative feature change rate.
7. A terminal, characterized in that, include: The memory, the processor, and the model test adaptation program stored in the memory and executable on the processor, wherein the model test adaptation program, when executed by the processor, implements the steps of the model test adaptation method as described in any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that can be executed to implement the steps of the model testing adaptive method as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Feature alignment-based test stage adaptive learning method, device and equipment
CN117079070A
Model training method, image classification method, image classification device and storage medium
CN117422942A