Model training method and device, computer equipment and storage medium
By training the model to generate automated test scripts, the problem that traditional test scripts cannot be updated dynamically is solved, which improves test coverage and efficiency and reduces costs.
Patent Information
- Application Number
- CN202411731785.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-28
- Publication Date
- 2025-03-21
AI Technical Summary
Traditional automated test scripts cannot change dynamically with the update of server system functions, resulting in the inability to overwrite all functions of the test server software and hardware, and the generation of manual test scripts is inefficient and costly.
By obtaining and splitting test cases and test scripts, establishing a set of corresponding relationships, and using initial model training to obtain the target model, which is used to generate automated test scripts, covering all functions of the server software and hardware.
Improves the efficiency of generating manual test scripts, reduces costs, and enhances the coverage of test scripts to server software and hardware functions.
Smart Images

Figure CN119669068A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of machine learning, and in particular to a model training method, device, computer equipment and storage medium. Background Art
[0002] Automated testing is an integral part of the server software and hardware development process. It helps developers discover and fix errors and defects in server software and hardware, thereby improving server quality.
[0003] However, as the complexity and scale of server systems increase, the functions of server hardware and software are constantly updated, and traditional automated test scripts cannot change dynamically with the update of functions, resulting in the inability to cover all functions corresponding to the server hardware and software. In addition, for some boundary tests and special tests, manual test scripts corresponding to manual test cases need to be manually generated, and then tested using manual test scripts, which is inefficient and costly. Summary of the invention
[0004] In view of this, the present invention provides a model training method, apparatus, computer equipment and storage medium to solve the problem of low efficiency and high cost in generating manual test scripts.
[0005] In a first aspect, the present invention provides a model training method, the method comprising: obtaining N test case units, the N test case units belonging to a first test case, the first test case corresponding to M first test scripts, and the type of the first test case being a manual test case type; splitting each of the M first test scripts into L script units, and obtaining annotation information of each of the L script units, M<L; establishing a correspondence relationship set between the N test case units and the L script units, the correspondence relationship set comprising a plurality of correspondence relationships, each correspondence relationship being a correspondence relationship between a test case unit and at least one script unit; inputting the annotation information and the correspondence relationship set into an initial model for training to obtain a target model, and using the target model to perform script generation on a target test case to obtain a target test script, the target test case being input into the target model at a granularity of a test case unit, and the target test script being used to test the performance of a server.
[0006] Based on the method of the first aspect above, N test case units can be obtained, and each of the M first test scripts corresponding to the N test case units can be split into L script units, a corresponding relationship set between the N test case units and the L script units is established, and a target model is obtained by training based on the annotation information and the corresponding relationship set, and the target model is used to generate scripts for the target test cases to obtain the target test scripts.
[0007] Since the N test case units belong to the first test case, the type of the first test case is a manual test case type, and the target model is trained based on the N test cases and the M first test scripts corresponding to the first test cases, the target model can generate a manual test script corresponding to the manual test case, avoiding the need to manually generate a test script when the test script cannot cover special test cases or when the functions of the server hardware and software change, thereby improving the efficiency of generating manual test scripts, reducing costs, and at the same time, improving the coverage of the test scripts in testing the functions of the server hardware and software.
[0008] In an optional implementation, obtaining N test case units includes: obtaining a first test case; identifying logical structure information of the first test case through a preset tool, and splitting the first test case into N test case units according to the logical structure information.
[0009] In this implementation, the first test case may be split into N use case units according to the logical structure information of the first test case, thereby facilitating subsequent training of a classification model based on the N use case units.
[0010] In an optional embodiment, the method also includes: obtaining multiple historical test cases; splitting each test case in the multiple historical test cases into a number of historical case units; obtaining use case annotation information of each of the several historical case units, wherein the use case annotation information is used to indicate the use case type of each use case unit; inputting the several use case units and the use case annotation information into a preset model to obtain a classification model, and using the classification model to classify the use case type of the target test case.
[0011] In this implementation, a classification model may be obtained by training multiple historical use cases, so that the classification model has the function of distinguishing test cases of different use case types.
[0012] In an optional embodiment, before using the target model to generate a script for the target test case to obtain the target test script, the method also includes: obtaining the target test case; identifying the target logical structure information of the target test case through a preset tool, and splitting the target test case into multiple target case units according to the target logical structure information; inputting the multiple target case units into a classification model, and outputting a classification result, wherein the classification result is used to indicate that the case type of the target test case is a manual test case type.
[0013] In this implementation manner, the target test case may be split into a plurality of target test case units, which are then input into a classification model to determine that the test case type of the target test case is a manual test case type.
[0014] In an optional embodiment, the annotation information and the corresponding relationship set are input into the initial model for training to obtain a target model, including: obtaining F eigenvalues according to the annotation information and the corresponding relationship set, F ≥ 1 and is a positive integer; dividing the F eigenvalues into a training set and a test set, the training set includes a first number of eigenvalues, the test set includes a second number of eigenvalues, and the sum of the first number and the second number is F; obtaining the initial model, and adding P fully connected layers, Q random inactivation layers and an output layer to the initial model to obtain a first model; compiling the first model, and inputting the first number of eigenvalues into the first model for training to obtain a target model; inputting the second number of eigenvalues into the target model for testing, and outputting test results, the test results indicating that the accuracy of the test script corresponding to the test case generated by the target model is greater than or equal to a preset threshold.
[0015] In this implementation, multiple eigenvalues can be obtained based on the annotation information and the corresponding relationship set, and the multiple eigenvalues can be divided into a training set and a test set, and a fully connected layer, a random inactivation layer, and an output layer are added to the initial model to construct a first model, compile the first model, and obtain a target model by training with the training set, and obtain the target model by testing with the test set, so that the accuracy of the target model is greater than or equal to a preset threshold.
[0016] In an optional embodiment, the P fully connected layers include a first fully connected layer and a second fully connected layer; the Q random dropout layers include a first random dropout layer and a second random dropout layer; P fully connected layers, Q random dropout layers and an output layer are added to the initial model to obtain a first model, including: adding the first fully connected layer in sequence to the initial model, and setting the input shape, the first number of nodes and the first activation function of the first fully connected layer, the first number of nodes being a first value; adding the first random dropout layer after the first fully connected layer, and setting the first dropout rate of the first random dropout layer, the first dropout rate being a third value; adding the second fully connected layer after the first random dropout layer, and setting the second number of nodes and the second activation function of the second fully connected layer, the second number of nodes being a second value; adding the second random dropout layer after the second fully connected layer, and setting the second dropout rate of the second random dropout layer, the second dropout rate being a fourth value; adding the output layer to the second random dropout layer to obtain the second model; configuring the optimizer, loss function and evaluation index of the second model to obtain the first model.
[0017] In this embodiment, the first model is obtained by setting the model parameters of the added fully connected layer and random inactivation layer, as well as the optimizer, loss function and evaluation index. The first model can perform feature fusion, classification and regression, feature dimension transformation, fully connect all neurons in the previous layer with all neurons in the current layer, transform through the weight matrix and activation function, and randomly discard some neurons during the training process, reduce the model's dependence on training data, prevent model overfitting, regularize, enhance robustness, and facilitate subsequent training of the first model based on multiple eigenvalues to obtain the target model.
[0018] In an optional embodiment, the method also includes: obtaining the number of categories corresponding to F eigenvalues; calculating the number P of fully connected layers to be added to the initial model according to a preset algorithm and the number of categories, the preset algorithm is: P = min(max(2, log2(S)), 5); wherein S represents the number of categories.
[0019] In this implementation, the number of fully connected layers that need to be added to the first model can be calculated based on a preset algorithm, so that the number of fully connected layers of the first model is appropriate, avoiding the problem of too many fully connected layers leading to high model complexity, and too few fully connected layers leading to insufficient model feature fusion, resulting in reduced model accuracy.
[0020] In a second aspect, the present invention provides a model training device, including an acquisition module for acquiring N test case units, the N test case units belonging to a first test case, the first test case corresponding to M first test scripts, and the type of the first test case being a manual test case type; a processing module for splitting each of the M first test scripts into L script units, and acquiring annotation information of each of the L script units, M<L; the processing module is also used to establish a correspondence relationship set between the N test case units and the L script units, the correspondence relationship set including multiple correspondence relationships, each correspondence relationship being a correspondence relationship between a test case unit and at least one script unit; the processing module is also used to input the annotation information and the correspondence relationship set into an initial model for training to obtain a target model, and use the target model to perform script generation on a target test case to obtain a target test script, wherein the target test case is input into the target model at a granularity of a test case unit.
[0021] In a third aspect, the present invention provides a computer device, comprising: a memory and a processor, the memory and the processor are communicatively connected to each other, computer instructions are stored in the memory, and the processor executes the model training method of the first aspect or any corresponding embodiment thereof by executing the computer instructions.
[0022] In a fourth aspect, the present invention provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the model training method of the first aspect or any corresponding embodiment thereof.
[0023] In a fifth aspect, the present invention provides a computer program product, comprising computer instructions, which are used to enable a computer to execute the model training method of the first aspect or any corresponding embodiment thereof. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0025] Figure 1 is a flow chart of a model training method according to an embodiment of the present invention;
[0026] Figure 2 is a flowchart of another model training method according to an embodiment of the present invention;
[0027] Figure 3 is a structural block diagram of a model training device according to an embodiment of the present invention;
[0028] Figure 4 It is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0029] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0030] Automated testing is an integral part of the server hardware and software development process. It helps developers discover and fix errors and defects in server hardware and software, thereby improving server quality. However, as the complexity and scale of server systems increase, traditional automated testing methods can no longer meet the needs.
[0031] The technical solution provided by the embodiment of the present invention is applied to the scenario of testing the server software and hardware functions through test scripts. In particular, the traditional automated test script cannot change dynamically with the update of functions, resulting in the inability to cover all functions corresponding to the server software and hardware. Traditional automated test scripts are difficult to capture potential defects in the server software and hardware system, especially in the boundary and rare cases of the server software and hardware system. Therefore, the embodiment of the present invention is also applicable to some boundary tests and special test scenarios.
[0032] In these scenarios, manual test scripts corresponding to manual test cases need to be manually generated and then tested using the manual test scripts, which is inefficient and costly, with low test coverage and defect discovery rate.
[0033] In order to solve the above technical problems, an embodiment of the present invention provides a model training method, which obtains a target model through training to solve the problems of low efficiency and high cost of generating manual test scripts, low test coverage and low defect detection rate.
[0034] The model training method provided in the embodiment of the present invention can be performed by a model training device. The model training device can be any device with communication capabilities and computing capabilities. For example, the model training device is a server, a cloud server, or a cloud device.
[0035] According to an embodiment of the present invention, a model training method embodiment is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0036] In this embodiment, a model training method is provided, which can be used in the above-mentioned model training device. Figure 1 is a flow chart of a model training method according to an embodiment of the present invention. Figure 1 As shown, the process includes the following steps:
[0037] S101: Obtain N test case units.
[0038] Among them, N test case units belong to the first test case. The first test case corresponds to M first test scripts. The type of the first test case is a manual test case type.
[0039] In some optional implementations, the model training device obtains a first test case; identifies the logical structure information of the first test case through a preset tool, and splits the first test case into N test case units according to the logical structure information.
[0040] The preset tool may be a code analysis tool, for example, a static code analysis tool.
[0041] It can be understood that a use case unit is a smaller test unit than a test case.
[0042] S102: Split each of the M first test scripts into L script units, and obtain annotation information of each of the L script units.
[0043] Among them, M<L.
[0044] The annotation information includes a plurality of annotation statements. The annotation information is used to describe the test type, test target, test environment and test data of each script unit. The annotation information in the embodiment of the present invention may also be the variable name in the script unit.
[0045] Test types include functional test type, performance test type, and security test type.
[0046] Test goals are used to express the test results expected for each script unit.
[0047] In some optional embodiments, the model training device obtains M first test scripts; identifies the logical structure information of each first test script through a preset tool, and splits each first test script into L script units according to the logical structure information of each first test script.
[0048] In one example, after the model training device obtains the annotation information of each script unit in L script units, it parses the annotation information of each script unit through natural language processing technology, performs sentence segmentation on the annotation information, and performs word segmentation on each annotation sentence to obtain multiple annotations after the annotation information is split.
[0049] It can be understood that the model training device can perform feature extraction on multiple annotations and L script units, extract multiple key features from the multiple annotations and L script units, and obtain F features corresponding to the multiple key features.
[0050] S103: Establish a corresponding relationship set between the N test case units and the L script units.
[0051] The corresponding relationship set includes a plurality of corresponding relationships, each of which is a corresponding relationship between a test case unit and at least one script unit.
[0052] S104: input the annotation information and the corresponding relationship set into the initial model for training to obtain a target model, and use the target model to generate a script for a target test case to obtain a target test script.
[0053] The target test case is input into the target model with the test case unit as the granularity. It can be understood that the target test case also needs to be split into multiple test case units before being input into the target model.
[0054] In the embodiment of the present invention, the target test script is used to test the performance of the server. For example, the performance of the server may be the fault tolerance, recovery mechanism, robustness, robustness and security of the server.
[0055] Correspondingly, the target test script can be a test script that simulates the failure of a key component (such as a network card, hard disk, power supply) to test the fault tolerance and recovery mechanism of the server; the target test script can be a test script that simulates the failure of multiple components (such as disconnecting multiple network connections or multiple hard disk failures at the same time) to test the robustness of the server; the target test script can be a test script that simulates the sending of abnormal or illegal data input (such as malformed data packets, overlong strings) to test the robustness and security of the server.
[0056] The initial model may be a sequential model. For example, the sequential model may be a Sequential model.
[0057] In one example, the model training device can input annotation information and a set of corresponding relationships into an initial model for training through a machine learning algorithm to obtain a target model.
[0058] Among them, the machine learning algorithm can be a decision tree algorithm, a random forest algorithm, or a support vector machine algorithm.
[0059] Optionally, testers can review the generated target test scripts to ensure that they meet the actual test requirements and make adjustments and optimizations if necessary.
[0060] In an optional embodiment, the model training device obtains F eigenvalues based on the annotation information and the corresponding relationship set; divides the F eigenvalues into a training set and a test set; obtains an initial model, and adds P fully connected layers, Q random inactivation layers and an output layer to the initial model to obtain a first model; compiles the first model, and inputs the first number of eigenvalues into the first model for training to obtain a target model; inputs the second number of eigenvalues into the target model for testing, and outputs the test results.
[0061] Wherein, F ≥ 1 and is a positive integer.
[0062] The training set includes a first number of feature values. The test set includes a second number of feature values. The sum of the first number and the second number is F. Optionally, the ratio of the first number to the second number can be set according to actual needs. For example, the ratio can be 9:1.
[0063] The test result indicates that the accuracy of the test script corresponding to the test case generated by the target model is greater than or equal to a preset threshold.
[0064] The preset threshold value can be set according to actual needs without limitation. For example, the preset threshold value can be 95%.
[0065] In an optional implementation, the model training device obtains the number of categories corresponding to F eigenvalues; and calculates the number P of fully connected layers to be added to the initial model based on a preset algorithm and the number of categories.
[0066] The preset algorithm is: P=min(max(2, log2(S)), 5); where S represents the number of categories.
[0067] Exemplarily, taking S as 2, P=min(max(2, log2(2)), 5) the model training device calculates the number of fully connected layers 2 that need to be added to the initial model based on a preset algorithm.
[0068] The number of categories is associated with the F eigenvalues. The categories of the eigenvalues are associated with the types of the eigenvalues.
[0069] In an optional embodiment, the model training device obtains the baseline number of random inactivation layers, the number of model parameters required for the first model, the first weights corresponding to the number of model parameters, and the second weights corresponding to F eigenvalues; and calculates the number Q of random inactivation layers to be added to the initial model based on the first algorithm, the baseline number of random inactivation layers, the number of model parameters, F, the first weight, and the second weight.
[0070] The first algorithm is: Q=D+α*A+β*F.
[0071] Among them, D represents the number of baseline random dropout layers; α represents the first weight; β represents the second weight; A represents the number of model parameters; and F represents the number of eigenvalues.
[0072] In one example, the P fully connected layers include a first fully connected layer and a second fully connected layer; the Q random dropout layers include a first random dropout layer and a second random dropout layer.
[0073] The fully connected layer can be a Dense layer. The fully connected layer fully connects all neurons in the previous layer with all neurons in the current layer to achieve feature fusion and abstraction.
[0074] The random dropout layer can be a Dropout layer. The random dropout layer randomly drops a portion of neurons during the training process to reduce the model's dependence on training data, thereby improving the model's generalization ability.
[0075] It is understandable that the number of P and Q can be the same. The number of Q can also be smaller than the number of P.
[0076] In an optional embodiment, the model training device adds two fully connected layers, two random dropout layers and an output layer to the initial model to obtain a first model, including: adding the first fully connected layer to the initial model in sequence, and setting the input shape, the first number of nodes and the first activation function of the first fully connected layer; adding the first random dropout layer after the first fully connected layer, and setting the first dropout rate of the first random dropout layer; adding the second fully connected layer after the first random dropout layer, and setting the second number of nodes and the second activation function of the second fully connected layer; adding the second random dropout layer after the second fully connected layer, and setting the second dropout rate of the second random dropout layer; adding the output layer to the second random dropout layer to obtain the second model; configuring the optimizer, loss function and evaluation index of the second model to obtain the first model.
[0077] The first node number is a first value, and the second node number is a second value. For example, the first node number may be 512, and the second node number may be 256.
[0078] The first discard rate is a third value; the second discard rate is a fourth value. The third value may be consistent with the fourth value or may be different. For example, the third value and the fourth value are both 0.5.
[0079] The first activation function may be a ReLU function. The second activation function may be a Sigmoid function.
[0080] The optimizer can be an Adam optimizer.
[0081] The loss function can be a binary cross entropy function (binary_crossentropy).
[0082] The evaluation metric can be accuracy.
[0083] In an optional embodiment, before using the target model to generate a script for the target test case to obtain the target test script, the model training device obtains the target test case; identifies the target logical structure information of the target test case through a preset tool, and splits the target test case into multiple target case units according to the target logical structure information; inputs the multiple target case units into the classification model, and outputs the classification results.
[0084] The classification result is used to indicate that the case type of the target test case is a manual test case type.
[0085] Specifically, the model training device can also train a classification model, such as Figure 2 As shown, Figure 2 is a flow chart of another model training method according to an embodiment of the present invention; the model training device specifically performs the following steps:
[0086] S201: Obtain multiple historical test cases.
[0087] S202: Split each test case in the multiple historical test cases into a plurality of historical test case units.
[0088] S203: Obtain use case annotation information of each of several historical use case units.
[0089] The use case annotation information is used to indicate the use case type of each use case unit. The use case type includes an automatic test case type or a manual test case type.
[0090] S204: Input a number of use case units and use case annotation information into a preset model to obtain a classification model, and use the classification model to classify the use case types of the target test cases.
[0091] The preset model may be any model with a classification function, for example, the preset model is a SVM model.
[0092] Optionally, the model training device evaluates the accuracy of the classification model through cross-validation to obtain an evaluation result; and adjusts the classification model parameters according to the evaluation result to optimize the classification effect.
[0093] Based on the above Figure 1 According to the method, the model training device can obtain N test case units, and split each of the M first test scripts corresponding to the N test case units into L script units, establish a corresponding relationship set between the N test case units and the L script units, and obtain a target model based on the annotation information and the corresponding relationship set training, and use the target model to generate scripts for target test cases to obtain target test scripts.
[0094] Since the N test case units belong to the first test case, the type of the first test case is a manual test case type, and the target model is trained based on the N test cases and the M first test scripts corresponding to the first test cases, the target model can generate a manual test script corresponding to the manual test case, avoiding the need to manually generate a test script when the test script cannot cover special test cases or when the functions of the server hardware and software change, thereby improving the efficiency of generating manual test scripts, reducing costs, and at the same time, improving the coverage of the test scripts in testing the functions of the server hardware and software.
[0095] In the present embodiment, a model training device is also provided, which is used to implement the above-mentioned embodiments and preferred embodiments, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceived.
[0096] This embodiment provides a model training device, such as Figure 3 As shown, Figure 3 : is a structural block diagram of a model training device according to an embodiment of the present invention; the model training device comprises:
[0097] The acquisition module 301 is used to acquire N test case units, where the N test case units belong to a first test case, the first test case corresponds to M first test scripts, and the type of the first test case is a manual test case type.
[0098] The processing module 302 is used to split each of the M first test scripts into L script units, and obtain annotation information of each of the L script units, M<L.
[0099] The processing module 302 is further used to establish a correspondence relationship set between the N test case units and the L script units, where the correspondence relationship set includes multiple correspondence relationships, each of which is a correspondence relationship between a test case unit and at least one script unit.
[0100] The processing module 302 is also used to input the annotation information and the corresponding relationship set into the initial model for training to obtain the target model, and use the target model to generate a script for the target test case to obtain a target test script. The target test case is input into the target model at the granularity of the test case unit, and the target test script is used to test the performance of the server.
[0101] In some optional implementations, the acquisition module 301 is specifically used to acquire the first test case; the acquisition module 301 is specifically used to identify the logical structure information of the first test case through a preset tool, and split the first test case into N use case units according to the logical structure information.
[0102] In some optional implementations, the acquisition module 301 is also used to acquire multiple historical test cases; the processing module 302 is also used to split each test case in the multiple historical test cases into a number of historical use case units; the acquisition module 301 is also used to acquire use case annotation information of each of the several historical use case units, and the use case annotation information is used to indicate the use case type of each use case unit; the processing module 302 is also used to input the several use case units and the use case annotation information into a preset model to obtain a classification model, and use the classification model to classify the use case type of the target test case.
[0103] In some optional embodiments, before using the target model to generate a script for the target test case to obtain the target test script, the acquisition module 301 is also used to obtain the target test case; the processing module 302 is also used to identify the target logical structure information of the target test case through a preset tool, and split the target test case into multiple target case units according to the target logical structure information; the processing module 302 is also used to input the multiple target case units into a classification model and output a classification result, and the classification result is used to indicate that the case type of the target test case is a manual test case type.
[0104] In some optional embodiments, the processing module 302 is further specifically used to obtain F eigenvalues according to the annotation information and the corresponding relationship set, where F ≥ 1 and is a positive integer; the processing module 302 is further specifically used to divide the F eigenvalues into a training set and a test set, the training set includes a first number of eigenvalues, the test set includes a second number of eigenvalues, and the sum of the first number and the second number is F; the processing module 302 is further specifically used to obtain an initial model, and add P fully connected layers, Q random inactivation layers and an output layer to the initial model to obtain a first model; the processing module 302 is further specifically used to compile the first model, and input the first number of eigenvalues into the first model for training to obtain a target model; the processing module 302 is further specifically used to input the second number of eigenvalues into the target model for testing, and output a test result, the test result indicating that the accuracy of the test script corresponding to the test case generated by the target model is greater than or equal to a preset threshold.
[0105] In some optional embodiments, the P fully connected layers include a first fully connected layer and a second fully connected layer; the Q random dropout layers include a first random dropout layer and a second random dropout layer; the processing module 302 is further specifically used to sequentially add the first fully connected layer to the initial model, and set the input shape, the first number of nodes and the first activation function of the first fully connected layer, where the first number of nodes is a first value; the processing module 302 is further specifically used to add the first random dropout layer after the first fully connected layer, and set the first dropout rate of the first random dropout layer, where the first dropout rate is a third value; the processing module 302 is further specifically used to add the second fully connected layer after the first random dropout layer, and set the second number of nodes and the second activation function of the second fully connected layer, where the second number of nodes is a second value.
[0106] The processing module 302 is also specifically used to add a second random dropout layer after the second fully connected layer, and set a second dropout rate of the second random dropout layer, where the second dropout rate is a fourth value; the processing module 302 is also specifically used to add an output layer to the second random dropout layer to obtain a second model; the processing module 302 is also specifically used to configure the optimizer, loss function and evaluation index of the second model to obtain the first model.
[0107] In some optional embodiments, the acquisition module 301 is also used to obtain the number of categories corresponding to F eigenvalues; the processing module 302 is also used to calculate the number P of fully connected layers to be added to the initial model according to a preset algorithm and the number of categories, and the preset algorithm is: P = min(max(2, log2(S)), 5); wherein S represents the number of categories.
[0108] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.
[0109] The model training device in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.
[0110] The embodiment of the present invention also provides a computer device having the above Figure 3 The model training apparatus shown.
[0111] See also Figure 4 , Figure 4 is a schematic diagram of the structure of a computer device provided by an optional embodiment of the present invention, such as Figure 4As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process the instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 4 A processor 10 is taken as an example.
[0112] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.
[0113] The memory 20 stores instructions executable by at least one processor 10, so that the at least one processor 10 executes the method shown in the above embodiment.
[0114] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0115] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.
[0116] The computer device further comprises a communication interface 30 for the computer device to communicate with other devices or a communication network.
[0117] The embodiment of the present invention also provides a computer-readable storage medium. The method according to the embodiment of the present invention can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium through a network download, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state hard disk, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.
[0118] Part of the present application may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present application through the operation of the computer. Those skilled in the art should understand that the existence of computer program instructions in computer-readable media includes but is not limited to source files, executable files, installation package files, etc., and accordingly, the way in which computer program instructions are executed by a computer includes but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium can be any available computer-readable storage medium or communication medium accessible to the computer.
[0119] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.
Claims
1. A model training method, characterized in that: The method comprises: Obtain N test case units, where the N test case units belong to a first test case, the first test case corresponds to M first test scripts, and the type of the first test case is a manual test case type; Splitting each of the M first test scripts into L script units, and obtaining annotation information of each of the L script units, M<L; Establishing a correspondence relationship set between the N test case units and the L script units, the correspondence relationship set comprising a plurality of correspondence relationships, each correspondence relationship being a correspondence relationship between a test case unit and at least one script unit; The annotation information and the corresponding relationship set are input into the initial model for training to obtain a target model, and the target model is used to generate a script for the target test case to obtain a target test script. The target test case is input into the target model with the test case unit as the granularity, and the target test script is used to test the performance of the server.
2. The method according to claim 1, characterized in that The obtaining of N test case units includes: Obtaining the first test case; The logical structure information of the first test case is identified by a preset tool, and the first test case is split into the N test case units according to the logical structure information.
3. The method according to claim 1, characterized in that The method further comprises: Get multiple historical test cases; Splitting each of the multiple historical test cases into a plurality of historical test case units; Acquire use case annotation information of each of the plurality of historical use case units, where the use case annotation information is used to indicate a use case type of each of the use case units; The plurality of use case units and the use case annotation information are input into a preset model to obtain a classification model, and the classification model is used to classify the use case types of the target test cases.
4. The method according to claim 3, characterized in that Before generating a script for the target test case using the target model to obtain the target test script, the method further includes: Obtaining the target test case; Identifying the target logical structure information of the target test case through the preset tool, and splitting the target test case into multiple target case units according to the target logical structure information; The multiple target use case units are input into the classification model, and a classification result is output, where the classification result is used to indicate that the use case type of the target test case is the manual test case type.
5. The method according to claim 1, characterized in that The step of inputting the annotation information and the corresponding relationship set into an initial model for training to obtain a target model comprises: According to the annotation information and the corresponding relationship set, F eigenvalues are obtained, where F ≥ 1 and is a positive integer; Divide the F eigenvalues into a training set and a test set, wherein the training set includes a first number of the eigenvalues, and the test set includes a second number of the eigenvalues, and the sum of the first number and the second number is F; Obtain the initial model, and add P fully connected layers, Q random dropout layers, and an output layer to the initial model to obtain a first model; Compiling the first model, and inputting the first number of feature values into the first model for training to obtain the target model; The second number of feature values are input into the target model for testing, and a test result is output, wherein the test result indicates that the accuracy of the test script corresponding to the test case generated by the target model is greater than or equal to a preset threshold.
6. The method according to claim 5, characterized in that The P fully connected layers include a first fully connected layer and a second fully connected layer; the Q random inactivation layers include a first random inactivation layer and a second random inactivation layer; and the adding of the P fully connected layers, the Q random inactivation layers and the output layer to the initial model to obtain a first model includes: Adding the first fully connected layer to the initial model in sequence, and setting an input shape, a first number of nodes, and a first activation function of the first fully connected layer, where the first number of nodes is a first value; Adding the first random dropout layer after the first fully connected layer, and setting a first dropout rate of the first random dropout layer, wherein the first dropout rate is a third value; Adding the second fully connected layer after the first random dropout layer, and setting a second number of nodes and a second activation function of the second fully connected layer, wherein the second number of nodes is the second value; adding the second random dropout layer after the second fully connected layer, and setting a second dropout rate of the second random dropout layer, wherein the second dropout rate is a fourth value; Adding an output layer to the second random dropout layer to obtain a second model; Configure the optimizer, loss function, and evaluation index of the second model to obtain the first model.
7. The method according to claim 5, characterized in that The method further comprises: Obtain the number of categories corresponding to the F eigenvalues; According to the preset algorithm and the number of classifications, the number P of fully connected layers to be added to the initial model is calculated. The preset algorithm is: P = min(max(2, log2(S)), 5) Wherein, S represents the number of classifications.
8. A model training device, characterized in that: The device comprises: An acquisition module, used for acquiring N test case units, wherein the N test case units belong to a first test case, the first test case corresponds to M first test scripts, and the type of the first test case is a manual test case type; A processing module, used for splitting each of the M first test scripts into L script units, and obtaining annotation information of each of the L script units, M<L; The processing module is further used to establish a corresponding relationship set between the N test case units and the L script units, wherein the corresponding relationship set includes multiple corresponding relationships, each corresponding relationship being a corresponding relationship between a test case unit and at least one script unit; The processing module is also used to input the annotation information and the corresponding relationship set into the initial model for training to obtain a target model, and use the target model to script the target test case to obtain a target test script. The target test case is input into the target model with the test case unit as the granularity.
9. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the model training method according to any one of claims 1 to 7 by executing the computer instructions.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the model training method described in any one of claims 1 to 7.