Test case generation method, system and computer readable storage medium

By constructing affine functions and optimizing parameters to generate new test cases, the problem that the test case generation method in the existing technology cannot effectively detect errors in the image classification model, and achieve more efficient model testing coverage and accuracy.

CN114116456BActive Publication Date: 2024-11-05GUANGZHOU INTELLIGENT SOFTWARE IND RES INST
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111301946.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-04
Publication Date
2024-11-05
Estimated Expiration
2041-11-04

AI Technical Summary

Technical Problem

The existing test case generation method cannot effectively discover potential model errors in image classification model testing, mainly because most of the outputs of the generated new test cases are correct, and the properties of the model cannot be fully utilized, resulting in the inability to effectively discover potential model errors.

Method used

By generating a perturbation sample set from the existing test cases of the model to be tested and building an affine function to approximate the output differences of the model, calculate the sample that enables the affine function to obtain the maximum value point as a new test case, and optimize the unknown using linear planning method Parameters to generate test cases that can detect model errors.

Benefits of technology

The generated new test cases can effectively detect errors in the model to be tested, improve the coverage and accuracy of model testing, and can more effectively discover potential problems of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114116456B_ABST
    Figure CN114116456B_ABST
Patent Text Reader

Abstract

The present invention provides a test case generation method, system and computer readable storage medium. The test case generation method comprises the following steps: S1: obtaining an initial image sample x from an existing test case of the model to be tested ini , for the initial image sample x ini Add random noise multiple times to generate a perturbed sample set, and obtain the output y' corresponding to each new sample x'; S2: For each new sample x', except for the dimension c, establish the affine function Z i (x) = a0+a1x1+…+a m x m ; S3: Calculate unknown parameters a0, a1, ..., a according to the multiple new samples x' and the corresponding output y' m , so that the affine function Z i (x) satisfies |Z i (x')–z i (x')|≤λ; S4: According to the unknown parameters a0, a1, ..., a m , calculate so that Z i (x) Get the maximum value of x1, x2, ..., x m , get a new test case sample x out , x out =(x1,x2,…,x m ). The test case generation method and system of the embodiment of the present invention can generate new test cases that can effectively discover errors in the model to be tested.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer software technology, and in particular to a test case generation method, system and computer-readable storage medium. Background Art

[0002] Image classification is an important problem in the field of artificial intelligence - computer vision. Practical problems such as face recognition and object recognition can be converted into image classification problems. At present, using existing data sets to build a neural network image classification model is an effective technical means to solve image classification problems, and it is also the most widely used mainstream technical means.

[0003] Image classification can be specifically described as the following problem: for categories numbered 1, 2, ..., n, we input an image x belonging to one of the categories, and we hope to get its correct category number. In this scenario, we also call the classified image a "sample" and the category number a "label". The neural network image classification model can be regarded as a function f, which receives an m-dimensional vector and outputs an n-dimensional vector. Each element of the input m-dimensional vector corresponds to a pixel value of the input sample, and each element of the output n-dimensional vector corresponds to the possibility score of the sample being classified as a certain category of samples. We use f i (x) represents the i-th dimension element of the output of the neural network when it receives sample x. Then for a certain i, if f i (x) is greater than all other elements in the output, then we get the classification result i of the neural network, because at this time the neural network believes that the probability score of x's category i is the highest.

[0004] Model testing is an important way to ensure that the model can correctly and effectively perform its functions. The data used for testing is called a "test case", which usually consists of two parts: (1) input sample; (2) the correct output corresponding to the input. The general testing process is as follows: we input the sample to the model being tested and get the output of the model. If the model output is consistent with the correct output, it means that the model is correct under the test case, otherwise we have found an error in the model. The purpose of testing is to effectively discover possible errors in the model through test cases. Therefore, in the neural network image classification model test, one test case contains a sample image and the correct label of the sample image. The testing process is to input the sample to the model to be tested and check whether the output result of the model is consistent with the correct label.

[0005] For the neural network image classification model test, the test cases come from the original data set actually collected to solve the classification problem. Part of this data set will be used to build the model, and the other part will be used as test cases. In fact, the number of test cases from the original data set is very limited, while the input space of the neural network model is huge, which means that the test cases from the original data set are far from covering the input samples that the neural network model may receive. In other words, the test cases from the original data set cannot fully discover the potential errors in the model.

[0006] Therefore, test cases also come from artificial construction, that is, people generate new test cases based on existing test cases by some method to expand the test case set. A mainstream test case generation method is to add random noise of a certain disturbance range to the image samples of existing test cases to obtain new samples. This is a mainstream test case generation method, because this method simulates the noise disturbance in real scenes, so the new test cases generated by this method can potentially discover some neural network image classification models that have misclassified due to noise interference on samples.

[0007] However, this method of directly adding random noise to existing test case samples to generate new test cases also has its shortcomings. Since this method only focuses on the sample itself and does not take advantage of the properties of the neural network image classification model to be tested, the vast majority of the outputs of the generated new test cases are correct. In other words, the newly generated test cases cannot effectively discover potential errors in the network to be tested, and therefore lose their practical significance for testing. Summary of the invention

[0008] Based on this, it is necessary to provide a test case generation method, system and computer-readable storage medium that can generate new test cases that effectively discover errors in the model to be tested.

[0009] An embodiment of the present invention provides a test case generation method, which comprises the following steps:

[0010] S1: Get the initial image sample x from the existing test cases of the model to be tested ini , x ini is an m-dimensional vector, x ini The correct classification result is c, for the initial image sample x ini Add random noise multiple times to generate a perturbation sample set, which includes multiple perturbation sample sets in the initial image sample x ini A new sample x' with random noise is added to the perturbation sample set, each new sample x' of the perturbation sample set is input into the model to be tested, and an output y' corresponding to each new sample x' is obtained;

[0011] S2: For each new sample x', except for the dimension c, establish the affine function for the other dimensions i:

[0012] Z i (x) = a0 + a1 x1 + ... + a m x m ,

[0013] where a0, a1, …, a m is the unknown parameter to be determined, Z i (x) is z i The affine function of (x),

[0014] z i (x) = y i –y c ,

[0015] y is the output of sample x in the model to be tested, y i and c are the i-th and c-th elements of y respectively;

[0016] S3: Calculate unknown parameters a0, a1, ..., a according to the multiple new samples x' and the corresponding output y' m , so that the affine function Z i (x) satisfies |Z i (x')–z i (x')|≤λ, where λ is the preset error;

[0017] S4: According to the calculated unknown parameters a0, a1, ..., a m , calculate so that Z i (x) Get the maximum value of x1, x2, ..., x m , will make Z i (x) Get the maximum value of x1, x2, ..., x m The vector composed is the new test case sample x out , x out =(x1,x2,…,x m ).

[0018] As a further improvement of the above embodiment, in step S1, the initial image sample x ini The process of adding random noise consists of the following sub-steps:

[0019] S11: For the initial image sample x ini Each dimension x i , calculate p i =min(0,x i -r) and q i =max(255,xi +r);

[0020] S12: For each dimension, randomly obtain the interval [p i ,q i ], assign the integer to x' i ;

[0021] S13: Get a new sample x', x'=(x'1, x'2, ..., x' m ).

[0022] As a further improvement of the above embodiment, in step S3, the optimization problem is solved by a linear programming method:

[0023] minλ

[0024]

[0025] The unknown parameters a0, a1, ..., a that minimize λ in all new samples x' m The values ​​of unknown parameters a0, a1, …, a m The determined value of .

[0026] As a further improvement of the above embodiment, in step S4, for the unknown parameters a0, a1, ..., a m The affine function of the determined value, Z i (x) = a0 + a1 x1 + ... + a m x m , when parameter a i When x is positive, i =q i ; When parameter a i When it is negative, take x i =p i ; x1, x2, …, x m The value of is taken as the new test case sample x out Corresponding to the values ​​of each dimension, a new test case sample x is formed out .

[0027] Another aspect of the present invention provides a test case generation system, which includes:

[0028] Perturbation sample set generation module: obtain the initial image sample x from the existing test cases of the model to be tested ini , x ini is an m-dimensional vector, x ini The correct classification result is c, for the initial image sample x ini Add random noise multiple times to generate a perturbation sample set, which includes multiple perturbation sample sets in the initial image sample x iniA new sample x' with random noise is added to the perturbation sample set, each new sample x' of the perturbation sample set is input into the model to be tested, and an output y' corresponding to each new sample x' is obtained;

[0029] Affine function generation module: For each new sample x', except for the dimension c, an affine function is established:

[0030] Z i (x) = a0 + a1 x1 + ... + a m x m ,

[0031] where a0, a1, …, a m is the unknown parameter to be determined, Z i (x) is z i The affine function of (x),

[0032] z i (x) = y i –y c ,

[0033] y is the output of sample x in the model to be tested, y i and c are the i-th and c-th elements of y respectively;

[0034] The affine function generation module also calculates unknown parameters a0, a1, ..., a according to the multiple new samples x' and the corresponding output y'. m , so that the affine function Z i (x) satisfies |Z i (x')–z i (x')|≤λ, where λ is the preset error;

[0035] New test case sample generation module: based on the calculated unknown parameters a0, a1, ..., a m , calculate so that Z i (x) Get the maximum value of x1, x2, ..., x m , will make Z i (x) Get the maximum value of x1, x2, ..., x m The vector composed is the new test case sample x out , x out =(x1,x2,…,x m ).

[0036] As a further improvement of the above embodiment, the disturbance sample set generation module generates the initial image sample x ini The process of adding random noise consists of the following sub-steps:

[0037] S11: For the initial image sample xini Each dimension x i , calculate p i =min(0,x i -r) and q i =max(255,x i +r);

[0038] S12: For each dimension, randomly obtain the interval [p i ,q i ], assign the integer to x' i ;

[0039] S13: Get a new sample x', x'=(x'1, x'2, ..., x' m ).

[0040] As a further improvement of the above embodiment, the affine function generation module solves the optimization problem by a linear programming method:

[0041] minλ

[0042]

[0043] The unknown parameters a0, a1, ..., a that minimize λ in all new samples x' m The values ​​of unknown parameters a0, a1, …, a m The determined value of .

[0044] As a further improvement of the above embodiment, the new test case sample generation module obtains unknown parameters a0, a1, ..., a m The affine function Z of the determined value i (x) = a0 + a1 x1 + ... + a m x m , when parameter a i When x is positive, i =q i ; When parameter a i When it is negative, take x i =p i ; x1, x2, …, x m The value of is taken as the new test case sample x out Corresponding to the values ​​of each dimension, a new test case sample x is formed out .

[0045] In another aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of the test case generation method described in any of the above embodiments are implemented.

[0046] The test case generation method and system of the embodiments of the present invention use existing test cases to construct an approximate model with similar properties and clear structure to the model to be tested, and generate new test cases by analyzing the approximate model. The generated new test cases can effectively discover errors in the model to be tested. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] The above and other purposes, features and advantages of the present invention will become more clear by more specific description of the preferred embodiments of the present invention shown in the accompanying drawings. The same reference numerals indicate the same parts in all the accompanying drawings, and the accompanying drawings are not deliberately scaled to the actual size, and the focus is on illustrating the main purpose of the present invention.

[0048] Figure 1 A schematic diagram of a test case generation method according to an embodiment of the present invention. DETAILED DESCRIPTION

[0049] To facilitate understanding of the present invention, the present invention will be described more fully below with reference to the relevant drawings.

[0050] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which the present invention belongs. The terms used in the specification herein are only for the purpose of describing specific embodiments and are not intended to limit the present invention. The term "and / or" used herein includes any and all combinations of one or more related listed items.

[0051] The basic idea of ​​the embodiment of the present invention is as follows:

[0052] Use x i represents the element of the i-th dimension of a vector x. Similarly, the output vector y of vector x in the model to be tested is similar. For an existing sample x, its correct classification result is c. In this case, it means that the c-th dimension element of its output y, that is, y c , should be greater than the other dimension elements of its output, namely y i -y c <0.

[0053] Use z i (x) represents y i -y c This value is a function of x. If we can generate a z near the original sample x i (x) As large a sample as possible, this new sample is likely to cause the model to be tested to misclassify, which means that we have obtained an effective new test case. However, since the neural network model to be tested is very complex in structure, z i (x) is difficult to express explicitly using an indirect function. In other words, directly i(x) It is difficult to conduct analysis.

[0054] Therefore, the basic idea of ​​the present invention is to construct a simple model Z based on the existing test case sample x. i (x), and through Z i (x) effectively approximates the z of the model to be tested near x i (x) function. Then for this Z with a simple structure i (x) is analyzed and its maximum value is calculated, that is, the value that makes Z i (x) As large a sample as possible, so as to obtain a new test case that is most likely to cause the model to be tested to fail.

[0055] To implement the basic idea of ​​the present invention, an embodiment of the present invention provides a test case generation method, which includes the following steps:

[0056] S1: Get the initial image sample x from the existing test cases of the model to be tested ini , x ini is an m-dimensional vector, x ini The correct classification result is c, for the initial image sample x ini Add random noise multiple times to generate a perturbation sample set, which includes multiple perturbation sample sets in the initial image sample x ini A new sample x' with random noise is added to the perturbation sample set, each new sample x' of the perturbation sample set is input into the model to be tested, and an output y' corresponding to each new sample x' is obtained;

[0057] S2: For each new sample x', except for the dimension c, establish the affine function for the other dimensions i:

[0058] Z i (x) = a0 + a1 x1 + ... + a m x m ,

[0059] where a0, a1, …, a m is the unknown parameter to be determined, Z i (x) is z i The affine function of (x),

[0060] z i (x) = y i –y c ,

[0061] y is the output of sample x in the model to be tested, y i and c are the i-th and c-th elements of y respectively;

[0062] S3: Calculate unknown parameters a0, a1, ..., a according to the multiple new samples x' and the corresponding output y' m , so that the affine function Z i (x) satisfies |Z i (x')–z i (x')|≤λ, where λ is the preset error;

[0063] S4: According to the calculated unknown parameters a0, a1, ..., a m , calculate so that Z i (x) Get the maximum value of x1, x2, ..., x m , will make Z i (x) Get the maximum value of x1, x2, ..., x m The vector composed is the new test case sample x out , x out =(x1,x2,…,x m ).

[0064] In this embodiment, the model to be tested may be a neural network image classification model. In step S1, for an existing test case of the neural network image classification model to be tested, we add a random noise δ within a certain disturbance range to the image sample x in the test case to obtain a new sample x'=x+δ, and repeat this process K times to obtain a perturbed sample set with K new samples x'. Then, each sample x' in the newly obtained perturbed sample set is input into the model to be tested one by one to obtain the corresponding output y'. The perturbation used can be performed as follows: that is, given a perturbation radius r for the sample pixel value, the added perturbation is a vector δ with the same dimension as the sample x, where -r≤δ i ≤r. However, it should be noted that the pixel value must be between 0 and 255, so the pixel value x after disturbance i +δ i This constraint should also be received.

[0065] Multiple new samples obtained by adding random noise within a certain perturbation range to the original sample x and the corresponding output of the model to be tested constitute multiple pairs of input and output data (x', y'). Through these data pairs, the behavioral characteristics and properties of the model to be tested within a certain perturbation range of the image sample x of the original test case can be characterized, so as to further build an approximate model.

[0066] In steps S2 and S3, a simple model Z is constructed using the multiple pairs of data (x', y') obtained in the previous step. i (x), and through Z i (x) effectively approximates the z of the model to be tested near x i (x) function. The purpose of model learning is to make the new model Z i(x) and z of the original model i The similarity of (x) can be guaranteed. In other words, this step ensures that Z i (x')+λ is z i (x') is an approximate upper bound, and Z i (x')-λ is z i In step S3, a set of unknown parameters a0, a1, ..., a are obtained by calculating the input and output data (x', y') of multiple new samples x'. m , the set of unknown parameters a0,a1,…,a m Can make Z i (x') satisfies |Z i (x')–z i (x')|≤λ.

[0067] In a preferred embodiment, in step S1, the initial image sample x ini The process of adding random noise consists of the following sub-steps:

[0068] S11: For the initial image sample x ini Each dimension x i , calculate p i =min(0,x i -r) and q i =max(255,x i +r);

[0069] S12: For each dimension, randomly obtain the interval [p i ,q i ], assign the integer to x' i ;

[0070] S13: Assign the value x' obtained in each dimension i Combination, get a new sample x', x'=(x'1,x'2,…,x' m ).

[0071] Repeat the above steps S11-S13 K times to obtain K new samples x'. Then input each new sample x' into the model to be tested, obtain the corresponding output y', and obtain K pairs of such data (x', y'). The set of these new samples x' is the perturbation sample set.

[0072] In a preferred embodiment, in step S3, the optimization problem is solved by a linear programming method:

[0073] minλ

[0074]

[0075] The unknown parameters a0, a1, ..., a that minimize λ in all new samples x' m The values ​​of unknown parameters a0, a1, …, a m The determined value of .

[0076] The above embodiment transforms the problem of solving unknown parameters into an optimization problem and solves it using the linear programming method. i (x') to approximate z i (x') in the perturbation range, so we hope that the distance between them is as small as possible. Therefore, the optimization goal of the constructed optimization problem is to minimize the distance λ between them, that is, to minimize the distance λ between all new samples x'. i (x')–z i The difference of (x') is the smallest.

[0077] In a preferred embodiment, in step S4, for the unknown parameters a0, a1, ..., a m The affine function of the determined value: Z i (x) = a0 + a1 x1 + ... + a m x m , when parameter a i When x is positive, i =q i ; When parameter a i When it is negative, take x i =p i ; Determine x1, x2, …, x according to the above method m The values ​​of x1, x2, …, x m The value of is taken as the new test case sample x out Corresponding to the values ​​of each dimension, a new test case sample x is formed out .

[0078] Because Z i is an affine function of the form:

[0079] Z i (x) = a0 + a1 x1 + ... + a m x m ,

[0080] Therefore Z i For each x i are monotonic: when parameter a i When x is positive, i The larger the Z i The larger the parameter a is, the i When x is negative, i The smaller the Z iThe smaller. Therefore, for the disturbance range [p1,q1]×…×[p m ,q m ], we can generate a Z i The maximum value point: when parameter a i When x is positive, i =q i , that is, take the maximum value of its disturbance interval; when parameter a i When it is negative, take x i =p i , that is, take the minimum value of its disturbance interval.

[0081] The embodiment of the present invention also provides a test case generation system, which includes:

[0082] Perturbation sample set generation module: obtain the initial image sample x from the existing test cases of the model to be tested ini , x ini is an m-dimensional vector, x ini The correct classification result is c, for the initial image sample x ini Add random noise multiple times to generate a perturbation sample set, which includes multiple perturbation sample sets in the initial image sample x ini A new sample x' of random noise is added to the perturbation sample set, each new sample x' of the perturbation sample set is input into the model to be tested, and an output y' corresponding to each new sample x' is obtained;

[0083] Affine function generation module: For each new sample x', except for the dimension c, an affine function is established for each dimension i:

[0084] Z i (x) = a0 + a1 x1 + ... + a m x m ,

[0085] where a0, a1, …, a m is the unknown parameter to be determined, Z i (x) is z i The affine function of (x),

[0086] z i (x) = y i –y c ,

[0087] y is the output of sample x in the model to be tested, y i and c are the i-th and c-th elements of y respectively;

[0088] The affine function generation module also calculates unknown parameters a0, a1, ..., a according to the multiple new samples x' and the corresponding output y'.m , so that the affine function Z i (x) satisfies |Z i (x')–z i (x')|≤λ, where λ is the preset error;

[0089] New test case sample generation module: based on the calculated unknown parameters a0, a1, ..., a m , calculate so that Z i (x) Get the maximum value of x1, x2, ..., x m , will make Z i (x) Get the maximum value of x1, x2, ..., x m The vector composed is the new test case sample x out , x out =(x1,x2,…,x m ).

[0090] In a preferred embodiment, the disturbance sample set generation module generates the initial image sample x ini The process of adding random noise consists of the following sub-steps:

[0091] S11: For the initial image sample x ini Each dimension x i , calculate p i =min(0,x i -r) and q i =max(255,x i +r);

[0092] S12: For each dimension, randomly obtain the interval [p i ,q i ], assign the integer to x' i ;

[0093] S13: Get a new sample x', x'=(x'1, x'2, ..., x' m ).

[0094] In a preferred embodiment, the affine function generation module solves the optimization problem by a linear programming method:

[0095] minλ

[0096]

[0097] The unknown parameters a0, a1, ..., a that minimize λ in all new samples x' m The values ​​of unknown parameters a0, a1, …, a m The determined value of .

[0098] In a preferred embodiment, the new test case sample generation module generates the unknown parameters a0, a1, ..., a m The affine function Z of the determined value i (x) = a0 + a1 x1 + ... + a m x m , when parameter a i When x is positive, i =q i ; When parameter a i When it is negative, take x i =p i ; x1, x2, …, x m The value of is taken as the new test case sample x out Corresponding to the values ​​of each dimension, a new test case sample x is formed out .

[0099] The specific working principles of the perturbation sample set generation module, the affine function generation module and the new test case sample generation module are consistent with the description in the above test case generation method and will not be repeated here.

[0100] An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the test case generation method described in any of the above embodiments are implemented.

[0101] In this embodiment, the computer-readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the computer-readable storage medium can be an internal storage unit of a computer device, such as a hard disk or memory of the computer device. In other embodiments, the computer-readable storage medium can also be an external storage device of a computer device, such as a plug-in hard disk equipped on the computer device, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. Of course, the computer-readable storage medium can also include both the internal storage unit of the computer device and its external storage device. In this embodiment, the computer-readable storage medium is generally used to store an operating system and various application software installed on the computer device. In addition, the computer-readable storage medium can also be used to temporarily store various types of data that have been output or are to be output.

[0102] The processor may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chip in some embodiments. The processor is generally used to control the overall operation of a computer device. In this embodiment, the processor is used to run a program code stored in a computer-readable storage medium or process data to implement the test case generation method of the above embodiment.

[0103] The test case generation method and system of the embodiment of the present invention utilizes existing test cases to construct an approximate model with similar properties and clear structure to the model to be tested, and generates new test cases by analyzing the approximate model. The generated new test cases can effectively discover errors in the model to be tested. The technical solution of the present invention can more effectively generate test cases that cause errors in the neural network image classification model based on model abstraction. On the one hand, it provides a more effective testing method for discovering potential errors in the neural network. On the other hand, these test cases can be used for further training of the neural network, thereby improving the performance of the neural network.

[0104] The above embodiments only express the specific implementation methods of the invention, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for those of ordinary skill in the art, several improvements can be made without departing from the concept of the invention, and these all belong to the protection scope of the invention. Therefore, the protection scope of the patent of the present invention shall be subject to the attached claims.

Claims

1. A test case generation method, It is characterized in that The steps include: S1: Get the initial image sample x from the existing test cases of the model to be tested ini , x ini is an m-dimensional vector, x ini The correct classification result is c, for the initial image sample x ini Add random noise multiple times to generate a perturbation sample set, which includes multiple perturbation sample sets in the initial image sample x ini A new sample x' with random noise is added to the perturbation sample set, each new sample x' of the perturbation sample set is input into the model to be tested, and an output y' corresponding to each new sample x' is obtained; S2: For each new sample x', except for the dimension c, establish the affine function for the other dimensions i: Z i (x)=a 0 +a 1 x 1 +…+a m x m , where a 0 ,a 1 ,…,a m is the unknown parameter to be determined, Z i (x) is z i The affine function of (x), z i (x)=y i -and c , y is the output of sample x in the model to be tested, y i and c are the i-th and c-th elements of y respectively; S3: Calculate the unknown parameter a based on the multiple new samples x' and the corresponding output y' 0 ,a 1 ,…,a m , so that the affine function Z i (x) satisfies |Z i (x')–z i (x')|≤λ, where λ is the preset error; S4: According to the calculated unknown parameter a 0 ,a 1 ,…,a m , calculate so that Z i (x) Get the maximum value x 1 ,x 2 ,…,x m , will make Z i (x) Get the maximum value x 1 ,x 2 ,…,x m The vector composed is the new test case sample x out , x out =(x 1 ,x 2 ,…,x m ).

2. The test case generation method according to claim 1, It is characterized in that In step S1, the initial image sample x ini The process of adding random noise consists of the following sub-steps: S11: For the initial image sample x ini Each dimension x i , calculate p i =min(0,x i -r) and q i =max(255,x i +r); S12: For each dimension, randomly obtain the interval [p i ,q i ], assign the integer to x' i ; S13: Get a new sample x', x'=(x' 1 ,x' 2 ,…,x' m ).

3. The test case generation method according to claim 1 or 2, It is characterized in that In step S3, the optimization problem is solved by linear programming method: minλ s.t. The unknown parameter a that minimizes λ in all new samples x' 0 ,a 1 ,…,a m The value of the unknown parameter a 0 ,a 1 ,…,a m The determined value of .

4. The test case generation method according to claim 2, It is characterized in that In step S4, for the unknown parameter a 0 ,a 1 ,…,a m The affine function of the determined value, Z i (x) = a 0 +a 1 x 1 +…+a m x m , when parameter a i When x is positive, i =q i ; When parameter a i When it is negative, take x i =p i ; x 1 ,x 2 ,…,x m The value of is taken as the new test case sample x out Corresponding to the values ​​of each dimension, a new test case sample x is formed out .

5. A test case generation system, It is characterized in that include: Perturbation sample set generation module: obtain the initial image sample x from the existing test cases of the model to be tested ini , x ini is an m-dimensional vector, x ini The correct classification result is c, for the initial image sample x ini Add random noise multiple times to generate a perturbation sample set, which includes multiple perturbation sample sets in the initial image sample x ini A new sample x' with random noise is added to the perturbation sample set, each new sample x' of the perturbation sample set is input into the model to be tested, and an output y' corresponding to each new sample x' is obtained; Affine function generation module: For each new sample x', except for the dimension c, an affine function is established: Z i (x)=a 0 +a 1 x 1 +…+a m x m , where a 0 ,a 1 ,…,a m is the unknown parameter to be determined, Z i (x) is z i The affine function of (x), z i (x)=y i -and c , y is the output of sample x in the model to be tested, y i and c are the i-th and c-th elements of y respectively; The affine function generation module also calculates the unknown parameter a according to the multiple new samples x' and the corresponding output y'. 0 ,a 1 ,…,a m , so that the affine function Z i (x) satisfies |Z i (x')–z i (x')|≤λ, where λ is the preset error; New test case sample generation module: based on the calculated unknown parameter a 0 ,a 1 ,…,a m , calculate so that Z i (x) Get the maximum value x 1 ,x 2 ,…,x m , will make Z i (x) Get the maximum value x 1 ,x 2 ,…,x m The vector composed is the new test case sample x out , x out =(x 1 ,x 2 ,…,x m ).

6. The test case generation system according to claim 5, It is characterized in that The disturbance sample set generation module generates the initial image sample x ini The process of adding random noise consists of the following sub-steps: S11: For the initial image sample x ini Each dimension x i , calculate p i =min(0,x i -r) and q i =max(255,x i +r); S12: For each dimension, randomly obtain the interval [p i ,q i ], assign the integer to x' i ; S13: Get a new sample x', x'=(x' 1 ,x' 2 ,…,x' m ).

7. The test case generation system according to claim 5, It is characterized in that The affine function generation module solves the optimization problem by linear programming method: minλ s.t. The unknown parameter a that minimizes λ in all new samples x' 0 ,a 1 ,…,a m The value of the unknown parameter a 0 ,a 1 ,…,a m The determined value of .

8. The test case generation method according to claim 6, It is characterized in that The new test case sample generation module has obtained the unknown parameter a 0 ,a 1 ,…,a m The affine function Z of the determined value i (x) = a 0 +a 1 x 1 +…+a m x m , when parameter a i When x is positive, i =q i ; When parameter a i When it is negative, take x i =p i ; x 1 ,x 2 ,…,x m The value of is taken as the new test case sample x out Corresponding to the values ​​of each dimension, a new test case sample x is formed out .

9. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the test case generation method according to any one of claims 1 to 4 are implemented.