A test method and device of a deep learning model, an electronic device and a storage medium

CN116149972BActive Publication Date: 2026-08-21HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111372034.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-18
Publication Date
2026-08-21
Estimated Expiration
2041-11-18

AI Technical Summary

Technical Problem

[0006]大量研究指出,即使深度学习模型被训练得很好,输出M(I)的精度已经达到最高(例如达到百分之九十九以上的精度),少量噪声足以导致输出错误M(I+E)的精度显著低于正确输出M(I)的精度

Benefits of technology

[0011]为了解决上述的问题,本申请的实施例提供了一种深度学习模型的测试的方法、装置、终端设备和系统。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116149972B_ABST
    Figure CN116149972B_ABST
Patent Text Reader

Abstract

The application provides a test method of a deep learning model, including: inputting picture data I into a deep learning model, obtaining a perturbation value of a neuron according to a difference in output of each neuron in the deep learning model before and after adding noise E, and the number of neurons in the deep learning model M is n; selecting n neurons with the largest perturbation value from the n neurons as sampling neurons, wherein n < n; obtaining a perturbation distribution of each neuron in the n sampling neurons according to the perturbation value of the n sampling neurons; the perturbation distribution of the neuron includes convergence and non-convergence; determining the number of neurons with non-converged perturbation distribution as n according to the perturbation distribution of each neuron in the n neurons, wherein n < n; updating parameters of the noise through back propagation for the n neurons with non-converged perturbation distribution, and repeating the above steps; and completing the test of the deep learning model in the case that the number of neurons with non-converged perturbation distribution is 0.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of artificial intelligence, and more particularly to a testing method, apparatus, electronic device, and storage medium for a deep learning model. Background Technology

[0002] Deep learning is a mathematical equation used to build and simulate the human brain's analytical learning process, a technique that interprets data by mimicking the mechanisms of the human brain. A deep learning model is a model obtained after analyzing and solving a specific deep learning problem. Neurons are an important component of a deep learning model, used to connect the upper and lower layers of the model and pass parameters.

[0003] Deep learning models are used in intelligent applications, including autonomous driving and intelligent manufacturing. However, a large number of documents and real-world cases have pointed out that when the input of a deep learning model is noisy, the output of the deep learning model is prone to errors.

[0004] Figure 1 This example demonstrates how a deep learning model can output incorrectly due to noise. Given input data I, which is a road condition image, when the road condition image I is input into the autonomous driving deep learning model M, the output M(I) is "stop". In this example, "stop" is the correct deep learning model output. However, if environmental noise E (such as raindrops) is added to the road condition image I, and then I+E is input into the deep learning model, the output M(I+E) is "accelerate". Since M(I+E) is not equal to M(I), and M(I) is the correct output, M(I+E) is an incorrect output.

[0005] The purpose of testing deep learning models is to find as many errors as possible M(I+E), that is, M(I+E) that are not equal to M(I).

[0006] Numerous studies have shown that even when a deep learning model is well-trained and the accuracy of the output M(I) has reached its maximum (e.g., over 99%), a small amount of noise is enough to cause the accuracy of the output error M(I+E) to be significantly lower than that of the correct output M(I).

[0007] The purpose of deep learning testing techniques is to find as many erroneous outputs as possible M(I+E), and then use these erroneous M(I+E) to repair the deep learning model so that the outputs M(I) and M(I+E) have nearly the same accuracy.

[0008] The principle of traditional software testing is that the testing tool uses static or dynamic analysis methods to generate a test set to traverse as many control flow branches in the software as possible, so as to find all errors in the target software, such as incorrect output, program crashes, etc. This approach is more efficient than the method of randomly searching for software errors, which means randomly generating software inputs to search for program errors.

[0009] Inspired by software testing, deep learning model testing searches for errors in a deep learning model by traversing the "control flow branches" of the deep learning model. In theory, the neurons of a deep learning model carry the control flow branches of the deep learning model. Therefore, the principle of deep learning model testing is to generate a test set I+E to traverse the control flow branches of the neurons in the deep learning model, that is, the output values of the neurons, and efficiently search for a large number of errors in the deep learning model. Summary of the Invention

[0010] The technical problems to be solved by the embodiments of this application include that globally testing all neurons will become a bottleneck in terms of time. The optimal granularity for traversing the output values of neurons cannot be analyzed theoretically, so manual debugging is required, which is difficult and error-prone.

[0011] To solve the above problems, the embodiments of this application provide a method, device, terminal device, and system for testing a deep learning model.

[0012] In a first aspect, the embodiments of this application provide a method for testing a deep learning model. The method includes: inputting image data into the deep learning model; obtaining the perturbation value of each neuron in the deep learning model according to the difference in the output of each neuron in the deep learning model before and after adding noise, where the number of neurons in the deep learning model is n; selecting k neurons with the largest perturbation values from the n neurons as sampling neurons, where k << n; obtaining the perturbation distribution of each neuron among the k sampling neurons according to the perturbation values of the k sampling neurons; the perturbation distribution of the neurons includes convergence and non-convergence; determining that the number of neurons with non-convergent perturbation distribution among the k neurons is m, where m < k; updating the parameters of the noise E for the m neurons with non-convergent perturbation distribution through backpropagation; and completing the testing of the deep learning model when the number of neurons with non-convergent perturbation distribution is 0. In this way, this application can find neurons that are prone to trigger errors, preferentially traverse the output values of neurons that are prone to trigger errors to avoid exhaustive search; and use backpropagation for training to obtain a new test set, so that when the test completion rate reaches 100%, a large number of errors in the deep learning model can be found.

[0013] In one implementation, obtaining the perturbation value of each neuron in the deep learning model based on the difference in output of each neuron before and after adding noise includes: obtaining a first output of each neuron in the deep learning model based on the input image data; adding noise to the image data to obtain a second output of each neuron in the deep learning model; and obtaining the perturbation value of each neuron based on the difference between the first and second outputs. This way, the impact of the current noise on the output of each neuron in the deep learning model is obtained.

[0014] In one implementation, selecting k neurons with the largest perturbation values ​​from the n neurons as sampling neurons includes: traversing the perturbation value output by each neuron for each image data in the sampling dataset, and calculating the variance of the perturbation value of each of the n neurons; the sampling dataset includes multiple different image data; and selecting k neurons with the largest variance of perturbation values ​​from the n neurons as sampling neurons. In this way, by utilizing the magnitude of the neuron perturbation values, a minority of neurons can be identified from the millions of neurons in the deep learning model. Prioritizing the traversal of the output values ​​of these neurons allows for more efficient searching for errors in the deep learning model, reducing the computational load required during subsequent model testing.

[0015] In one embodiment, obtaining the perturbation distribution of each of the k sampled neurons based on the perturbation values ​​of the k sampled neurons includes: fitting the perturbation distribution of each of the k sampled neurons using the MCMC algorithm based on the perturbation values ​​of the k sampled neurons. Thus, the MCMC algorithm is used to obtain the convergence degree of the perturbation distribution of the neuron with the largest perturbation value. In existing differential equation theory, neuron perturbation and Markov chain Monte Carlo (MCMC) is the optimal method for detecting the convergence degree of the perturbation distribution of differential operators, and can obtain the optimal granularity of traversing the output values ​​of neurons. In another embodiment, obtaining the perturbation distribution of each of the k sampled neurons based on the perturbation values ​​of the k sampled neurons includes: calculating the variance of the perturbation value of each of the k sampled neurons based on the perturbation value of each neuron in each data point of the sampled dataset; the sampled dataset includes multiple different image data; and fitting the perturbation distribution of each of the k sampled neurons using the MCMC algorithm based on the variance of the perturbation value of each neuron in the k sampled neurons. In this way, the convergence of the perturbation distribution of each neuron among the k sampling neurons with the largest perturbation values ​​can be fitted by the MCMC algorithm, so as to obtain the optimal granularity of the output values ​​of the traversed neurons, so as to complete the subsequent calculation.

[0016] In one implementation, obtaining the perturbation distribution of each of the k sampled neurons based on the perturbation values ​​of the k sampled neurons includes: calculating the Monte Carlo Standard Error (MCSE) value of the perturbation distribution of each neuron based on the perturbation distribution of each neuron; when the MCSE value is zero, the perturbation distribution of the corresponding neuron is convergent; when the MCSE value is not zero, the perturbation distribution of the corresponding neuron is non-convergent. In this way, neurons with non-convergent perturbation distributions can be identified, i.e., neurons prone to triggering errors. Prioritizing the output values ​​of these error-prone neurons avoids exhaustive search.

[0017] In one implementation, updating the parameters of the noise E through backpropagation for the m neurons with non-converged perturbation distributions includes: calculating the gradient of the noise based on the m neurons with non-converged perturbation distributions; performing backpropagation based on the noise gradient; and updating the values ​​of the noise E parameters based on the backpropagation result. This allows for the generation of a new test set I+E, enabling optimal granularity traversal of the control flow branches of the deep learning model's neurons, efficiently searching for errors in a large number of deep learning models, and avoiding exhaustive search.

[0018] In one implementation, calculating the gradient of the noise based on m neurons with non-converged perturbation distribution includes calculating the loss function of the deep learning model based on the m neurons with non-converged perturbation distribution; and taking the derivative of the loss function with respect to the noise to obtain the gradient of the noise. This allows it to be used in conjunction with optimization algorithms such as gradient descent to train the deep learning model and update the weights to minimize the loss function.

[0019] In one implementation, updating the value of the noise E parameter based on the backpropagation result includes: when the backpropagation result is the sum of the perturbation values ​​of the m non-converged neurons is maximized, updating the parameter value of the noise E based on the gradient of the current noise. Thus, this embodiment of the application utilizes backpropagation to search for offset values ​​and corresponding inputs that cause large perturbations in neurons by modifying the parameters of the noise E, thereby reducing the time required for testing.

[0020] Second aspect, an embodiment of the present application provides a testing device for a deep learning model. The device includes: a data reading module for inputting image data into the deep learning model; a perturbation value calculation module for obtaining the perturbation value of each neuron in the model according to the difference in the output of each neuron in the deep learning model before and after adding noise, where the number of neurons in the deep learning model is n; a sampling module for selecting k neurons with the largest perturbation values from the n neurons as sampling neurons, where k << n; a perturbation distribution fitting module for obtaining the perturbation distribution of each of the k sampling neurons according to the perturbation values of the k sampling neurons; the perturbation distribution of the neuron includes convergence and non-convergence; a non-convergent neuron determination module for determining that the number of neurons with non-convergent perturbation distribution is m according to the perturbation distribution of each of the k neurons, where m < k; a backpropagation module for updating the parameters of the noise E through backpropagation for the m neurons with non-convergent perturbation distribution; when the number of neurons with non-convergent perturbation distribution is 0, the testing of the deep learning model is completed. The beneficial effects are the same as those described in the first aspect and will not be elaborated here.

[0021] Third aspect, an embodiment of the present application provides an electronic device, including: at least one memory for storing programs; and at least one processor for executing the programs stored in the memory. When the programs stored in the memory are executed, the processor is used to execute the method according to any one of the first aspect.

[0022] Fourth aspect, an embodiment of the present application provides a storage medium, in which instructions are stored. When the instructions are run on a terminal, the first terminal is caused to execute the method according to any one of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] In order to more clearly illustrate the technical solutions of the multiple embodiments disclosed in this specification, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the drawings in the following description are only the multiple embodiments disclosed in this specification. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0024] The following briefly introduces the drawings required for the description of the embodiments or the prior art.

[0025] Figure 1 It is a schematic diagram of a deep learning model for autonomous driving in the background technology;

[0026] Figure 2 It is a schematic diagram of the deep learning model for the first test in the second solution;

[0027] Figure 3 A schematic diagram of the deep learning model that has completed all tests in the second scheme;

[0028] Figure 4 A schematic diagram of a deep learning model with multiple erroneous outputs in the second approach;

[0029] Figure 5 This is a schematic diagram of the neuron output values ​​that trigger model errors provided in the embodiments of this application;

[0030] Figure 6 A scene diagram for obtaining neurons prone to triggering errors through perturbation values, provided in an embodiment of this application;

[0031] Figure 7 Example diagram of the backpropagation principle provided in the embodiments of this application;

[0032] Figure 8 A system architecture diagram of the testing method for the deep learning model provided in the embodiments of this application;

[0033] Figure 9 A flowchart illustrating the testing method for the deep learning model provided in the embodiments of this application;

[0034] Figure 10 A flowchart illustrating the process of obtaining error-prone neurons based on neuron perturbation and the MCMC algorithm in the testing method for the deep learning model provided in this application embodiment;

[0035] Figure 11 A schematic diagram of the perturbation distribution of each neuron in the fitting error-prone neurons in the testing method of the deep learning model provided in the embodiments of this application;

[0036] Figure 12 A flowchart of the noise optimization algorithm based on backpropagation in the testing method of the deep learning model provided in the application embodiment;

[0037] Figure 13 A schematic diagram of the testing method for the deep learning model provided in Example 1 of the application implemented in PyTorch;

[0038] Figure 14 A flowchart of Themis, an instance of the testing method for the deep learning model provided in Example 1 of the application, on PyTorch;

[0039] Figure 15 A schematic diagram comparing the accuracy of Themis and other testing tools provided in Embodiment 1 of this application;

[0040] Figure 16 A comparative diagram of the error detection capabilities of Themis and other testing tools provided in Embodiment 1 of this application;

[0041] Figure 17 A comparative schematic diagram showing the improvement in model accuracy brought about by Themis and other testing tools provided in Embodiment 1 of this application;

[0042] Figure 18 A schematic diagram comparing the model performance overhead introduced by Themis and other testing tools provided in Embodiment 1 of this application;

[0043] Figure 19 A testing apparatus for a deep learning model provided in the embodiments of this application;

[0044] Figure 20 An electronic device provided in an embodiment of this application. Detailed Implementation

[0045] In the following description, references are made to “some embodiments,” which describe a subset of all possible embodiments. However, it is understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.

[0046] In the following description, the terms “first, second, third, etc.” or module A, module B, module C, etc. are used only to distinguish similar objects and do not represent a specific ordering of objects. It is understood that a specific order or sequence may be interchanged where permitted so that the embodiments of this application described herein can be implemented in an order other than that illustrated or described herein.

[0047] In the following description, the labels of the steps, such as S110, S120, etc., do not necessarily mean that the steps will be executed in this way. The order of the steps can be interchanged or executed simultaneously if permitted.

[0048] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.

[0049] First, combine with the appendix Figure 1-4 The technical solutions related to the embodiments of this application are described below.

[0050] The first approach is an exhaustive method, which requires testing the deep learning model and iterating through all the model's predicted output values ​​and neuron outputs. This method can completely iterate through these neuron output values ​​and find the relevant deep learning model errors.

[0051] The brute-force approach is inherently inefficient. First, most mainstream deep learning models currently have over a million neurons, and the brute-force approach requires traversing all neurons, resulting in millions of computations per traversal. Second, the brute-force approach iterates through all model inputs (I). In autonomous driving, datasets are enormous, often using frames from several hours of video as model inputs, further increasing the testing burden. Compared to other approaches, the brute-force approach is extremely time-consuming and inefficient.

[0052] The second approach is a non-exhaustive approach. Since the output value of a neuron is a discrete number between positive and negative infinity, it is impossible to traverse all the output values ​​of the neuron. In order to efficiently test the deep learning model and search for errors, the output value of the neuron can be divided into several intervals and these intervals can be used as the traversal to reduce the number of neuron output values ​​that need to be traversed.

[0053] like Figure 2 As shown, the classic deep learning model testing technique DeepXplore divides the output of neurons into two intervals: greater than zero and less than zero, and generates a test set to iterate through these intervals. For example, the testing technique inputs training data I and noise E into a deep learning model M. The output of neuron N1 is 0.1, which is greater than 0, so the interval where N1's output value is greater than 0 is traversed. The output of neuron N2 is -2.9, which is less than 0, so the interval where N2's output value is less than 0 is traversed. And so on. In this example, since each neuron has traversed one of the intervals between greater than zero and less than zero, meaning that half of the output intervals of all neurons have been traversed, the test completion rate is improved from zero to 50%. Next, as... Figure 3 As shown, the testing technique selects another training data (I') and adds new noise (E') to generate new neuron output values. This process iterates through the untraversed neuron output intervals. Since the new output value of N1 is -13.7, which is less than 0, the interval where N1's output value is less than 0 has been traversed. The output value of neuron N2 is 1.1, which is greater than 0, so the interval where N2's output value is greater than 0 has been traversed. And so on. Since the new test data has traversed all neuron output value intervals, the test completion rate reaches 100%. In other words, DeepXplore's testing technique considers all deep learning model errors to have been found, so the testing technique completes the test and stops.

[0054] While the non-exhaustive approach of coarse-grainedly segmenting neuron outputs can significantly improve the speed of deep learning model testing, it often results in a large number of deep learning model errors being overlooked. This is because the optimal granularity for traversing neuron outputs cannot be theoretically analyzed; not all neurons have the same optimal granularity, requiring repeated manual adjustments, which is difficult and error-prone. In reality, the optimal granularity is often finer than the manually selected granularity. Experiments show that the second approach to deep learning model testing occasionally fails to find any deep learning errors even when the testing completion rate reaches 100%.

[0055] The second approach, which iterates through neuron output values ​​in a coarse-grained manner, has problems, such as... Figure 4 The deep learning model shown has multiple erroneous outputs. Suppose that for deep learning model M, when the output value of a neuron is -1.1, -0.5, 0.1, 0.2, 1.3, 1.4, ..., deep learning model M is likely to make an error. When the test set (I+E) traverses the value 0.1, the region of output values ​​greater than 0 of N1 is covered. Other important output values ​​of N1 that are greater than zero, such as 0.2, 1.3, and 1.4, will not be traversed. This causes a large number of deep learning model errors to be ignored.

[0056] Ideally, a testing process should automatically generate a test set, allowing it to iterate through all important neuron output values. However, important neuron output values ​​are often unknown and difficult to obtain through theoretical analysis. Currently, only exhaustive methods, such as iterating through all neuron outputs, can completely traverse these neuron output values ​​and find related deep learning model errors. But as mentioned earlier, neuron output values ​​range from negative infinity to positive infinity, making exhaustive methods generally impractical.

[0057] To facilitate understanding of the testing methods for deep learning models provided in the embodiments of this application, the overall concept and principles of the embodiments of this application are first introduced.

[0058] To greatly improve the efficiency of searching for errors in deep learning models, this application embodiment selects to prioritize traversing neurons that are prone to triggering errors. Neurons that are prone to triggering errors are those whose absolute output value is highly likely to cause errors in the deep learning model.

[0059] Figure 5 This diagram illustrates the output values ​​of neurons that are prone to triggering model errors, as provided in the embodiments of this application. Figure 5 As shown, neuron N1 has more output values ​​that trigger errors in the deep learning model than neuron N5. This means that neuron N1 has more error control flow branches than neuron N5. Prioritizing the traversal of neuron N1's output values ​​can more efficiently identify errors in the deep learning model. Neuron N1 is the neuron most likely to trigger model errors.

[0060] However, the output values ​​of neurons that are likely to trigger errors in deep learning models are generally unknown and cannot be found theoretically. Therefore, the embodiments of this application require improvements in three aspects: Improvement 1: Identify neurons that are prone to triggering errors; Improvement 2: After identifying neurons that are prone to triggering errors, efficiently iterate through the output values ​​of these neurons to avoid exhaustive search; Improvement 3: Calculate the test completeness so that when the test completeness reaches 100%, a large number of deep learning model errors can be found.

[0061] The testing method for the deep learning model provided in this application improves upon the above three aspects by utilizing neuron perturbation and backpropagation. The principles of neuron perturbation and backpropagation are described below.

[0062] The principle of neuron perturbation is as follows: For any input data I, before adding noise E, the output of each neuron in the deep learning model is N(I), and after adding noise E, the output of each neuron in the model is N(I+E). The larger the absolute value of the difference between N(I+E) and N(I), the greater the perturbation of the neuron.

[0063] Figure 6 This is a schematic diagram illustrating how to obtain neurons prone to triggering errors through neuron perturbation values, as provided in an embodiment of this application. Figure 6 As shown, after inputting the dataset I+E into the deep learning model M, a perturbation distribution map can be plotted for the output of each neuron. The horizontal axis of the perturbation distribution map represents the perturbation value, and the vertical axis represents the frequency of the perturbation value. According to the perturbation distribution map, the perturbation distribution of neuron N1 has a larger variance than that of neuron N5. Therefore, the noise E causes a greater perturbation to neuron N1. In other words, iterating through the output values ​​of neuron N1 is more likely to trigger errors. Therefore, prioritizing the iteration through the output values ​​of neuron N1 can more efficiently search for errors in the deep learning model M. N1 is a neuron more prone to triggering errors than neuron N5.

[0064] Backpropagation is a common algorithm used in conjunction with optimization algorithms such as gradient descent to train deep learning models. It calculates the gradients of all functions in the network and feeds these gradients back to the optimization algorithm to update the weights and minimize the loss function. Backpropagation first calculates the output value of each node using a forward propagation approach, and then calculates the partial derivatives of the loss function with respect to each parameter by traversing the graph using backpropagation.

[0065] Figure 7 An example diagram illustrating the backpropagation principle provided in an embodiment of this application. For example... Figure 7As shown, assuming that the perturbation value of neuron N1 is 1.1 for input data I and noise E, then N1(I+E)- N1(I) =1.1, and then the noise parameters are fine-tuned according to the backpropagation algorithm.

[0066] For example, using raindrops as noise and raindrop size as the noise parameter, we observe the change in the perturbation of neuron N1 caused by raindrop noise after adjusting the raindrop size. Using the backpropagation algorithm, if increasing the raindrop size and determining that the new raindrop noise increases the perturbation value of neuron N1, and noise E' causes a greater perturbation to N1 than noise E, the raindrop size can be further increased until increasing the raindrop size can no longer further increase the perturbation value of neuron N1. During this process, new noises E'' and E''' are generated through the backpropagation algorithm. When the raindrop size is increased to E''', the perturbation of the neuron output by the raindrop noise becomes smaller; for example, E''' perturbs N1 by 4.0, and E''' perturbs N1 by 3.3. Therefore, we stop adjusting the raindrop size, and use the raindrop noise E'' as the output of the backpropagation, thereby generating a data set I+E, which becomes the new test set.

[0067] In this embodiment, backpropagation is used to test the model. The neuron N(I+E) value that causes large perturbations is denoted as the "offset value". These are the neuron output values ​​that are likely to trigger errors in the deep learning model.

[0068] It should be understood that in the testing method of the deep learning model provided in this application embodiment, not all N(I+E) are important; only N(I+E) that causes large perturbations are important. Therefore, this application embodiment utilizes backpropagation to search for offset values ​​and corresponding inputs I+E that cause large perturbations in neurons by modifying the parameters of noise E, thereby reducing the time required for testing.

[0069] Based on the principles of neuronal perturbation and backpropagation described above, the following will be combined with the appendix provided in this application. Figure 8-17 This application describes a testing method for a deep learning model provided in an embodiment.

[0070] Figure 8 This is a system architecture diagram of the testing method for the deep learning model provided in the embodiments of this application. (See diagram below.) Figure 8 As shown, the system structure of this application embodiment includes: a perturbation calculation module 81, a completion test module 82, and a backpropagation module 83.

[0071] The perturbation calculation module 81 inputs the data I and noise E from the dataset into the deep learning model, obtains the outputs N(I) and N(I+E) of each neuron, calculates the perturbation value of each neuron, and selects the k neurons with the largest perturbation values. For example, the value of k can be 1000. The perturbation calculation module 81 can be referred to as the first stage of model testing.

[0072] In the first stage, by using the magnitude of the neuron perturbation value, a small number of neurons, such as 1,000, can be identified from the millions of neurons in the deep learning model. These 1,000 neurons can be used as neurons that are prone to triggering errors, reducing the amount of computation required in the subsequent model testing process.

[0073] It should be noted that the sampled neurons, representing a small percentage, such as 1,000 neurons prone to errors, are neurons with a relatively high probability of triggering errors compared to the millions of neurons in a deep learning model.

[0074] Furthermore, in the first stage, a perturbation distribution map can be drawn for the output of each neuron on the sampled dataset, the variance of the perturbation distribution of each neuron can be calculated, and the k neurons with the largest variance of the perturbation distribution can be extracted as the sampled neurons.

[0075] The test completion module 82 calculates the convergence degree and test completion degree of the perturbation distribution of each neuron among the k neurons with the largest perturbation values. For neurons whose perturbation distributions have not converged, the next step of backpropagation is performed. The test completion module 82 can be regarded as the second stage of testing the deep learning model.

[0076] To concentrate computational resources and focus time on computing neurons prone to triggering errors, thereby reducing resource waste and saving time, the convergence of neuron perturbations can be calculated based on neuron perturbations and Markov Chain Monte Carlo (MCMC) in the second stage of testing deep learning models.

[0077] In existing differential equation theory, the Monte Carlo (MCMC) method based on neuron perturbation and Markov chain is the optimal method for detecting the convergence of the perturbation distribution of differential operators. When the Monte Carlo standard error (MCSE) of the perturbation distribution is 0, the perturbation distribution is considered to be converged.

[0078] For example, the output of all neurons can be calculated first, then the convergence of all neurons can be calculated, and finally MCMC sampling can be performed to obtain neurons that are prone to triggering errors.

[0079] Exemplarily, in the second stage, neurons N1 and N5 are used as sampling neurons, and the Markov Chain Monte Carlo (MCMC) algorithm is adopted to calculate the convergence degree of the perturbation distributions of neurons N1 and N5. The test completion degree is obtained according to the convergence state of each neuron's perturbation distribution.

[0080] The backpropagation module 83 further tests the neurons whose perturbation distributions have not converged by using the backpropagation algorithm, generates a new test set, and repeats the calculation of the perturbation module 81 and the test completion degree module 82 until the perturbation distributions output by all sampled neurons reach convergence. The backpropagation module 83 can be denoted as the third stage of the test of the deep learning model.

[0081] Based on Figure 8 The system structure shown, the test method of the deep learning model provided by the embodiments of the present application adopts the MCMC algorithm based on neuron perturbation to calculate the convergence degree of the perturbation distributions of neurons prone to trigger errors, and adopts the noise optimization algorithm based on backpropagation to optimize the noise, so as to make the final test completion degree reach 100% by using the two characteristics that the machine learning model has neurons prone to trigger errors and the backpropagation needs to be used in the model optimization process. The test method of the deep learning model provided by the embodiments of the present application can be applied to all software using the deep learning model, including the ModelArts self-driving development platform of ModelArts.

[0082] Figure 9 It is a flowchart of the test method of the deep learning model provided by the embodiments of the present application. As Figure 9 shown, the method includes:

[0083] S91, input the picture data I into the deep learning model, and obtain the perturbation value of each neuron in the model according to the difference in the output of each neuron in the deep learning model before and after adding the noise E. The number of neurons in the deep learning model M is n; S92, select k neurons with the largest perturbation values from the n neurons as sampling neurons, where k << n; S93, obtain the perturbation distribution of each neuron among the k sampling neurons according to the perturbation values of the k sampling neurons; the perturbation distribution of a neuron includes convergence and non-convergence; S94, determine that the number of neurons with non-convergent perturbation distributions among the k neurons is m, where m < k; S95, update the parameters of the perturbation distribution noise E for the m neurons with non-convergent perturbation distributions through backpropagation, S96, repeat the above steps S91 - S95 when the perturbation distributions of the m neurons with non-convergent perturbation distributions have not all converged, and when the perturbation distributions of the m neurons with non-convergent perturbation distributions have all converged, that is, the number of neurons with non-convergent perturbation distributions is 0, complete the test of the perturbation distribution deep learning model.

[0084] The deep learning model testing method provided in this application embodiment executes steps S91-S92 above in the first stage, using the magnitude of the neuron perturbation value to sample a small number of easily triggered error neurons from the millions of neurons in the deep learning model. In the second stage, steps S93-S94 are executed, using the MCMC algorithm to calculate the convergence degree of the easily triggered error neuron perturbation distribution. In the third stage, step S95 is executed to optimize the noise parameters through backpropagation. Through iteration, the perturbation distribution deep learning model testing is completed.

[0085] Figure 10 This is a flowchart illustrating the process of obtaining neurons prone to triggering errors based on neuron perturbation and the MCMC algorithm. Figure 10 As shown, step S91 can be performed using steps S911-S913 to obtain the perturbation value of each neuron.

[0086] S911, read in the dataset.

[0087] In one feasible implementation, the output of each neuron in the deep learning model is obtained based on the input image data I, and is denoted as the first output.

[0088] For example, image data I is input into a deep learning model; image data I can be a road condition image I. A I B I C In the deep learning model M, each neuron Ni outputs Ni(I), where i is a natural number with values ​​of 1, 2, 3, ..., n.

[0089] S912, calculate the neuron perturbation value.

[0090] In one feasible implementation, noise E is added to the image data I to obtain the output of each neuron in the deep learning model as the second output, denoted as the second output. The perturbation value of each neuron is obtained based on the difference between the first output and the second output.

[0091] For example, noise E can be added to image data I to obtain new image data I+E. Image data I+E is then input into a deep learning model, and the output of each neuron Ni in the model is Ni(I+E). Here, the added noise E is randomly generated; the difference between the neuron outputs before and after adding noise E, Ni(I+E)-Ni(I), is calculated to obtain the perturbation value of each neuron Ni in the model.

[0092] In one feasible implementation, the perturbation value output by each neuron for each image data in the sampled dataset is iterated.

[0093] For example, iterate through each image data I in the sampled dataset S. A I B , ...I J For each neuron Ni, obtain the image data I from the sampled dataset S. A I B , ...I J Output Ni(I) A ),Ni(I B ),…,Ni(I J ), and the output Ni(I) after adding noise E. A +E),Ni(I B +E),…,Ni(I J +E), calculate the perturbation value of the output of each neuron to each image data in the sampled dataset.

[0094] In one feasible implementation, step S92 can be performed as follows: steps S921-S922 to obtain the sampled neurons.

[0095] S921, calculate the variance of the perturbation value of each of the n neurons.

[0096] For example, a perturbation distribution map can be plotted for the output of each neuron on a sampled dataset, and the variance of the perturbation distribution of each neuron out of n neurons can be calculated.

[0097] S922 selects k neurons with the largest perturbation variance from n neurons as sampling neurons.

[0098] For example, the neurons can be sorted according to the variance of the perturbation values ​​of n neurons, and the k neurons with the largest perturbation value variance can be selected as the sampling neurons.

[0099] For example, k neurons with the largest variance of perturbation values ​​can be selected as sampling neurons based on the variance distribution map of the perturbation values ​​of n neurons.

[0100] For example, the value of k is preferably 1000.

[0101] In one feasible implementation, step S93 can be performed by fitting the perturbation distribution of each of the k sampled neurons using steps S931-S933.

[0102] Step S931: Based on the perturbation values ​​or variances of the k sampled neurons, calculate the perturbation distribution of each neuron among the k sampled neurons using the MCMC algorithm.

[0103] Step S932: Calculate the Monte Carlo Standard Error (MCSE) values of the perturbation distributions of the k sampled neurons according to the perturbation distribution of each neuron.

[0104] As Figure 11 shown, calculate the Monte Carlo Standard Error (MCSE) values of the perturbation distributions of neurons N1 and N5 according to the variance distribution diagrams of the perturbation values of neurons N1 and N5.

[0105] Step S933: Obtain the convergence states of the perturbation distributions of the k sampled neurons according to the MCSE values.

[0106] In the case where the MCSE value is zero, the perturbation distribution of the corresponding neuron is convergent; in the case where the MCSE value is not zero, the perturbation distribution of the corresponding neuron is not convergent.

[0107] In an implementable embodiment, step S94 can obtain m non-convergent neurons as neurons prone to trigger errors by adopting the following steps S941 - S942.

[0108] S941: According to the result of S93, obtain the number of neurons with a MCSE value of zero in the perturbation distribution of neurons, that is, the number of neurons with a convergent perturbation distribution, calculate the percentage of the number of neurons with a convergent perturbation distribution in the number of sampled neurons, and obtain the test completion degree.

[0109] Exemplarily, as Figure 11 shown, at this time, the MCSE value of the perturbation distribution of neuron N5 is 0, and the neuron is convergent. The MCSE value of the perturbation distribution of neuron N1 is not 0, and the neuron is not convergent; since the number of sampled neurons is 2, the test completion degree is 50% at this time.

[0110] S942: Output the non-convergent neurons according to the model test completion degree for subsequent backpropagation.

[0111] Exemplarily, the number of neurons with a non-convergent perturbation distribution among the k neurons is m, where m < k, and the model test completion degree is less than 100%, then output m neurons with a non-convergent perturbation distribution for subsequent backpropagation.

[0112] So far, in the first and second stages of the test method of the deep learning model provided in the embodiments of the present application, sampling of neurons is completed, and the obtained non-convergent neurons are neurons prone to trigger errors for subsequent backpropagation. And the test completion degree of the neurons is obtained. Since the noise used in the test is randomly generated, the test completion degree of the neurons is often relatively low. In order to test as many neurons as possible, the noise needs to be optimized in the third stage.

[0113] The testing method for the deep learning model provided in this application executes step S95 in the third stage, which uses a noise optimization algorithm based on backpropagation to optimize the noise.

[0114] Figure 12 The flowchart illustrates the noise optimization algorithm based on backpropagation in the testing method for the deep learning model provided in the application embodiment. Figure 12 As shown, noise optimization is achieved in step S95 through the following steps S951-S954.

[0115] S951, Read the dataset.

[0116] In one feasible implementation, data I can be input into a deep learning model M, where data I can be a road condition image I. A I B I C …

[0117] S952 calculates the gradient of the noise based on m neurons with non-convergent perturbation distribution.

[0118] In one feasible implementation, step S952 includes:

[0119] S9521, obtains the outputs of m neurons with non-convergent perturbation distribution.

[0120] In one feasible implementation, the output of each of m neurons with non-convergent perturbation distributions can be obtained from the input image data I.

[0121] S9522, the loss function for calculating the model.

[0122] In one feasible implementation, the loss function of the model can be obtained by summing the outputs of each of the m neurons whose perturbation distribution is non-convergent.

[0123] S9523, calculate the noise gradient based on the loss function.

[0124] In one feasible implementation, the gradient of the noise can be obtained by differentiating the loss function Loss with respect to the noise E. E.

[0125] S953 performs backpropagation based on the noise gradient.

[0126] according to Figure 7 The backpropagation example shown demonstrates how the parameter values ​​of noise E are adjusted according to the noise gradient to perform backpropagation.

[0127] For example, the parameter value of the noise E can be adjusted so that E k =Ek-1 +ΔE*lr, where lr is the learning rate, with a value of 3*10. -4 k is the number of backpropagations, and its value is a natural number.

[0128] S954 updates the noise based on the results of backpropagation.

[0129] By continuously adjusting the noise E k After each backpropagation, the perturbation value of the non-convergent neuron N1 is calculated, and finally the noise E that maximizes the perturbation value is obtained. k The noise is updated so that E=E k .

[0130] In one feasible implementation, the parameter value of noise E can be adjusted according to the noise gradient to maximize the sum of the perturbation values ​​of the m non-converged neurons.

[0131] Based on the updated noise E, the steps of the first, second, and third stages are repeated to train and test the completion rate and optimize the noise until the final perturbation distribution is such that the number of non-converged neurons is 0 and the test completion rate reaches 100%. In this embodiment, the loss value of the neuron is obtained by calculating the loss between the output value and the expected value of the non-converged neuron, and then the noise is optimized so that the expected neuron perturbation value can converge and the desired loss value is 0.

[0132] Example 1:

[0133] The testing method for the deep learning model provided in Embodiment 1 of this application is applied to efficient and secure big data processing based on a trusted operating environment.

[0134] Figure 13 This diagram illustrates the implementation of the testing method for the deep learning model provided in Embodiment 1 of this application on PyTorch. The implementation of this embodiment on the PyTorch deep learning framework is named Themis.

[0135] PyTorch is currently the most commonly used framework in the field of deep learning. In the first stage of the embodiment of this application, the output value M(I) or M(I+E) of the deep learning model M is calculated by calling the nn.forward() function of PyTorch. The feature of the nn.forward() function is that it uses the graphics processing unit (GPU) to perform matrix addition and multiplication, which is a necessary operation for calculating the output value of neurons, and is more than 10 times faster than the CPU method.

[0136] like Figure 13As shown, for a user to provide a target deep learning model M, a test set I, noise type, and noise parameters; where the noise type E is raindrops and the noise parameter is the raindrop size, perform the following steps S131-S136.

[0137] S131, add noise to test set I to generate test set I+E.

[0138] S132, input I and I+E into the deep learning model M, and calculate the perturbation distribution of each neuron in M.

[0139] In one feasible implementation, the PyTorch register_hook() function can be called to obtain the output value N(I) or N(I+E) of the corresponding neuron in M(I) or M(I+E) in order to calculate the perturbation distribution of each neuron in M.

[0140] S133, Write the set of data (I+E)' that caused the error in the test set I+E into the error report according to the perturbation distribution.

[0141] S134 uses the Markov Chain Monte Carlo (MCMC) algorithm to detect the convergence of the perturbation distribution of each neuron.

[0142] In one feasible implementation, MCMC can be run by calling the Python library PYMC3.

[0143] Specifically, S134 includes the following steps S1341-S1342.

[0144] S1341, call the PYMC3.sample() function to fit the perturbation distribution of the neurons.

[0145] S1342, call the PYMC3.summary() function to calculate the MCSE value of the perturbation distribution of each neuron, calculate the percentage of neurons with a perturbation distribution MCSE value of 0, and use this percentage as the test completion rate.

[0146] S135, determine whether the perturbation distribution of all neurons has converged. If the result is "no", proceed to step S136; if the result is "yes", the test degree reaches 100% and the test ends.

[0147] S136 uses the backpropagation method to adjust the parameters of the noise E, thereby generating a new test set I+E.

[0148] In one feasible implementation, backpropagation can be achieved by calling PyTorch's `Autograd.backward()` and `Optim.SGD()` functions. `Autograd.backward()` takes backpropagation variables as input, including the test set `I`, noise `E`, and the set of neurons whose perturbation distribution has not converged, and outputs the set of backpropagation variables. `Optim.SGD()` takes the set of backpropagation variables as input, including the output of `Autograd.backward()` and an optimization function. The optimization function searches for the value of the noise parameter `E` to maximize the sum of the perturbation values ​​of all neurons whose perturbation distribution has not converged, and outputs the updated test set `I+E`.

[0149] The flowchart of Themis, an example of the testing method for the deep learning model provided in Embodiment 1 of this application, is shown below. Figure 14 As shown, it will not be elaborated further here.

[0150] To demonstrate the beneficial effects of the testing method for the deep learning model provided in Embodiment 1 of this application, Themis's improvement in model accuracy and performance overhead were tested on PyTorch. Comparison techniques with Themis include DeepXplore [OSDI'17], DeepGauge [ASE'18], Surprise Adaquacy [ICSE'19], and DeepImportance [ICSE'20].

[0151] The experiments employed datasets and deep learning models tested using the aforementioned comparative techniques, including LeNet applied to the MNIST handwritten digit dataset and Dave-2 applied to the Udacity autonomous driving dataset. These models and datasets were downloaded from the PyTorch website or the model's official website, thus ensuring the highest accuracy among all open-source models. To add noise to these datasets, Embodiment 1 of this application used the built-in noise-adding algorithms of these models or datasets, including CW, PGD, and Gaussian noise. These noises were tested using the DeepXplore comparative technique used in this experiment.

[0152] Figure 15 Example graphs showing the accuracy of various testing tools provided in Embodiment 1 of this application. Figure 15As shown, retraining the DNN using the faults detected by the DLS test improves the accuracy of the DNN. When the testing techniques reach 100% completion, the number of erroneous outputs of the deep learning model found by these techniques, i.e., the number of M(I+E) that are not equal to M(I), is represented by the gray numbers for each dataset and model. The highest number of erroneous outputs of the deep learning model found by any of the testing techniques is shown in the figure. Figure 15 As shown, Embodiment 1 of this application finds 3.78 times more deep learning model error outputs than the prior art. This is because Embodiment 1 of this application is based on the theoretical characteristics of deep learning models to search for all deep learning model errors. Moreover, the theory of partial differential equations also indicates that Embodiment 1 of this application is likely to find all neuron output values ​​that trigger deep learning model errors, as well as a large number of deep learning model error outputs. In contrast, existing work requires manually selecting the granularity of neuron output values ​​for traversal, inevitably missing a large number of errors in deep learning models.

[0153] Figure 16 The error detection capabilities of Themis and existing technologies were compared. Error detection capability refers to the correlation between the number of errors found by the testing technology and the target error rate. If the testing technology finds more errors from a model with a higher error rate, it indicates a higher error detection capability. In particular, if the correlation between the number of errors found and the target error rate is greater than 0.7, the testing technology is considered to have strong error detection capability (this is a generally accepted indicator). If the correlation between the number of errors found and the target error rate is negative, the testing technology is considered to have very weak error detection capability. Embodiment 1 of this application shows the correlation between the number of faults identified by DLS testing and the DLS error rate. A correlation greater than 0.7 is considered a strong correlation. A correlation less than 0.0 is considered a weak correlation.

[0154] Existing software testing and deep learning model testing work have shown that testing techniques with strong error detection capabilities will inevitably find more errors than those with weak error detection capabilities.

[0155] like Figure 16As shown, Themis's error detection capability is greater than 0.7 for all models. This means that Themis can find more errors for models with higher error rates. This is because Themis searches for deep learning model errors based on the neuron perturbation distribution. The neuron perturbation distribution is related to the model's error rate. Partial differential stability theory states that the higher the error rate of a deep learning model, the greater the noise perturbation to the neurons, and the more difficult it is for these perturbation distributions to converge. Therefore, for deep learning models with higher error rates, Themis's test completion rate improves more slowly (because the perturbation distribution converges more slowly), thus Themis is more likely to find more deep learning model errors. In contrast, existing technologies such as the first and second schemes only use the coverage of the neuron's output interval as the test completion rate. Theoretically, the neuron's output interval coverage is not correlated with the deep learning model's error rate. Therefore, the error detection capability of existing technologies varies across different models and datasets, sometimes strong and sometimes weak.

[0156] Next, Embodiment 1 of this application analyzes the improvement in model accuracy brought about by the testing technology. That is, the deep learning model errors found by the testing technology are used to further train the target model, thereby improving the accuracy of the target model against noise, that is, improving the accuracy of M(I+E) to the level of M(I). From Figure 17 As can be seen, Themis improves model accuracy by 2.1X% compared to existing technologies, especially for the three models on the left: ResNet56, DenseNet121, and VGG-19, where Themis achieves the greatest improvement in accuracy. This is because Themis's error detection capability is greater than 0.7, meaning that for models with higher error rates, Themis finds more errors. Therefore, for models whose accuracy is greatly reduced due to noise, Themis has more room to improve model accuracy, allowing the accuracy of model M'(I+E) to approach the accuracy of M(I).

[0157] Finally, as Figure 18 As shown, Embodiment 1 of this application compares the test time of Themis with other existing testing technologies, that is, the time required for the test completion rate to reach 100% from 0%. The results show that Themis can complete the test in a few minutes. Compared with the time consumed by existing technologies, although Themis traverses the neuron output values ​​at the original granularity, resulting in additional performance overhead, Themis prioritizes traversing the important neuron output values, which greatly improves the test efficiency.

[0158] In summary, the testing method for deep learning models provided in this application can automatically test and optimize the stability of deep learning models, with theoretically guaranteed accuracy and stable performance overhead.

[0159] The testing method for the deep learning model provided by the embodiments of the present application utilizes neuron perturbation, MCMC, and backpropagation. By calculating the perturbation values generated for any noisy neurons, the gradient of the noise is obtained and the noise is automatically optimized. Then, the model is retrained using the generated noise dataset, ultimately improving the stability of the model.

[0160] The testing method for the deep learning model provided by the embodiments of the present application calculates the neuron perturbation values and finally selects one thousand neurons that are most likely to trigger errors. It changes from calculating millions of neurons to one thousand neurons, reducing the time overhead.

[0161] The testing method for the deep learning model provided by the embodiments of the present application is supported by the theory of partial differential equations and does not require manual segmentation of neuron outputs; all test parameters have theoretically optimal values and do not require manual debugging, and the optimal granularity can be found百分百.

[0162] In the testing method for the deep learning model provided by the embodiments of the present application, a more realistic dataset is generated by modifying the algorithm for generating the noise dataset to train the deep learning model.

[0163] Figure 19 A testing device for a deep learning model provided by the embodiments of the present application. As Figure 19 shown, the device includes: a data reading module 91 for inputting picture data into the deep learning model; a perturbation value calculation module 92 for obtaining the perturbation value of each neuron in the model according to the difference in the output of each neuron in the deep learning model before and after adding noise, and the number of neurons in the deep learning model is n; a sampling module 93 for selecting k neurons with the largest perturbation values from the n neurons as sampling neurons, where k << n; a perturbation distribution fitting module 94 for obtaining the perturbation distribution of each neuron among the k sampling neurons according to the perturbation values of the k sampling neurons; the perturbation distribution of neurons includes convergence and non-convergence; a non-convergent neuron determination module 95 for determining that the number of neurons with non-convergent perturbation distribution is m among the k neurons, where m < k; a backpropagation module 96 for updating the parameters of the noise for the m neurons with non-convergent perturbation distribution through backpropagation When the number of neurons with non-convergent perturbation distribution is 0, the testing of the deep learning model is completed.

[0164] Figure 20 An electronic device 1100 provided by the embodiments of the present application, such as Figure 4As shown, it includes: at least one memory 1102 for storing a program; and at least one processor 1101 for executing the program stored in the memory. When the program stored in the memory 1102 is executed, the processor 1101 is used to execute the method of any of the above embodiments.

[0165] An embodiment of this application provides a storage medium 1103, which stores instructions that, when executed on a terminal, cause the first terminal to perform the method of any of the above embodiments.

[0166] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the embodiments of this application.

[0167] Furthermore, various aspects or features of the embodiments of this application can be implemented as methods, apparatus, or articles of manufacture using standard programming and / or engineering techniques. The term "article of manufacture" as used in this application encompasses a computer program accessible from any computer-readable device, carrier, or medium. For example, computer-readable media may include, but are not limited to: magnetic storage devices (e.g., hard disks, floppy disks, or magnetic tapes), optical discs (e.g., compact discs (CDs), digital versatile discs (DVDs), etc.), smart cards, and flash memory devices (e.g., erasable programmable read-only memory (EPROMs), cards, sticks, or key drives, etc.). Additionally, the various storage media described herein may represent one or more devices and / or other machine-readable media for storing information. The term "machine-readable medium" may include, but is not limited to, wireless channels and various other media capable of storing, containing, and / or carrying instructions and / or data.

[0168] It should be understood that in the various embodiments of this application, the order of the above-mentioned processes does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of this application.

[0169] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0170] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.

[0171] 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 units can be selected to achieve the purpose of this embodiment according to actual needs.

[0172] If the aforementioned function is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application embodiment, 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, a server, or an access network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0173] The above description is merely a specific implementation of the embodiments of this application, but the protection scope of the embodiments of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the embodiments of this application should be covered within the protection scope of the embodiments of this application.

Claims

1. A testing method for a deep learning model, characterized in that, The method includes: Input the image data into the deep learning model; Based on the difference in the output of each neuron in the deep learning model before and after adding noise E to the image data, the perturbation value of each neuron in the model is obtained. The number of neurons in the deep learning model is... indivual; From n neurons, select k neurons with the largest variance in perturbation values ​​as sampling neurons, where k < <n; Based on the perturbation values ​​of the k sampled neurons, the perturbation distribution of each of the k sampled neurons is obtained; the perturbation distribution of the neurons includes converged and non-converged distributions. Based on the perturbation distribution of each neuron in the k sampled neurons, the number of neurons with non-convergent perturbation distributions is determined to be m, where m <k; The parameters of the noise E are updated through backpropagation for m neurons whose perturbation distribution is non-converged; The deep learning model is tested when the number of neurons in the perturbation distribution that have not converged is 0.

2. The testing method for the deep learning model according to claim 1, characterized in that, The step of obtaining the perturbation value of each neuron in the deep learning model based on the difference in the output of each neuron before and after adding noise E to the image data includes: Based on the input image data, the output of each neuron in the deep learning model is obtained as the first output; Noise is added to the image data to obtain the output of each neuron in the deep learning model as a second output. The perturbation value of each neuron is obtained based on the difference between the first output and the second output.

3. The testing method for the deep learning model according to claim 1, characterized in that, Before selecting the k neurons with the largest perturbation value variances from the n neurons as sampling neurons, the method further includes: Iterate through the perturbation value output by each neuron for each image data in the sampled dataset, and calculate the variance of the perturbation value of each of the n neurons; the sampled dataset includes multiple different image data.

4. The testing method for the deep learning model according to claim 1, characterized in that, The step of obtaining the perturbation distribution of each of the k sampled neurons based on the perturbation values ​​of the k sampled neurons includes: Based on the perturbation values ​​of k sampled neurons, the perturbation distribution of each of the k sampled neurons is fitted using the Markov Chain Monte Carlo (MCMC) algorithm.

5. The testing method for the deep learning model according to claim 4, characterized in that, According to The perturbation value of each sampled neuron is used to obtain the... The perturbation distribution of each neuron in the sampled neurons also includes: Based on the perturbation distribution of each neuron, calculate the Monte Carlo standard error (MCSE) value of the perturbation distribution of each neuron; When the MCSE value is zero, the perturbation distribution of the corresponding neuron is convergent; When the MCSE value is not zero, the perturbation distribution of the corresponding neuron is non-convergent.

6. The testing method for the deep learning model according to claim 1, characterized in that, The process of updating the parameters of the noise E through backpropagation for the m neurons whose perturbation distribution is non-converged includes: The gradient of the noise is calculated based on m neurons whose perturbation distribution is non-convergent; Backpropagation is performed based on the gradient of the noise; The parameter values ​​of the noise E are updated based on the results of the backpropagation.

7. The testing method for the deep learning model according to claim 6, characterized in that, The step of calculating the noise gradient based on m neurons whose perturbation distribution is non-converged includes: The loss function of the deep learning model is calculated based on m neurons whose perturbation distribution is non-converged. The gradient of the noise is obtained by differentiating the loss function with respect to the noise.

8. The testing method for the deep learning model according to claim 6, characterized in that, The step of updating the parameter value of the noise E based on the backpropagation result includes: The parameter values ​​of noise E are adjusted according to the noise gradient to maximize the sum of the perturbation values ​​of m non-converged neurons.

9. A testing device for a deep learning model, characterized in that, The device includes: The data input module is used to input image data into the deep learning model; The perturbation value calculation module is used to obtain the perturbation value of each neuron in the deep learning model based on the difference in the output of each neuron in the deep learning model before and after adding noise E to the image data. The deep learning model has n neurons. The sampling module is used to select k neurons with the largest variance of perturbation values ​​from n neurons as sampling neurons, where k < <n; The perturbation distribution fitting module is used to obtain the perturbation distribution of each of the k sampled neurons based on the perturbation values ​​of the k sampled neurons; the perturbation distribution of the neurons includes converged and non-converged distributions. The non-convergent neuron determination module is used to determine the number of neurons whose perturbation distribution is non-convergent, which is m, based on the perturbation distribution of each neuron in the k sampled neurons. <k; The backpropagation module is used to update the parameters of the noise E through backpropagation for m neurons whose perturbation distribution is non-converged; and to complete the deep learning model test when the number of neurons whose perturbation distribution is non-converged is 0.

10. An electronic device, characterized in that, include: At least one memory for storing programs; and At least one processor is configured to execute a program stored in the memory, wherein when the program stored in the memory is executed, the processor is configured to perform the method as described in any one of claims 1-8.

11. A storage medium storing instructions that, when executed on a terminal, cause the terminal to perform the method as described in any one of claims 1-8.