Picture, information classification model generation method and device, equipment and storage medium
By generating a target classification model based on the quantitative determination of the influence level of the operator, the problem of high operating cost of the business classification model is solved, and speed improvement and quantitative quality assurance are achieved.
Patent Information
- Application Number
- CN202310063834.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-01-11
- Publication Date
- 2026-02-27
- Estimated Expiration
- 2043-01-11
AI Technical Summary
Existing business classification models consume a lot of time and computing resources during operation, and the quantification process relies on human experience, making it difficult to guarantee the quality and effectiveness of quantification.
By determining the degree of influence of the classification processing associated with each operator on the image or information to be classified, and performing quantification judgment operations on the operators in order of increasing degree of influence, a target classification model is generated.
Without affecting the effectiveness of business applications, it improved the running speed of business applications, saved human resources, and enhanced quantitative results.
Smart Images

Figure CN115994318B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the technical field of computer, and particularly relates to a picture and information classification model generation method and device, equipment and storage medium. BACKGROUND
[0002] Business applications usually need to rely on the support of business classification models, such as a picture classification model, a text classification model and a video classification model, and there are generally floating-point parameters in these business classification models, which may cause the running of the business classification model to consume a large amount of time, computing resources and storage resources.
[0003] In order to reduce the running consumption of the business classification model and thus improve the implementation speed of the business application and reduce the running load of the business application, the related technology proposes to quantize the business classification model, but the quantization processing of the business classification model often depends more on the experience of algorithm engineers, and the quantization quality and quantization effect are difficult to guarantee, thereby affecting the running speed and implementation effect of the business application. SUMMARY
[0004] The present disclosure provides a picture and information classification model generation method, device, equipment and storage medium, which can guarantee the quantization effect of the quantization processing of the model and improve the running speed of the business application without affecting the implementation effect of the business application.
[0005] The technical solutions of the embodiments of the present disclosure are as follows:
[0006] According to a first aspect of the embodiments of the present disclosure, a picture classification model generation method is provided, including: obtaining an initial classification model used to determine a classification result of a picture to be classified; the initial classification model includes m operators; any operator is used to perform classification processing associated with picture classification on the picture to be classified; m is a positive integer; according to the operation order and type of the classification processing associated with each operator, the influence degree level of the classification processing associated with each operator on the classification result of the picture to be classified is determined; the quantization determination operation is performed on each operator in order from low to high according to the influence degree level corresponding to each operator, and at least one target operator is obtained; the quantization determination operation is used to determine the operator obtained after quantization as the target operator when the quantization obtained classification model satisfies a first preset condition; and at least one target operator in the initial classification model is quantized to generate a target classification model used to determine the classification result of the picture to be classified.
[0007] Optionally, the initial classification model comprises n structural blocks; each structural block comprises at least one operator; any structural block is configured to perform a classification process associated with picture classification on the picture to be classified; n is a positive integer less than m; and the specific method for determining the influence level of the classification process associated with each operator on the classification result of the picture to be classified according to the operation sequence and type of the classification process associated with each operator comprises: determining the operation sequence of the classification process associated with the n structural blocks; determining the influence level of the classification process associated with the n structural blocks on the classification result of the picture to be classified according to a first preset rule; determining the operation sequence of the classification process associated with at least one operator in each structural block; determining the influence level of the classification process associated with at least one operator in each structural block on the classification result of the picture to be classified according to a second preset rule; and determining the influence level of each operator according to the influence level corresponding to the n structural blocks and the influence level corresponding to at least one operator in each structural block.
[0008] Optionally, the first preset rule comprises: when a first structural block and a second structural block in the n structural blocks are both preset type structural blocks, and the operation sequence of the first structural block is located before the operation sequence of the second structural block, or when the first structural block is a preset type structural block and the second structural block is not a preset type structural block, or when the first structural block and the second structural block are both not preset type structural blocks and the operation sequence of the first structural block is located before the operation sequence of the second structural block, determining that the influence level of the first structural block is lower than that of the second structural block; the preset type structural block is a structural block comprising a preset type operator; the preset type operator is an operator with a normalization function; the first structural block is any one of the n structural blocks; and the second structural block is any one of the n structural blocks except the first structural block.
[0009] Optionally, the second preset rule comprises: when the operator following a first operator and the operator following a second operator in a structural block are both preset type operators, and the operation sequence of the first operator is located before the operation sequence of the second operator, or when the operator following the first operator is a preset type operator and the operator following the second operator is not a preset type operator, or when the operator following the first operator and the operator following the second operator are both not preset type operators and the operation sequence of the first operator is located before the operation sequence of the second operator, determining that the influence level of the first operator is lower than that of the second operator; the first operator is any one of the operators in the structural block; and the second operator is any one of the operators in the structural block except the first operator.
[0010] Optionally, the specific method for sequentially performing the quantization determination operation on each operator in the order from low to high of the influence degree level corresponding to each operator to obtain at least one target operator comprises: quantizing each operator in the current operator set to obtain a current classification model; the current operator set comprises: the target operator in the first i operators and the previous i-1 operators in the order from low to high of the influence degree level corresponding to each operator; i is a positive integer less than or equal to m; the current classification model is a model obtained after quantization of the i th operator; when the current classification model meets a first preset condition, the i th operator is determined as the target operator, and the value of i is updated; the first preset condition comprises: the relative gap between the classification result of the to-be-classified picture determined by the current classification model and the classification result of the to-be-classified picture determined by the initial classification model is less than or equal to a preset threshold, and the running time consumption of the classification result determined by the current classification model is less than a current time threshold; the current time threshold is the running time consumption of the classification result determined by the classification model obtained after quantizing each target operator in the current operator set; when the current classification model does not meet the first preset condition, the value of i is updated; and the quantization of each operator in the current operator set is repeated until i is greater than m, and at least one target operator is obtained.
[0011] Optionally, the specific method for quantizing each operator in the current operator set to obtain a current classification model comprises: quantizing each target operator in the current operator set according to a target quantization algorithm corresponding to each target operator to obtain a first model; quantizing the i th operator according to a plurality of preset quantization algorithms based on the first model to obtain a plurality of second models corresponding one by one to the plurality of preset quantization algorithms; and determining the second model meeting a second preset condition in the plurality of second models as the current classification model.
[0012] Optionally, the picture classification model generation method further comprises: determining the preset quantization algorithm corresponding to the second model meeting the second preset condition as the target quantization algorithm corresponding to the i th operator.
[0013] Optionally, the specific method for quantizing at least one target operator in the initial classification model to generate a target classification model for determining the classification result of the to-be-classified picture comprises: quantizing each target operator according to a target quantization algorithm corresponding to each target operator to generate the target classification model.
[0014] Optionally, the second preset condition comprises: a relative difference between the classification result of the to-be-classified picture determined by the second model and the classification result of the to-be-classified picture determined by the initial classification model is less than or equal to a preset threshold, and a running time of the classification result determined by the second model is less than or equal to a preset time threshold; and the specific method of determining the second model that meets the second preset condition from the plurality of second models as the current classification model comprises: classifying the to-be-classified picture based on the second model to obtain running information of the second model; the running information comprises the classification result of the to-be-classified picture determined by the second model and the running time of the classification result determined by the second model; and when the relative difference between the classification result of the to-be-classified picture determined by the second model and the classification result of the to-be-classified picture determined by the initial classification model is less than or equal to the preset threshold, and the running time of the classification result determined by the second model is less than or equal to the preset time threshold, the second model is determined as the current classification model.
[0015] According to a second aspect of the embodiments of the present disclosure, an information classification model generation method is provided, comprising: obtaining an initial classification model for determining a classification result of to-be-classified information; the initial classification model comprising m operators; any operator is used for performing classification processing associated with information classification on the to-be-classified information; m is a positive integer; determining an influence degree level of the classification processing associated with each operator on the classification result of the to-be-classified information according to an operation sequence and type of the classification processing associated with each operator; and performing a quantization determination operation on each operator in order from low to high according to the influence degree level corresponding to each operator to obtain at least one target operator; the quantization determination operation is used for determining an operator whose classification model obtained after quantization satisfies a first preset condition as a target operator; and quantizing at least one target operator in the initial classification model to generate a target classification model for determining the classification result of the to-be-classified information.
[0016] Optionally, the initial classification model comprises n structural blocks; each structural block comprises at least one operator; any structural block is used for performing classification processing associated with information classification on the to-be-classified information; n is a positive integer smaller than m; and the specific method of determining the influence degree level of the classification processing associated with each operator on the classification result of the to-be-classified information according to the operation sequence and type of the classification processing associated with each operator comprises: determining an operation sequence of the classification processing associated with the n structural blocks; determining the influence degree level of the classification processing associated with the n structural blocks on the classification result of the to-be-classified information according to a first preset rule; determining an operation sequence of the classification processing associated with at least one operator in each structural block; determining the influence degree level of the classification processing associated with at least one operator in each structural block on the classification result of the to-be-classified information according to a second preset rule; and determining the influence degree level corresponding to each operator according to the influence degree level corresponding to the n structural blocks and the influence degree level corresponding to at least one operator in each structural block.
[0017] Optionally, the first preset rule comprises: when the first structure block and the second structure block in the n structure blocks are both preset type structure blocks, and the operation sequence of the first structure block is located before the operation sequence of the second structure block, or when the first structure block is a preset type structure block and the second structure block is not a preset type structure block, or when the first structure block and the second structure block are both not preset type structure blocks and the operation sequence of the first structure block is located before the operation sequence of the second structure block, it is determined that the influence degree level of the first structure block is lower than that of the second structure block; the preset type structure block is a structure block comprising a preset type operator; the preset type operator is an operator with a normalization function; the first structure block is any one of the n structure blocks; and the second structure block is any one of the n structure blocks except the first structure block.
[0018] Optionally, the second preset rule comprises: when the next operator of the first operator and the next operator of the second operator in the structure block are both preset type operators, and the operation sequence of the first operator is located before the operation sequence of the second operator, or when the next operator of the first operator is a preset type operator and the next operator of the second operator is not a preset type operator, or when the next operator of the first operator and the next operator of the second operator are both not preset type operators and the operation sequence of the first operator is located before the operation sequence of the second operator, it is determined that the influence degree level of the first operator is lower than that of the second operator; the first operator is any one of the operators in the structure block; and the second operator is any one of the operators in the structure block except the first operator.
[0019] Optionally, the specific method for performing the quantization determination operation on each operator in order from low to high according to the influence degree level corresponding to each operator comprises: quantizing each operator in a current operator set to obtain a current classification model; the current operator set comprises target operators in the first i-1 operators and the i th operator in order from low to high according to the influence degree level corresponding to each operator; i is a positive integer less than or equal to m; the current classification model is a model obtained after quantization of the i th operator; when the current classification model meets a first preset condition, the i th operator is determined as a target operator, and the value of i is updated; the first preset condition comprises that the relative gap between the classification result of the to-be-classified information determined by the current classification model and the classification result of the to-be-classified information determined by the initial classification model is less than or equal to a preset threshold, and the running time consumption of the classification result determined by the current classification model is less than a current time threshold; the current time threshold is the running time consumption of the classification result determined by the classification model obtained after quantization of each target operator in the current operator set; when the current classification model does not meet the first preset condition, the value of i is updated; and the quantization of each operator in the current operator set is repeated until i is greater than m, so as to obtain at least one target operator.
[0020] Optionally, the specific method of quantifying each operator in the current operator set to obtain the current classification model comprises: quantifying each target operator in the current operator set according to a target quantization algorithm corresponding to each target operator to obtain a first model; quantifying the i th operator according to a plurality of preset quantization algorithms based on the first model to obtain a plurality of second models corresponding to the plurality of preset quantization algorithms one by one; and determining a second model meeting a second preset condition from the plurality of second models as the current classification model.
[0021] Optionally, the information classification model generation method further comprises: determining a preset quantization algorithm corresponding to the second model meeting the second preset condition as the target quantization algorithm corresponding to the i th operator.
[0022] Optionally, the specific method of quantifying at least one target operator in the initial classification model to generate a target classification model for determining a classification result of the information to be classified comprises: quantifying each target operator according to a target quantization algorithm corresponding to each target operator to generate the target classification model.
[0023] Optionally, the second preset condition comprises: a relative gap between the classification result of the information to be classified determined by the second model and the classification result of the information to be classified determined by the initial classification model is less than or equal to a preset threshold, and a running time of the classification result determined by the second model is less than or equal to a preset time threshold; and the specific method of determining a second model meeting the second preset condition from the plurality of second models as the current classification model comprises: classifying the information to be classified based on the second model to obtain running information of the second model; the running information comprises the classification result of the information to be classified determined by the second model and the running time of the classification result determined by the second model; and when the relative gap between the classification result of the information to be classified determined by the second model and the classification result of the information to be classified determined by the initial classification model is less than or equal to the preset threshold, and the running time of the classification result determined by the second model is less than or equal to the preset time threshold, the second model is determined as the current classification model.
[0024] According to a third aspect of the embodiments of the present disclosure, a picture classification model generation apparatus is provided, comprising: an obtaining unit, a determining unit and a processing unit; the obtaining unit is configured to obtain an initial classification model used to determine a classification result of a picture to be classified; the initial classification model comprises m operators; any operator is used to perform a classification process associated with picture classification on the picture to be classified; m is a positive integer; the determining unit is configured to determine an influence degree level of the classification process associated with each operator on the classification result of the picture to be classified according to an operation sequence and a type of the classification process associated with each operator; the processing unit is configured to sequentially perform a quantization determination operation on each operator in an order from low to high of the influence degree level corresponding to each operator to obtain at least one target operator; the quantization determination operation is used to determine an operator whose classification model obtained after quantization satisfies a first preset condition as a target operator; and the processing unit is further configured to quantize the at least one target operator in the initial classification model to generate a target classification model used to determine the classification result of the picture to be classified.
[0025] Optionally, the initial classification model comprises n structural blocks; each structural block comprises at least one operator; any structural block is used to perform a classification process associated with picture classification on the picture to be classified; n is a positive integer smaller than m; the determining unit is specifically configured to: determine an operation sequence of the classification process associated with the n structural blocks; determine the influence degree level of the classification process associated with the n structural blocks on the classification result of the picture to be classified according to a first preset rule; determine an operation sequence of the classification process associated with at least one operator in each structural block; determine the influence degree level of the classification process associated with the at least one operator in each structural block on the classification result of the picture to be classified according to a second preset rule; and determine the influence degree level corresponding to each operator according to the influence degree level corresponding to the n structural blocks and the influence degree level corresponding to the at least one operator in each structural block.
[0026] Optionally, the first preset rule comprises: when a first structural block and a second structural block in the n structural blocks are both preset type structural blocks, and the operation sequence of the first structural block is located before the operation sequence of the second structural block, or when the first structural block is a preset type structural block and the second structural block is not a preset type structural block, or when the first structural block and the second structural block are both not preset type structural blocks and the operation sequence of the first structural block is located before the operation sequence of the second structural block, it is determined that the influence degree level of the first structural block is lower than that of the second structural block; the preset type structural block is a structural block comprising a preset type operator; the preset type operator is an operator with a normalization function; the first structural block is any one of the n structural blocks; and the second structural block is any one of the n structural blocks except the first structural block.
[0027] Optionally, the second preset rule comprises: when a next operator of the first operator and a next operator of the second operator in the structural block are preset type operators, and an operation order of the first operator is located before an operation order of the second operator, or when the next operator of the first operator is a preset type operator and the next operator of the second operator is not a preset type operator, or when the next operator of the first operator and the next operator of the second operator are not preset type operators and the operation order of the first operator is located before the operation order of the second operator, it is determined that the influence degree level of the first operator is lower than that of the second operator; the first operator is any one of the operators in the structural block; and the second operator is any one of the operators in the structural block except the first operator.
[0028] Optionally, the processing unit is specifically configured to: quantize each operator in the current operator set to obtain a current classification model; the current operator set comprises: a target operator in the first i-1 operators and the i th operator in the order of the influence degree levels of the operators from low to high; i is a positive integer less than or equal to m; the current classification model is a model obtained after quantization of the i th operator; when the current classification model meets a first preset condition, the i th operator is determined as the target operator, and the value of i is updated; the first preset condition comprises: a relative gap between a classification result of the to-be-classified picture determined by the current classification model and a classification result of the to-be-classified picture determined by the initial classification model is less than or equal to a preset threshold, and a running time consumption of the classification result determined by the current classification model is less than a current time threshold; the current time threshold is a running time consumption of the classification result determined by a classification model obtained after quantization of each target operator in the current operator set; when the current classification model does not meet the first preset condition, the value of i is updated; and the quantization of each operator in the current operator set is repeated until i is greater than m, to obtain at least one target operator.
[0029] Optionally, the processing unit is specifically configured to: quantize each target operator in the current operator set according to a target quantization algorithm corresponding to each target operator to obtain a first model; quantize the i th operator according to a plurality of preset quantization algorithms based on the first model to obtain a plurality of second models corresponding one by one to the plurality of preset quantization algorithms; and determine, as the current classification model, a second model that meets a second preset condition from the plurality of second models.
[0030] Optionally, the determination unit is further configured to determine, as the target quantization algorithm corresponding to the i th operator, a preset quantization algorithm corresponding to a second model that meets the second preset condition.
[0031] Optionally, the processing unit is specifically configured to: quantize each target operator according to a target quantization algorithm corresponding to each target operator to generate a target classification model.
[0032] Optionally, the second preset condition comprises: a relative difference between the classification result of the to-be-classified picture determined by the second model and the classification result of the to-be-classified picture determined by the initial classification model is less than or equal to a preset threshold, and a running time of the classification result determined by the second model is less than or equal to a preset time threshold; and the processing unit is specifically configured to: classify the to-be-classified picture based on the second model to obtain running information of the second model; the running information comprises the classification result of the to-be-classified picture determined by the second model and the running time of the classification result determined by the second model; and when the relative difference between the classification result of the to-be-classified picture determined by the second model and the classification result of the to-be-classified picture determined by the initial classification model is less than or equal to the preset threshold, and the running time of the classification result determined by the second model is less than or equal to the preset time threshold, determine that the second model is the current classification model.
[0033] According to a fourth aspect of the embodiments of the present disclosure, an information classification model generation apparatus is provided, comprising: an obtaining unit, a determining unit and a processing unit; the obtaining unit is configured to obtain an initial classification model for determining a classification result of to-be-classified information; the initial classification model comprises m operators; any operator is used for performing classification processing associated with information classification on the to-be-classified information; m is a positive integer; the determining unit is configured to determine an influence degree level of the classification processing associated with each operator on the classification result of the to-be-classified information according to an operation sequence and a type of the classification processing associated with each operator; the processing unit is configured to sequentially perform a quantization determination operation on each operator in an order from low to high of the influence degree level corresponding to each operator to obtain at least one target operator; the quantization determination operation is used for determining an operator whose classification model obtained after quantization satisfies a first preset condition as a target operator; and the processing unit is further configured to quantize at least one target operator in the initial classification model to generate a target classification model for determining the classification result of the to-be-classified information.
[0034] Optionally, the initial classification model comprises n structural blocks; each structural block comprises at least one operator; any structural block is used for performing classification processing associated with information classification on the to-be-classified information; n is a positive integer less than m; the determining unit is specifically configured to: determine an operation sequence of the classification processing associated with the n structural blocks; determine an influence degree level of the classification processing associated with the n structural blocks on the classification result of the to-be-classified information according to a first preset rule; determine an operation sequence of the classification processing associated with at least one operator in each structural block; determine an influence degree level of the classification processing associated with at least one operator in each structural block on the classification result of the to-be-classified information according to a second preset rule; and determine the influence degree level corresponding to each operator according to the influence degree level corresponding to the n structural blocks and the influence degree level corresponding to at least one operator in each structural block.
[0035] Optionally, the first preset rule comprises: when the first structural block and the second structural block in the n structural blocks are both preset type structural blocks, and the operation order of the first structural block is located before the operation order of the second structural block, or when the first structural block is a preset type structural block and the second structural block is not a preset type structural block, or when the first structural block and the second structural block are both not preset type structural blocks and the operation order of the first structural block is located before the operation order of the second structural block, it is determined that the influence degree level of the first structural block is lower than that of the second structural block; the preset type structural block is a structural block comprising a preset type operator; the preset type operator is an operator with a normalization function; the first structural block is any one of the n structural blocks; and the second structural block is any one of the n structural blocks except the first structural block.
[0036] Optionally, the second preset rule comprises: when the next operator of the first operator and the next operator of the second operator in the structural block are both preset type operators, and the operation order of the first operator is located before the operation order of the second operator, or when the next operator of the first operator is a preset type operator and the next operator of the second operator is not a preset type operator, or when the next operator of the first operator and the next operator of the second operator are both not preset type operators and the operation order of the first operator is located before the operation order of the second operator, it is determined that the influence degree level of the first operator is lower than that of the second operator; the first operator is any one of the operators in the structural block; and the second operator is any one of the operators in the structural block except the first operator.
[0037] Optionally, the processing unit is specifically configured to: quantize each operator in the current operator set to obtain a current classification model; the current operator set comprises: target operators in the first i operators and the first i-1 operators in the order of the influence degree levels of the operators from low to high; i is a positive integer less than or equal to m; the current classification model is a model obtained after quantization of the i th operator; when the current classification model meets a first preset condition, the i th operator is determined as the target operator, and the value of i is updated; the first preset condition comprises: a relative gap between a classification result of the to-be-classified information determined by the current classification model and a classification result of the to-be-classified information determined by the initial classification model is less than or equal to a preset threshold, and a running time consumption of the classification result determined by the current classification model is less than a current time threshold; the current time threshold is a running time consumption of the classification result determined by the classification model obtained after quantization of each target operator in the current operator set; when the current classification model does not meet the first preset condition, the value of i is updated; and the quantization of each operator in the current operator set is repeated until i is greater than m, so as to obtain at least one target operator.
[0038] Optionally, the processing unit is specifically configured to: quantize each target operator according to a target quantization algorithm corresponding to each target operator in the current operator set to obtain a first model; quantize the i th operator according to a plurality of preset quantization algorithms based on the first model to obtain a plurality of second models corresponding to the plurality of preset quantization algorithms one by one; and determine a second model that meets a second preset condition from the plurality of second models as the current classification model.
[0039] Optionally, the determining unit is further configured to determine a preset quantization algorithm corresponding to the second model that meets the second preset condition as the target quantization algorithm corresponding to the i th operator.
[0040] Optionally, the processing unit is specifically configured to: quantize each target operator according to a target quantization algorithm corresponding to each target operator to generate a target classification model.
[0041] Optionally, the second preset condition includes that a relative gap between a classification result of the to-be-classified information determined by the second model and a classification result of the to-be-classified information determined by the initial classification model is less than or equal to a preset threshold, and a running time consumption of the classification result determined by the second model is less than or equal to a preset time threshold; and the processing unit is specifically configured to: classify the to-be-classified information based on the second model to obtain running information of the second model; the running information includes the classification result of the to-be-classified information determined by the second model and the running time consumption of the classification result determined by the second model; and when the relative gap between the classification result of the to-be-classified information determined by the second model and the classification result of the to-be-classified information determined by the initial classification model is less than or equal to the preset threshold, and the running time consumption of the classification result determined by the second model is less than or equal to the preset time threshold, determine the second model as the current classification model.
[0042] According to a fifth aspect of the embodiments of the present disclosure, an electronic device is provided, which can include a processor and a memory for storing processor-executable instructions; and wherein the processor is configured to execute the instructions to implement any one of the optional picture classification model generation methods in the first aspect or any one of the optional information classification model generation methods in the second aspect.
[0043] According to a sixth aspect of the embodiments of the present disclosure, a computer-readable storage medium is provided, and the computer-readable storage medium stores instructions, when the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device can execute any one of the optional picture classification model generation methods in the first aspect or any one of the optional information classification model generation methods in the second aspect.
[0044] According to a seventh aspect of the embodiments of the present disclosure, a computer program product is provided, which includes computer instructions, when the computer instructions are executed by a processor on an electronic device, cause the electronic device to perform any one of the picture classification model generation methods or any one of the information classification model generation methods according to the second aspect.
[0045] It should be understood that the above general description and the following detailed description are only exemplary and explanatory, and cannot limit the present disclosure.
[0046] The technical solutions provided by the embodiments of the present disclosure at least have the following beneficial effects:
[0047] Based on any one of the above aspects, in the picture classification model generation method provided by the present disclosure, after obtaining an initial classification model used to determine the classification result of a picture to be classified, the influence degree level of the classification processing associated with each operator on the classification result of the picture to be classified can be determined according to the operation sequence and type of the classification processing associated with each operator in the initial classification model, and further, the quantization determination operation is sequentially performed on each operator according to the influence degree level corresponding to each operator from low to high, to obtain at least one target operator, so that the target classification model is generated by quantizing each target operator in the initial classification model.
[0048] Since the influence degree levels of the m operators in the initial classification model on the classification result of the picture to be classified are different, the influence of the initial classification model after the quantization of each operator on the precision of the initial classification model is also different. Based on this, after determining the influence degree level of the classification processing associated with each operator in the initial classification model on the classification result of the picture to be classified, as many target operators as possible are selected from the m operators according to the influence degree level corresponding to each operator from low to high, so that the target classification model can be generated by further quantizing the plurality of target operators. Compared with the way of quantizing part of the parameters by relying on artificial experience in the prior art, the model is quantized by the electronic device according to the influence degree level in the present disclosure, which not only saves human resources, but also ensures that as many operators as possible in the initial classification model are quantized to obtain the target classification model, so that the running speed of the business application can be improved without affecting the implementation effect of the business application. BRIEF DESCRIPTION OF DRAWINGS
[0049] The accompanying drawings, which are incorporated into and form part of the specification, illustrate embodiments consistent with the present disclosure and, together with the specification, serve to explain the principles of the present disclosure, and do not constitute an improper limitation on the present disclosure.
[0050] Figure 1 FIG. 1 shows a structure schematic diagram of a picture classification model generation system according to an embodiment of the present disclosure;
[0051] Figure 2 A structural schematic diagram of a terminal is shown;
[0052] Figure 3 A flow schematic diagram of a picture classification model generation method is shown;
[0053] Figure 4 A flow schematic diagram of another picture classification model generation method is shown;
[0054] Figure 5 A flow schematic diagram of another picture classification model generation method is shown;
[0055] Figure 6 A flow schematic diagram of another picture classification model generation method is shown;
[0056] Figure 7 A flow schematic diagram of another picture classification model generation method is shown;
[0057] Figure 8 A flow schematic diagram of another picture classification model generation method is shown;
[0058] Figure 9 A flow schematic diagram of another picture classification model generation method is shown;
[0059] Figure 10 A flow schematic diagram of another picture classification model generation method is shown;
[0060] Figure 11 A flow schematic diagram of an information classification model generation method is shown;
[0061] Figure 12 A flow schematic diagram of another information classification model generation method is shown;
[0062] Figure 13 A flow schematic diagram of another information classification model generation method is shown;
[0063] Figure 14 A flow schematic diagram of another information classification model generation method is shown;
[0064] Figure 15 A flow schematic diagram of another information classification model generation method is shown;
[0065] Figure 16 Fig. 1 shows a flow diagram of another information classification model generation method provided by an embodiment of the present disclosure;
[0066] Figure 17 Fig. 1 shows a flow diagram of another information classification model generation method provided by an embodiment of the present disclosure;
[0067] Figure 18 Fig. 1 shows a structure diagram of a picture classification model generation device provided by an embodiment of the present disclosure;
[0068] Figure 19 Fig. 1 shows a structure diagram of an information classification model generation device provided by an embodiment of the present disclosure;
[0069] Figure 20 Fig. 1 shows a structure diagram of another terminal provided by an embodiment of the present disclosure;
[0070] Figure 21 Fig. 1 shows a structure diagram of a server provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0071] In order to make the ordinary person skilled in the art better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be described clearly and completely below with reference to the drawings.
[0072] It should be noted that the terms "first", "second", and the like in the specification and claims of the present disclosure and the above-described drawings are used to distinguish similar objects, and do not necessarily indicate a specific order or a chronological sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present disclosure described herein can be implemented in an order other than that illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Rather, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0073] It should also be understood that the term "comprising" indicates the presence of described features, integers, steps, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, and / or components.
[0074] The data involved in the present disclosure can be data authorized by the user or sufficiently authorized by all parties.
[0075] In the following, the related concepts involved in the embodiments of the present disclosure are explained to facilitate understanding.
[0076] 1. AI model
[0077] An AI model is a mathematical model (e.g., a neural network model) used to implement various applications of AI using machine learning. AI models can be used in various application scenarios, such as biology, medicine, and transportation. For example, when the target event is to predict the sensitivity of a cell line to a drug, the gene mutation data and gene expression data of the cell line can be input into an AI model to predict the sensitivity of the cell line to the drug.
[0078] An AI model is essentially an algorithm that includes a large number of parameters and calculation formulas (or calculation rules). The large number of parameters included in an AI model are usually floating-point data.
[0079] An AI model can generally be regarded as being composed of multiple blocks. When constructing an AI model, structures such as convolutional neural network (CNN) structures and transformer structures can be used. For example, a transformer structure is usually composed of 12 blocks. The general matrix multiplication (GEMM) operation is the main calculation method used by an AI model to process data.
[0080] Quantization of floating-point data in an AI model refers to converting floating-point data into fixed-point data.
[0081] The quantization effect of an AI model is often influenced by the structure and parameters of the model itself, the data type of the parameters, and the software and hardware characteristics of the co-processor such as the GPU deployed.
[0082] 2. Block
[0083] A block is a unit composed of operators for implementing basic operations such as convolution and pooling operations. Multiple blocks can be combined according to certain calculation logic to form an AI model.
[0084] 3. Operator
[0085] An operator is a mapping from one function space to another function space, used to implement basic operations such as convolution and pooling operations on data. The parameters and calculation formulas included in an AI model are specifically deployed in multiple operators that make up the AI model. That is, an operator is composed of parameters and calculation formulas.
[0086] At present, in order to reduce the burden of specific processing tasks of the microprocessor, a heterogeneous processing unit can be configured for the microprocessor. The heterogeneous processing unit can be a coprocessor. The coprocessor can be a hardware circuit module for processing specific algorithms or logical operations, which can be understood as a special accelerator. Moreover, in order to achieve faster computing speed, the coprocessor can generally process specific algorithms or logical operations based on single instruction multiple data (SIMD) technology.
[0087] When processing different scene requirements, different types of coprocessors can often be selected. For example, a math co-processor can control digital processing, and a graphics processing unit (GPU) can process video rendering, etc. Moreover, in order to improve the performance of the coprocessor in processing business, such as computing speed and accuracy, a business classification model, that is, an AI model with business classification function, can be deployed on the coprocessor. For example, a business classification model for pictures, a business classification model for text and a business classification model for videos, there are generally floating-point parameters in these business classification models, which can cause the running of the business classification model to consume a large amount of time, computing resources and storage resources.
[0088] In general technology, in order to reduce the running consumption of the business classification model, thereby improving the implementation speed of the business application and reducing the running load of the business application, it is proposed that the business classification model can be quantized. However, the quantization processing of the business classification model often depends on the experience of algorithm engineers, and the quantization quality and quantization effect are difficult to guarantee, thereby affecting the running speed and implementation effect of the business application.
[0089] In order to solve the above problems, the embodiment of the present disclosure provides a picture classification model generation method. After the electronic device obtains an initial classification model for determining the classification result of a to-be-classified picture, the electronic device can determine the influence degree level of the classification processing associated with each operator on the classification result of the to-be-classified picture according to the operation order and type of the classification processing associated with each operator in the initial classification model, and further execute a quantization determination operation on each operator in order from low to high according to the influence degree level corresponding to each operator. At least one target operator is obtained, so as to quantize each target operator in the initial classification model to generate a target classification model.
[0090] Since the m operators in the initial classification model have different levels of influence on the classification results of the images to be classified, the impact of each operator on the accuracy of the initial classification model after quantization often varies. Based on this, this disclosure, after first determining the level of influence of the classification processing associated with each operator in the initial classification model on the classification results of the images to be classified, can select as many target operators as possible from the m operators according to the order of their respective levels of influence from low to high. This allows for further quantization of multiple target operators to generate a target classification model. Compared to the common technique of relying on manual selection of parameters based on experience for quantization, this disclosure quantizes the model by judging the influence level one by one using electronic equipment. This not only saves manpower but also ensures that as many operators as possible in the initial classification model are quantized to obtain the target classification model, thereby improving the operating speed of business applications without affecting their implementation effectiveness.
[0091] It should be noted that model quantization typically employs two methods: post-training quantization (PTQ) and quantization-aware training (QAT). PTQ can be implemented automatically through the forward method for various model types, resulting in faster quantization. QAT, on the other hand, requires multiple training iterations, leading to a longer quantization cycle and the possibility of training non-convergence. The image classification model generation method disclosed herein adopts the PTQ method, which is applicable to various model types, meaning it is not sensitive to the application scenario, has good versatility, and avoids the additional computational or memory consumption issues associated with multiple training iterations.
[0092] Figure 1 This is a schematic diagram of an image classification model generation system provided in an embodiment of the present disclosure, such as... Figure 1 As shown, the image classification model generation system may include an electronic device 101 and a terminal 102. The electronic device 101 can establish a connection with the terminal 102 through a wired network or a wireless network.
[0093] In this disclosure, the electronic device 101 is mainly used to store resource files required for quantizing image classification models or information classification models, such as resource files including first sorting rules, second sorting rules, first preset conditions, and second preset conditions, as well as resource files including services for performing quantization judgment operations. When the electronic device 101 receives a model quantization request including an initial classification model sent by the terminal 102, it can quantize the initial classification model to obtain a target classification model and send the target classification model to the terminal 102.
[0094] In an implementable manner, the terminal 102 can be configured to build the initial classification model.
[0095] In some embodiments, the electronic device 101 can further comprise or be connected with a database, and the resource files required for quantifying the model can be stored in the database. When the initial classification model needs to be quantified, the electronic device 101 can call the stored resource files in the database.
[0096] The electronic device 101 can be a server, a terminal, or other electronic device for text processing, and the present disclosure does not limit the specific implementation of the electronic device 101.
[0097] When the electronic device 101 is a server, the electronic device 101 can be a single server, or a server cluster composed of multiple servers. In some embodiments, the server cluster can also be a distributed cluster. The present disclosure does not limit the specific implementation of the server.
[0098] When the electronic device 101 is a terminal, the electronic device 101 and the terminal 102 can be two independent terminals, or can be integrated into the same terminal, and the present disclosure does not limit the specific implementation of the electronic device 101 and the terminal 102.
[0099] It is easy to understand that when the electronic device 101 and the terminal 102 are integrated into the same terminal, the communication mode between the electronic device 101 and the terminal 102 is the communication between the internal modules of the terminal. In this case, the communication process between the electronic device 101 and the terminal 102 is the same as the communication process between the electronic device 101 and the terminal 102 when they are independent of each other.
[0100] For ease of understanding, the present disclosure mainly takes the electronic device 101 and the terminal 102 as independent examples for illustration.
[0101] The terminal 102 described above can be a mobile phone, a tablet computer, a desktop computer, a laptop computer, a handheld computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, a cellular phone, a personal digital assistant (PDA), an augmented reality (AR) \ virtual reality (VR) device, and other devices that can install and use a content community application, and the present disclosure does not limit the specific form of the terminal. It can interact with the user through one or more ways such as a keyboard, a touchpad, a touch screen, a remote control, voice interaction, or a handwriting device.
[0102] Optionally, the aboveFigure 1 In the text processing system shown, the electronic device 101 can be connected with at least one terminal 102. The number and type of the terminal 102 are not limited in the present disclosure.
[0103] In combination Figure 1 As Figure 2 shown, a structural schematic diagram of the terminal 102 provided by the embodiment of the present disclosure is shown. The terminal 102 can be configured with an input module 21, a communication module 22 and a storage module 23. The input module 21 can be a computer peripheral input device such as a mouse and a keyboard, or a touch screen, mainly used for the clicking operation of the staff to implement a specific function (for example, a model file sending function). The communication module 22 can be any kind of transceiver device, used for communication with other devices (for example, the electronic device 101) or a communication network. For example, the communication module 22 can send the model file of the initial classification model to the electronic device 101. The storage module 23 can be a memory device, which can be used to store resource files such as the model file of the initial classification model.
[0104] The picture classification model generation method provided by the embodiment of the present disclosure can be applied to the electronic device 101 in the application scenario shown above. Figure 1
[0105] The picture classification model generation method provided by the embodiment of the present disclosure will be described in detail below in combination with the drawings.
[0106] As Figure 3 shown, when the picture classification model generation method is applied to the electronic device, the picture classification model generation method can include S301-S304.
[0107] S301, the electronic device acquires an initial classification model used to determine the classification result of the picture to be classified.
[0108] The initial classification model includes m operators. Any operator is used to perform classification processing associated with picture classification on the picture to be classified. m is a positive integer.
[0109] In a possible implementation, the picture to be classified can be a picture containing a specific element (for example, a human face, an animal, a plant, or the like) or a picture having a specific feature (for example, a color feature, a contour feature, a style feature, or the like). Correspondingly, the initial classification model can be an AI model for classifying the picture to be classified based on a specific element in the picture to be classified, or an AI model for classifying the picture to be classified based on a specific feature of the picture to be classified. For example, when the specific element contained in the picture to be classified is a lion, the initial classification model can determine that the classification result of the picture to be classified is a lion picture. When the color feature of the picture to be classified is black and white, the initial classification model can determine that the classification result of the picture to be classified is a black-and-white picture.
[0110] In a possible implementation, the classification processing associated with picture classification performed by the operator on the picture to be classified can be a type of processing such as denoising processing, transformation processing, and smoothing processing.
[0111] It should be noted that when the initial classification model classifies the picture to be classified, the initial classification model usually needs to perform multiple types of classification processing associated with picture classification, such as denoising, transformation, and smoothing, feature extraction, and feature selection, to determine the classification result of the picture to be classified.
[0112] It should be understood that when the initial classification model completes the multiple classification processes on the picture to be classified, the initial classification model is implemented by the m operators that constitute the initial classification model, and the entire processing process requires a certain processing time. Further, each of the m operators is composed of a parameter and a calculation formula. Moreover, in order to improve the calculation accuracy of the operator, the parameter that constitutes the operator is generally a floating-point data. However, when an operator with a floating-point data parameter and an operator with a fixed-point data parameter complete the same classification processing once, the operator with the floating-point data parameter needs a time that is obviously greater than the operator with the fixed-point data parameter. Based on this, in order to improve the running speed of the initial classification model, the initial classification model can be quantized, that is, multiple parameters that constitute the m operators in the initial classification model are quantized from floating-point data to fixed-point data.
[0113] In a possible implementation, when the staff deploys the initial classification model for determining the classification result of the picture to be classified on the processor, in order to improve the running speed of the initial classification model and reduce the occupation of the initial classification model on resources such as storage resources and computing resources on the processor, the initial classification model can be quantized by the electronic device in advance.
[0114] Specifically, in combination with Figure 2The worker can perform a file sending operation (e.g., click a send button) directed to the electronic device through an input module of the terminal to send the model file of the initial classification model stored in a storage module of the terminal to the electronic device. In response to the file sending operation, a communication module of the terminal can send the model file of the initial classification model to the electronic device. Accordingly, the electronic device can receive the model file of the initial classification model from the terminal. Then, the electronic device can parse the model file of the initial classification model to obtain the m operators in the initial classification model. Subsequently, the electronic device can quantize the m operators to improve the running speed of the initial classification model.
[0115] In S302, the electronic device determines an influence degree level of the classification processing associated with each operator on the classification result of the picture to be classified according to the operation sequence and type of the classification processing associated with each operator.
[0116] It should be noted that in order to determine the classification result of the picture to be classified, the m operators constituting the initial classification model need to perform multiple types of classification processing. That is, the types of the m operators are relatively diverse. For example, the m operators can include a convolution operator for implementing convolution operation, a normalization operator for implementing normalization operation, and a pooling operator for implementing pooling operation.
[0117] Further, the influence degree of the operation result obtained by different types of operations on the classification result determined by the initial classification model is often different. Therefore, the influence degree of the operation accuracy of different types of operators on the classification result of the picture to be classified is often different. For example, the influence degree of the operation accuracy of the convolution operation on the classification result of the picture to be classified is generally higher than that of the normalization operation. Moreover, the influence degree on the classification result of the picture to be classified when the operation sequence is before or after a specific type of operator is often different. For example, when an operator is before a normalization operator, since the normalization operator will perform normalization operation on the operation result of the operator, the influence degree of the operation accuracy of the operator on the classification result of the picture to be classified when the operator is before the normalization operator is generally lower than that when the operator is after the normalization operator.
[0118] Therefore, in order to improve the running speed of the initial classification model while ensuring the implementation effect of the initial classification model, the electronic device can first determine the influence degree level of the classification processing associated with each of the m operators on the classification result of the picture to be classified, and then preferentially select an operator with a lower influence degree on the classification result of the picture to be classified for quantization, so as to quantize as many operators as possible in the m operators, thereby more effectively improving the running speed of the initial classification model and ensuring the quantization effect of the initial classification model.
[0119] In an implementable manner, after obtaining the m operators in the initial classification model, the electronic device can first determine the operation sequence and type of the classification processing associated with each of the m operators, then determine the influence degree of the classification processing associated with each of the operators on the classification result of the picture to be classified according to the type of the classification processing associated with each of the operators, and sort the operators according to the operation sequence of the classification processing associated with each of the operators to obtain the influence degree level of the classification processing associated with each of the operators on the classification result of the picture to be classified. In this way, the electronic device can preferentially quantize a specific type of operator according to the influence degree level of the classification processing associated with each of the operators on the classification result of the picture to be classified, so as to quantize more operators in the m operators.
[0120] In a possible example, the preset initial classification model includes five operators, namely operator a, operator b, operator c, operator d and operator e. Among them, operator d and operator e are operators of a specific type. Without determining the influence degree level corresponding to the five operators, the electronic device can quantize operator a, operator b, operator c, operator d and operator e in turn. In the process of quantizing the initial classification model by the electronic device, the accuracy of the initial classification model may satisfy the accuracy requirement after operator a and operator b are quantized, and then not satisfy the accuracy requirement after operator c is quantized. In this case, the electronic device can only quantize operator a and operator b in the initial classification model.
[0121] With the determination of the influence degree level corresponding to the five operators, the electronic device can preferentially quantize operator d and operator e. In the process of quantizing the initial classification model by the electronic device, the accuracy of the initial classification model may satisfy the accuracy requirement after operator d, operator e, operator a and operator b are quantized, and then not satisfy the accuracy requirement after operator c is quantized. In this case, the electronic device can complete the quantization of operator d, operator e, operator a and operator b. It can be seen that after determining the influence degree level corresponding to the m operators constituting the initial classification model, the electronic device can quantize as many operators as possible in the m operators.
[0122] S303, the electronic device performs quantization determination operation on each operator in order of influence degree level of each operator from low to high, and obtains at least one target operator.
[0123] In a possible manner, the quantization determination operation can be used to determine an operator whose quantized classification model satisfies a first preset condition as the target operator. The target operator can be an operator whose quantized classification model can reduce the operation time consumption of the initial classification model and has a lower influence degree on the operation accuracy of the initial classification model.
[0124] In a possible manner, the first preset condition can include that the relative difference between the classification result of the to-be-classified picture determined by the quantized classification model and the classification result of the to-be-classified picture determined by the initial classification model is less than a preset threshold, and the operation time consumption of the classification result determined by the quantized classification model is less than the operation time consumption of the classification result determined by the initial classification model. The preset threshold can be set in the electronic device by a worker in advance.
[0125] In an implementable manner, after the influence degree levels of the m operators are determined, the electronic device can perform quantization determination operation on each operator in order of influence degree level of each operator from low to high, that is, preferentially performing quantization determination operation on an operator whose influence degree on the classification result of the to-be-classified picture is lower. Specifically, after an operator is selected according to the influence degree level of each operator, the electronic device can quantize the selected operator. Then, the electronic device can replace the unquantized selected operator in the initial classification model with the quantized selected operator to obtain the initial classification model after the selected operator is updated, that is, the quantized classification model. Then, the electronic device can determine the classification result of the to-be-classified picture based on the quantized classification model, and test the operation time consumption of the classification result determined by the quantized classification model to determine whether the quantized classification model satisfies the first preset condition.
[0126] If the relative gap between the classification result of the to-be-classified picture determined by the quantized classification model and the classification result of the to-be-classified picture determined by the initial classification model is less than the preset threshold, and the running time of the quantized classification model in determining the classification result is less than the running time of the initial classification model in determining the classification result, the selected operator is determined as the target operator. Then, the electronic device can select the next operator in the influence degree level corresponding to each operator on the basis of the initial classification model after updating the selected operator, and then perform the quantization determination operation on the selected next operator. If not, the electronic device determines that the selected operator is not the target operator. Then, the electronic device can select the next operator in the influence degree level corresponding to each operator on the basis of the initial classification model without updating the selected operator, and then perform the quantization determination operation on the selected next operator. In this way, after the electronic device performs the quantization determination operation on the m operators according to the influence degree level corresponding to each of the m operators, at least one target operator can be obtained.
[0127] In S304, the electronic device quantizes the at least one target operator in the initial classification model to generate a target classification model for determining the classification result of the to-be-classified picture.
[0128] In one possible manner, the running time of the target classification model is less than the running time of the initial classification model, and the relative gap between the result output by the target classification model and the result output by the initial classification model is less than or equal to the preset threshold.
[0129] In one possible manner, since the target operator is quantized, the running time of the initial classification model can be reduced without affecting the implementation effect of the initial classification model. Therefore, after obtaining the at least one target operator, the electronic device can quantize the at least one target operator in the initial classification model to generate a target classification model.
[0130] In one possible example, in combination with the example in S302, on the premise of the same accuracy condition, the preset electronic device can obtain model A by sequentially quantizing the operator a and the operator b in the initial classification model when the influence degree level corresponding to each operator is not determined. When the influence degree level corresponding to each operator is determined, the electronic device can first perform the quantization determination operation on each operator according to the influence degree level corresponding to each operator, and obtain the target operators of the operator d, the operator e, the operator a, and the operator b. Then, the electronic device can quantize the operator d, the operator e, the operator a, and the operator b in the initial classification model to obtain model B (i.e., the target classification model).
[0131] When GPU 1 needs to determine the classification result of picture 1 to be classified, in the case that model A is deployed on GPU 1, since 3 of the 5 operators constituting model A are not quantized, that is, 2 of the 5 operators are fixed-point data-based operators and 3 are floating-point data-based operators. Therefore, when GPU 1 calls model A to determine the classification result of picture 1 to be classified, it needs to run 2 fixed-point data-based operators and 3 floating-point data-based operators.
[0132] In the case that model B (i.e., the target classification model) is deployed on GPU 1, since only 1 of the 5 operators constituting model B is not quantized, that is, 4 of the 5 operators are fixed-point data-based operators and 1 is a floating-point data-based operator. Therefore, when GPU 1 calls model B to determine the classification result of picture 1 to be classified, it needs to run 4 fixed-point data-based operators and 1 floating-point data-based operator.
[0133] It can be seen that, compared with calling model A to determine the classification result of picture 1 to be classified, which needs to run 3 floating-point data-based operators, calling model B (i.e., the target classification model) to determine the classification result of picture 1 to be classified only needs to run 1 floating-point data-based operator. It should be understood that, compared with floating-point data-based operators, fixed-point data-based operators require significantly less runtime. Therefore, the target classification model can process picture 1 faster while ensuring accuracy.
[0134] The technical solutions provided by the above embodiments at least bring the following beneficial effects: As can be seen from S301-S304, after the electronic device obtains the initial classification model for determining the classification result of the picture to be classified, it can determine the influence degree level of the classification processing associated with each operator in the initial classification model on the classification result of the picture to be classified according to the operation sequence and type of the classification processing associated with each operator, and further perform quantization determination operations on each operator in order from low to high according to the influence degree level corresponding to each operator to obtain at least one target operator, thereby quantizing each target operator in the initial classification model to generate a target classification model.
[0135] Since the m operators in the initial classification model have different levels of influence on the classification results of the images to be classified, the impact of each operator on the accuracy of the initial classification model after quantization often varies. Based on this, this disclosure, after first determining the level of influence of the classification processing associated with each operator in the initial classification model on the classification results of the images to be classified, can select as many target operators as possible from the m operators according to the order of their respective levels of influence from low to high. This allows for further quantization of multiple target operators to generate a target classification model. Compared to the common technique of relying on manual selection of parameters based on experience for quantization, this disclosure quantizes the model by judging the influence level one by one using electronic equipment. This not only saves manpower but also ensures that as many operators as possible in the initial classification model are quantized to obtain the target classification model, thereby improving the operating speed of business applications without affecting their implementation effectiveness.
[0136] In one embodiment, combined with Figure 3 In S302 above, when the electronic device determines the degree of influence of each operator's associated classification processing on the classification result of the image to be classified based on the operation order and type of each operator's associated classification processing, such as... Figure 4 As shown, this disclosure provides an optional implementation method, specifically including: S401-S405.
[0137] S401. The electronic device determines the order of operations for classifying and processing the n structural blocks.
[0138] In one possible approach, the m operators that make up the initial classification model are generally distributed across various structural blocks. That is, the initial classification model typically includes n structural blocks, and each structural block includes at least one of the m operators. n is a positive integer less than m. It should be understood that an operator resides in only one structural block.
[0139] In one possible approach, any structural block can be used to perform classification processing (e.g., segmentation and fusion) associated with the image classification of the image to be classified. It should be understood that the classification processing performed by the structural block on the image to be classified is based on at least one included operator.
[0140] In one possible approach, after parsing the model file of the initial classification model to obtain n structural blocks, the electronic device can sequentially number the n structural blocks from the starting structural block to the ending structural block according to the calculation logic of the n structural blocks, so as to determine the operation order of the classification processing associated with the n structural blocks.
[0141] S402. The electronic device determines the degree of influence of the classification processing associated with n structural blocks on the classification result of the image to be classified according to the first preset rule.
[0142] The first preset rule comprises: when the first structure block and the second structure block in the n structure blocks are both preset type structure blocks, and the operation order of the first structure block is before the operation order of the second structure block, or when the first structure block is a preset type structure block and the second structure block is not a preset type structure block, or when the first structure block and the second structure block are both not preset type structure blocks and the operation order of the first structure block is before the operation order of the second structure block, the influence degree level of the first structure block is determined to be lower than that of the second structure block. The preset type structure block is a structure block comprising a preset type operator. The preset type operator is an operator with a normalization function. The first structure block is any one of the n structure blocks. The second structure block is any one of the n structure blocks except the first structure block.
[0143] In a possible manner, for a preset type structure block comprising a preset type operator, the operation start operator and the operation end operator in the preset type structure block can be preset type operators.
[0144] It should be noted that when the preset type operator is included, the result obtained by the preset type structure block processing data often does not require high precision. That is, after the floating point type data in the preset type structure block is converted into fixed point type data, the initial classification model is less affected by the precision.
[0145] In a possible example, the preset initial classification model comprises six structure blocks, namely, a structure block 1 with a sequence number 1, a structure block 2 with a sequence number 2, a structure block 3 with a sequence number 3, a structure block 4 with a sequence number 4, a structure block 5 with a sequence number 5, and a structure block 6 with a sequence number 6. And the structure block 3 and the structure block 5 are preset type structure blocks.
[0146] According to the first preset rule, since the structure block 3 and the structure block 5 are preset type structure blocks, and the operation order of the structure block 3 is before the operation order of the structure block 5, the electronic device can determine that the influence degree level of the structure block 3 is lower than that of the structure block 5.
[0147] Since the structure block 5 is a preset type structure block and the structure block 1 is not a preset type structure block, the electronic device can determine that the influence degree level of the structure block 5 is lower than that of the structure block 1.
[0148] Since the structure block 1 and the structure block 2 are both not preset type structure blocks, and the operation order of the structure block 1 is before the operation order of the structure block 2, the electronic device can determine that the influence degree level of the structure block 1 is lower than that of the structure block 2.
[0149] Similarly, the electronic device can determine that the influence degree level of the structure block 3 is the first level, the influence degree level of the structure block 5 is the second level, the influence degree level of the structure block 1 is the third level, the influence degree level of the structure block 2 is the fourth level, the influence degree level of the structure block 4 is the fifth level, and the influence degree level of the structure block 6 is the sixth level.
[0150] In S403, the electronic device determines an operation sequence of the classification processing associated with the at least one operator in each structure block.
[0151] Specifically, after the electronic device parses the model file of the initial classification model to obtain the n structure blocks, the electronic device can further determine at least one operator included in each structure block, and arrange the sequence number of the at least one operator in each structure block in order according to the calculation logic of each structure block, from the operation starting operator to the operation ending operator, to determine the operation sequence of the classification processing associated with the at least one operator in each structure block.
[0152] In S404, the electronic device determines an influence degree level of the classification processing associated with the at least one operator in each structure block on the classification result of the picture to be classified according to a second preset rule.
[0153] The second preset rule includes: when the next operator of the first operator and the next operator of the second operator in the structure block are both preset type operators, and the operation sequence of the first operator is before the operation sequence of the second operator, or when the next operator of the first operator is a preset type operator and the next operator of the second operator is not a preset type operator, or when the next operator of the first operator and the next operator of the second operator are both not preset type operators and the operation sequence of the first operator is before the operation sequence of the second operator, it is determined that the influence degree level of the first operator is lower than that of the second operator. The first operator is any one operator in the structure block. The second operator is any one operator in the structure block except the first operator.
[0154] It should be noted that when the next operator of an operator is a preset type operator, the next operator will perform normalization processing on the result output by the operator. Therefore, the electronic device can determine that the result output by the operator does not need to have high precision, that is, after converting the floating-point data in the operator to fixed-point data, the preset type structure block is less affected by the precision. In this way, the initial classification model is less affected by the precision.
[0155] In a possible example, in combination with the example of S402, the preset structure block 3 includes 6 operators, which are operator 1 with sequence number 1, operator 2 with sequence number 2, operator 3 with sequence number 3, operator 4 with sequence number 4, operator 5 with sequence number 5, and operator 6 with sequence number 6. Moreover, operator 2 and operator 6 are preset type operators.
[0156] According to the second preset rule, since the next operator of the operator 1 is the operator 2 and the next operator of the operator 5 is the operator 6, which are preset type operators, and the operation order of the operator 1 is before that of the operator 5, the electronic device can determine that the influence degree level of the operator 1 is lower than that of the operator 5.
[0157] Since the next operator of the operator 5 is the operator 6, which is a preset type operator, and the next operator of the operator 2 is the operator 3, which is not a preset type operator, the electronic device can determine that the influence degree level of the operator 5 is lower than that of the operator 2.
[0158] Since the next operator of the operator 2 is the operator 3 and the next operator of the operator 3 is the operator 4, which are not preset type operators, and the operation order of the operator 2 is before that of the operator 3, the electronic device can determine that the influence degree level of the operator 2 is lower than that of the operator 3.
[0159] By analogy, the electronic device can determine that the influence degree level of the operator 1 is the first level, the influence degree level of the operator 5 is the second level, the influence degree level of the operator 2 is the third level, the influence degree level of the operator 3 is the fourth level, the influence degree level of the operator 4 is the fifth level, and the influence degree level of the operator 6 is the sixth level.
[0160] S405, the electronic device determines the influence degree level corresponding to each operator according to the influence degree levels corresponding to the n structure blocks and the influence degree levels corresponding to at least one operator in each structure block.
[0161] Specifically, after determining the influence degree levels corresponding to the n structure blocks and the influence degree levels corresponding to at least one operator in each structure block, the electronic device can sort the n structure blocks according to the influence degree levels of each structure block, and sort at least one operator in each structure block according to the influence degree levels of at least one operator in each structure block, to determine the influence degree levels corresponding to each operator.
[0162] In a possible example, in combination with the examples of S402 and S404 described above, the electronic device can first sort the six structure blocks in the initial classification model into structure block 3, structure block 5, structure block 1, structure block 2, structure block 4, and structure block 6 according to the influence degree levels corresponding to the six structure blocks. Then, the electronic device can sort the six operators in the structure block 3 into operator 1, operator 5, operator 2, operator 3, operator 4, and operator 6 according to the influence degree levels corresponding to the six operators in the structure block 3. By analogy, after sorting the operators in the structure block 5, structure block 1, structure block 2, structure block 4, and structure block 6, the electronic device can obtain the influence degree levels corresponding to each operator.
[0163] The technical solutions provided by the above embodiments at least have the following beneficial effects: As can be seen from S401-S405, a specific implementation manner that an electronic device determines an influence degree level of classification processing associated with each operator on a classification result of a picture to be classified according to an operation sequence and a type of classification processing associated with each operator is given. After the electronic device determines the operation sequence of the classification processing associated with the n structural blocks, the electronic device determines the influence degree level of the classification processing associated with the n structural blocks on the classification result of the picture to be classified according to a first preset rule, and after the electronic device determines the operation sequence of the classification processing associated with at least one operator in each structural block, the electronic device determines the influence degree level of the classification processing associated with at least one operator in each structural block on the classification result of the picture to be classified according to a second preset rule, so as to determine the influence degree level corresponding to each operator according to the influence degree level corresponding to the n structural blocks and the influence degree level corresponding to at least one operator in each structural block. Subsequently, the electronic device can determine a target operator according to the influence degree level corresponding to the m operators, thereby improving the probability of determining the target operator with the maximum number and having higher guarantee than artificial experience.
[0164] In an embodiment, in combination with Figure 3 In S303, the electronic device sequentially performs quantization determination operations on each operator according to the influence degree level corresponding to each operator from low to high, and when at least one target operator is obtained, the electronic device replaces the unquantized operator in the initial classification model with the quantized operator to obtain a current classification model. Figure 5 As shown in the above S303, the electronic device sequentially performs quantization determination operations on each operator according to the influence degree level corresponding to each operator from low to high, and when at least one target operator is obtained, the electronic device replaces the unquantized operator in the initial classification model with the quantized operator to obtain a current classification model.
[0165] S501, the electronic device quantizes each operator in a current operator set to obtain a current classification model.
[0166] The current operator set includes a target operator in the first i operators and the first i-1 operators in the order of the influence degree level corresponding to each operator from low to high. i is a positive integer less than or equal to m. The current classification model is a model obtained after quantization of the i th operator.
[0167] In a possible example, in combination with the example in S302, the influence degree level corresponding to the 5 operators in the preset initial classification model is operator d, operator e, operator a, operator b, and operator c. When the electronic device starts to perform quantization determination operations on the 5 operators based on the influence degree level corresponding to the 5 operators, that is, i is equal to 1, the current operator set includes the first operator (that is, operator d) in the order of the influence degree level corresponding to the 5 operators from low to high, and there is no target operator at this time. In this case, after the electronic device quantizes the first operator (that is, operator d), the electronic device can replace the unquantized operator d in the initial classification model with the quantized operator d to obtain a current classification model, that is, a model obtained after quantization of the operator d.
[0168] Then, if the decision operator d is the target operator, when i is equal to 2, the current operator set includes the second operator (i.e., operator e) and the operator d in the order of the influence degree levels of the five operators from low to high. In this case, the electronic device can replace the unquantized operator d in the initial classification model with the quantized operator d and replace the unquantized operator e in the initial classification model with the quantized operator e to obtain the current classification model, i.e., the model obtained after quantization of the operator e.
[0169] S502, the electronic device determines the i th operator as the target operator when the current classification model meets the first preset condition, and updates the value of i.
[0170] In one possible implementation, the first preset condition can further include that a relative gap between the classification result of the to-be-classified picture determined by the current classification model and the classification result of the to-be-classified picture determined by the initial classification model is less than or equal to a preset threshold, and the running time consumption of the classification result determined by the current classification model is less than a current time threshold. The current time threshold is the running time consumption of the classification result determined by the classification model obtained after quantization of each target operator in the current operator set.
[0171] In one implementation, when the current classification model meets the first preset condition, it can be indicated that the operation accuracy of the current classification model meets the requirement. Moreover, since the current time threshold is the running time consumption of the model obtained after quantization of the target operator in the current operator set, i.e., the running time consumption of the previous current classification model of the current classification model, if the running time consumption of the current classification model is less than the current time threshold, it can be indicated that the running time consumption of the current classification model is lower than the running time consumption of the previously determined current classification model, i.e., it can be indicated that the running time consumption of the current classification model is the shortest, and the operation speed can be improved and the operation accuracy can be ensured after quantization of the i th operator. In this case, the electronic device can determine the i th operator as the target operator and update the value of i, i.e., increment the value of i by 1, to then determine the next operator in the influence degree level of each operator.
[0172] S503, the electronic device updates the value of i when the current classification model does not meet the first preset condition.
[0173] In one implementation, when the current classification model does not meet the first preset condition, it can be indicated that the operation speed of the initial classification model cannot be improved after quantization of the i th operator. Alternatively, the operation speed of the initial classification model can be improved after quantization of the i th operator, but the operation accuracy cannot be ensured. In these cases, the i th operator cannot be determined as the target operator. Therefore, the electronic device can directly update the value of i, i.e., increment the value of i by 1.
[0174] S504, the electronic device repeats quantization on each operator in the current operator set until i is greater than m, to obtain at least one target operator.
[0175] In an implementable manner, after updating the value of i, i.e., incrementing the value of i by 1, the electronic device can first update the current operator set according to the value of i after incrementing, i.e., i+1, and then quantize each operator in the updated current operator set to obtain an updated current classification model, and determine whether the updated current classification model meets the first preset condition. In this way, until i is greater than m, the electronic device can obtain at least one target operator.
[0176] In a possible example, in combination with the example in S501, the influence degree levels corresponding to the 5 operators in the preset initial classification model are operator d, operator e, operator a, operator b, and operator c. When the electronic device starts to perform the quantization determination operation on the 5 operators based on the influence degree levels corresponding to the 5 operators, i.e., when i is equal to 1, the current operator set includes the first operator (i.e., operator d) in the order from low to high of the influence degree levels corresponding to the 5 operators, and at this time, there is no target operator.
[0177] Then, if the current classification model obtained by quantizing each operator in the current operator set meets the first preset condition, the electronic device can determine operator d as a target operator, and increment the value of i by 1. At this time, i is equal to 2, and the current operator set is: operator d and the second operator (i.e., operator e).
[0178] Then, if the current classification model obtained by quantizing each operator in the current operator set meets the first preset condition, the electronic device can determine operator d and operator e as target operators, and increment the value of i by 1. At this time, i is equal to 3, and the current operator set is: operator d, operator e, and the third operator (i.e., operator a).
[0179] Then, if the current classification model obtained by quantizing each operator in the current operator set does not meet the first preset condition, the electronic device can determine operator d and operator e as target operators, and increment the value of i by 1. At this time, i is equal to 4, and the current operator set is: operator d, operator e, and the fourth operator (i.e., operator b).
[0180] Then, if the current classification model obtained by quantizing each operator in the current operator set meets the first preset condition, the electronic device can determine operator d, operator e, and operator b as target operators, and increment the value of i by 1. At this time, i is equal to 5, and the current operator set is: operator d, operator e, operator b, and the fifth operator (i.e., operator c).
[0181] Then, if the current classification model obtained by quantizing each operator in the current operator set does not satisfy the first preset condition, the electronic device can determine the operator d, the operator e and the operator b as the target operators, and increment the value of i by 1. At this time, since i is equal to 6, the condition that i is greater than m is met, and the electronic device ends the execution of the quantization determination operation.
[0182] In this way, the electronic device can obtain the target operators including the operator d, the operator e and the operator b.
[0183] The above embodiment provides a technical solution which at least brings the following beneficial effects: as can be seen from S501-S504, a specific implementation manner is given in which the electronic device sequentially executes the quantization determination operation on each operator according to the order from low to high of the influence degree level corresponding to each operator, and obtains at least one target operator. After the electronic device quantizes each operator in the current operator set to obtain the current classification model, the electronic device can determine whether the current classification model meets the first preset condition. If yes, the electronic device can determine the i th operator as the target operator meeting the quantization condition, and increment the value of i by 1. If no, the electronic device directly increments the value of i by 1. Then, the electronic device can repeatedly quantize each operator in the current operator set until i is greater than m, and at least one target operator is obtained.
[0184] In an embodiment, when the electronic device quantizes each operator in the current operator set to obtain the current classification model, as shown in FIG. 6, the present disclosure provides an alternative implementation manner, which specifically includes S601-S603. Figure 6
[0185] S601, the electronic device quantizes each target operator in the current operator set according to the target quantization algorithm corresponding to each target operator to obtain a first model.
[0186] It should be noted that when the target operator is included in the current operator set, it indicates that the electronic device has quantized the target operator before and has determined the target quantization manner corresponding to the target operator. In this case, the electronic device can quantize each target operator in the current operator set according to the target quantization algorithm corresponding to each target operator to obtain the first model. For specific description of this case, reference can be made to the specific implementation manner of S602-S603 below, which will not be described here.
[0187] When the target operator is not included in the current operator set, it indicates that the current operator set is the first operator set, or the previous current operator set before the update of the current operator set does not meet the first preset condition. In this case, the electronic device can determine that there is no first model.
[0188] S602, the electronic device quantizes the i-th operator according to a plurality of preset quantization algorithms based on the first model to obtain a plurality of second models corresponding to the plurality of preset quantization algorithms one by one.
[0189] It should be noted that when quantizing an operator for processing at least two variables, a scaling factor can generally be determined first to convert the floating-point data in the operator to fixed-point data. Since the scaling factor needs to be determined, the value range of the floating-point data and the value range of the fixed-point data need to be known. Therefore, in order to determine the scaling factor, the minimum value (min) and the maximum value (max) of the floating-point data in the operator need to be determined first to obtain the value range of the floating-point data. The value range of the fixed-point data can be set according to the type of the quantized data. It should be understood that the specific determination formula of the scaling factor can be understood by referring to the prior art, and will not be described here.
[0190] In one possible manner, the fixed-point data can be set to int16 type, and the value range of the fixed-point data can be (-32768, +32767). Moreover, after setting the fixed-point data to int16 type to obtain the target classification model, if it is required to obtain the target classification model with the fixed-point data as Int8 type, the scaling factor obtained when the fixed-point data is set to int16 type can be changed to directly obtain the target classification model with the fixed-point data as Int8 type. At the same time, the model error between the target classification model based on the fixed-point data as int16 type and the initial classification model based on the floating-point data as fp16 type is less than 1 / 2 15 , and the theoretical accuracy of the two is in the same order of magnitude. The model error between the target classification model based on the fixed-point data as int16 type and the initial classification model based on the floating-point data as fp32 type is also between 10e-2 and 10e-3.
[0191] Moreover, when determining the minimum value and the maximum value of the floating-point data in the operator, there are usually a plurality of calibration algorithms. For example, entropy, mean-square error (MSE) method, percentile method, and the like. Moreover, after obtaining the scaling factor according to the value range of the floating-point data and the value range of the fixed-point data, there are also a plurality of counting reservation methods. For example, rounding method, ceil, and the like. At the same time, each calibration algorithm can also adjust the size of the parameter for calibration when determining the minimum value and the maximum value of the floating-point data in the operator. For example, the percentile method can adjust the percentage parameter to any value from 0% to 100%.
[0192] When quantizing an operator for processing a variable and a weight, per channel quantization and per tensor quantization can be selected.
[0193] Based on this, when quantizing the operator, in order to reduce the error as much as possible and obtain the highest possible accuracy, the electronic device is pre-configured with a plurality of preset quantization algorithms. The plurality of preset quantization algorithms can include a plurality of quantization algorithms based on the percentile method and the rounding method based on a plurality of percentage parameters, and can also include a plurality of quantization algorithms based on the percentile method and the rounding method based on a plurality of percentage parameters, or any one of the above quantization algorithms can quantize the operator. Here, it is not listed one by one.
[0194] Specifically, after performing S601, if there is no first model, the electronic device can determine that the current operator set only includes the i-th operator. In this case, the electronic device can quantize the i-th operator according to the plurality of preset quantization algorithms to obtain a plurality of second models corresponding one-to-one to the plurality of preset quantization algorithms.
[0195] If there is a first model, the electronic device can determine that the current operator set includes at least one target operator in addition to the i-th operator. In this case, the electronic device can quantize the i-th operator once according to each preset quantization algorithm to obtain a plurality of quantized i-th operators corresponding one-to-one to the plurality of preset quantization algorithms. Then, the electronic device can combine each quantized i-th operator and the first model once to obtain a plurality of second models corresponding one-to-one to the plurality of preset quantization algorithms.
[0196] In one possible example, in combination with the example in S302 described above, when the current operator set includes the first operator (i.e., operator d) in the order of the influence degree level corresponding to each operator from low to high, and there is no target operator, the electronic device can perform S601 to determine that there is no first model, and quantize the operator d according to the plurality of preset quantization algorithms to obtain a plurality of second models corresponding one-to-one to the plurality of preset quantization algorithms.
[0197] Further, the electronic device can determine the second model in the plurality of second models that meets the second preset condition as the current classification model, and determine the quantization algorithm corresponding to the second model that meets the second preset condition as the target quantization algorithm corresponding to the operator d. Specifically, the process can refer to the description of S603 and S701 described below.
[0198] When the current set of operators is updated to: the operator d and the second operator (i.e., the operator e), the electronic device can quantize the operator d according to the target quantization algorithm corresponding to the target operator (i.e., the operator d) in the current set of operators to obtain a first model. Then, the electronic device quantizes the i-th operator (i.e., the operator e) in the current set of operators according to the plurality of preset quantization algorithms based on the first model to obtain a plurality of second models corresponding to the plurality of preset quantization algorithms one by one. Until a plurality of target operators including the operator d, the operator e, and the operator b are obtained.
[0199] In S603, the electronic device determines, as the current classification model, a second model that meets a second preset condition from the plurality of second models.
[0200] The second preset condition includes that a relative gap between the classification result of the to-be-classified picture determined by the second model and the classification result of the to-be-classified picture determined by the initial classification model is less than or equal to a preset threshold, and a running time of the classification result determined by the second model is less than or equal to a preset time threshold.
[0201] In an implementable manner, the electronic device can determine, as the preset second model, a second model that meets the second preset condition from the plurality of second models, that is, a second model that meets the condition that a relative gap between the classification result of the to-be-classified picture determined by the second model and the classification result of the to-be-classified picture determined by the initial classification model is less than or equal to a preset threshold, and a running time of the classification result determined by the second model is the shortest, and determine a running time of the classification result determined by the preset second model as the preset time threshold.
[0202] Based on this, after obtaining the plurality of second models, the electronic device can determine, as the current classification model, a second model that meets the second preset condition from the plurality of second models, that is, a second model that meets the condition that a relative gap between the classification result of the to-be-classified picture determined by the second model and the classification result of the to-be-classified picture determined by the initial classification model is less than or equal to a preset threshold, and a running time of the classification result determined by the second model is less than or equal to a preset time threshold. That is, the current classification model is a second model that meets the accuracy requirement and has the fastest model running speed from the plurality of second models.
[0203] The technical solutions provided by the above embodiments at least have the following beneficial effects: As can be seen from S601-S603, a specific implementation manner of the electronic device quantizing each operator in the current operator set to obtain the current classification model is given. The electronic device can quantize each operator by using multiple preset quantization algorithms in a manner of taking each operator as a single variable to obtain multiple second models on the basis of the first model, so as to determine the current classification model that meets the second preset condition in the multiple second models, that is, determine the second model with the best quantization effect as the current classification model. Therefore, the electronic device can evaluate different quantization effects of multiple preset quantization algorithms on one operator on the basis of the target operator of the target quantization algorithm that has been determined, so as to identify the preset quantization algorithm that is most suitable for the one operator, and realize the differential evaluation of the superiority of the multiple preset quantization algorithms.
[0204] In an example that can be implemented, in combination with Figure 6 As Figure 7 indicated, the picture classification model generation method provided by the present disclosure further includes S701.
[0205] In S701, the electronic device determines the preset quantization algorithm corresponding to the second model that meets the second preset condition as the target quantization algorithm corresponding to the i th operator.
[0206] Specifically, after the current classification model is determined in the multiple second models, the electronic device can determine the preset quantization algorithm corresponding to the second model that meets the second preset condition as the target quantization algorithm corresponding to the i th operator. In this way, when the current classification model meets the first preset condition, the electronic device can determine the i th operator in the current operator set as the target operator, and determine the target quantization algorithm corresponding to the i th operator as the target quantization algorithm corresponding to the target operator.
[0207] Subsequently, when the target operator (that is, the i th operator) needs to be quantized, the electronic device can conveniently quantize the target operator according to the target quantization algorithm corresponding to the target operator, thereby accelerating the quantization speed of the initial classification model.
[0208] In a possible example, in combination with the example in S302 described above, when the current operator set includes the first operator (that is, the operator d) in the order of the influence degree level of each operator from low to high, and there is no target operator, if the current classification model obtained after each operator in the current operator set is quantized meets the first preset condition, the electronic device can determine the i th operator (that is, the operator d) in the current operator set as the target operator, and determine the quantization algorithm corresponding to the current classification model as the target quantization algorithm corresponding to the operator d.
[0209] When the current operator set is updated to: the operator d and the second operator (i.e., the operator e), if the current classification model obtained after each operator in the current operator set is quantized satisfies the first preset condition, the electronic device can determine the i th operator (i.e., the operator e) in the current operator set as the target operator, and determine the quantization algorithm corresponding to the current classification model as the target quantization algorithm corresponding to the operator e. Until the target operator including the operator d, the operator e and the operator b, and the target quantization algorithm corresponding to the operator d, the target quantization algorithm corresponding to the operator e and the target quantization algorithm corresponding to the operator b are obtained.
[0210] The technical solutions provided by the above embodiments at least have the following beneficial effects: as can be known from S701, after the electronic device determines the target quantization algorithm most suitable for the i th operator in the current operator set from the plurality of preset quantization algorithms on the basis of the target operator whose target quantization algorithm has been determined, the electronic device can establish the correspondence between the i th operator in the current operator set and the target quantization algorithm. In this way, after the i th operator in the current operator set is determined as the target operator, the electronic device can conveniently quantize the i th operator in the current operator set.
[0211] In an example that can be implemented, in combination with Figure 3 In the above S304, when the electronic device quantizes at least one target operator in the initial classification model to generate a target classification model for determining the classification result of the picture to be classified, as Figure 8 As shown in the above S304, the present disclosure provides an alternative implementation, specifically including: S801.
[0212] S801, the electronic device quantizes each target operator according to the target quantization algorithm corresponding to each target operator to generate a target classification model.
[0213] Specifically, when the plurality of target operators are obtained, the electronic device also obtains the target quantization algorithm corresponding to each target operator. Therefore, the electronic device can quantize each target operator according to the target quantization algorithm corresponding to each target operator to obtain a target classification model.
[0214] In a possible example, in combination with the example in S701, the plurality of target operators include the operator d, the operator e and the operator b. The electronic device can quantize the operator d according to the target quantization algorithm corresponding to the operator d, then quantize the operator e according to the target quantization algorithm corresponding to the operator e, and then quantize the operator b according to the target quantization algorithm corresponding to the operator b. In this way, the electronic device can complete the quantization of the initial classification model to obtain a target classification model.
[0215] The technical solutions provided by the above embodiments at least have the following beneficial effects: As can be known from S801, a specific implementation manner is given, in which the electronic device quantizes each target operator in the initial classification model to obtain a target classification model. After obtaining the plurality of target operators, since each target operator corresponds to a target quantization algorithm, the electronic device does not need to distinguish the plurality of preset quantization algorithms, and can quantize each target operator in the target operator by using the target quantization algorithm corresponding to the target operator to obtain the target classification model.
[0216] In an embodiment, when the electronic device determines the second model that meets the second preset condition from the plurality of second models as the current classification model, as shown in S1001, the present disclosure provides an optional implementation manner, which includes S901-S902. Figure 9
[0217] S901, the electronic device classifies the picture to be classified based on the second model to obtain running information of the second model.
[0218] The running information includes a classification result of the picture to be classified determined by the second model and a running time consumption of the classification result determined by the second model.
[0219] Specifically, after obtaining the second model, the electronic device can classify the picture to be classified based on the second model and monitor the running process of the second model. In this way, the electronic device can obtain the classification result of the picture to be classified determined by the second model. Meanwhile, the electronic device can monitor the time information of the start and stop of the running of the second model to determine the running time consumption of the classification result determined by the second model.
[0220] S902, when the relative gap between the classification result of the picture to be classified determined by the second model and the classification result of the picture to be classified determined by the initial classification model is less than or equal to a preset threshold, and the running time consumption of the classification result determined by the second model is less than or equal to a preset time threshold, the electronic device determines the second model as the current classification model.
[0221] It should be noted that since a large number of parameters in the initial classification model are floating-point data, the classification result obtained by the initial classification model when classifying the picture to be classified has good accuracy. Based on this, in order to accurately determine the error of the second model, the electronic device can determine the relative gap between the classification result of the picture to be classified determined by the second model and the classification result of the picture to be classified determined by the initial classification model as the model error of the second model.
[0222] In a possible manner, the electronic device can determine, by a first formula, a relative difference between the classification result of the to-be-classified picture determined by the second model and the classification result of the to-be-classified picture determined by the initial classification model. The first formula is:
[0223] R = ∑abs(r-Q) / ∑(r).
[0224] wherein R is the relative difference between the classification result of the to-be-classified picture determined by the second model and the classification result of the to-be-classified picture determined by the initial classification model. r is the classification result of the to-be-classified picture determined by the second model. Q is the classification result of the to-be-classified picture determined by the initial classification model. ∑abs is used to represent the absolute value of the value in the parentheses. ∑ is used to sum all values in the parentheses.
[0225] The above embodiments provide technical solutions at least with the following beneficial effects: As can be seen from S901-S902, a specific implementation manner is given in which the electronic device determines the second model that meets the second preset condition from the plurality of second models as the current classification model. The electronic device can classify the to-be-classified picture based on the second model, obtain the running information of the second model, and determine the second model as the current classification model when the relative difference between the classification result of the to-be-classified picture determined by the second model and the classification result of the to-be-classified picture determined by the initial classification model is less than or equal to a preset threshold, and the running time of the classification result determined by the second model is less than or equal to a preset time threshold. In this way, the electronic device can more accurately determine the quantization effect of the second model and better evaluate the performance of the second model when actually deployed on a co-processor such as a GPU.
[0226] In an implementable example, as shown in FIG. 8, a flowchart of a picture classification model generation method provided by the present disclosure is shown. After obtaining the model file of the initial classification model, the electronic device can parse the model file to determine the model graph used to represent the overall structure of the initial classification model. Then, the electronic device can determine the type of the model graph (such as the types of CNN structure and transformer structure) to determine the calculation logic of the initial classification model. Figure 10
[0227] Then, the electronic device can determine the influence degree level corresponding to the n structural blocks constituting the initial classification model according to the calculation logic of the initial classification model and the first preset rule, and determine the influence degree level corresponding to at least one operator in each structural block according to the calculation logic of each structural block and the second preset rule. Further, the electronic device can obtain the influence degree level corresponding to the m operators constituting the initial classification model.
[0228] Then, the electronic device can perform a quantization determination operation on the m operators according to the influence degree levels corresponding to the m operators. If there is no target operator in the current operator set, the electronic device can quantize each operator in the current operator set according to a plurality of preset quantization algorithms to obtain a plurality of second models. Further, the electronic device can determine the second model satisfying a second preset condition as the current classification model. If there is a target operator in the current operator set, the electronic device can quantize each target operator in the current operator set according to a target quantization algorithm corresponding to each target operator to obtain a first model. Then, the electronic device can quantize the i th operator in the current operator set according to a plurality of preset quantization algorithms based on the first model, and can obtain a plurality of second models corresponding one-to-one to the plurality of preset quantization algorithms. Further, the electronic device can determine the second model satisfying a second preset condition as the current classification model.
[0229] When the i th operator is the m th operator, after the electronic device determines that the i th operator is a target operator or not a target operator, the electronic device can quantize each target operator in the current operator set according to a target quantization algorithm corresponding to each target operator to obtain a target classification model.
[0230] Then, the electronic device can run the current classification model to determine the classification result of the picture to be classified to determine the index parameter of the current classification model. The index parameter can include model error, running time consumption, and resource occupation of the current classification model, and the like. Further, the electronic device can score the model performance of the current classification model according to the running time consumption and resource occupation of the current classification model to obtain a model performance score of the current classification model.
[0231] When the model error of the current classification model is less than or equal to a preset error threshold, the electronic device can further determine whether the model performance score of the current classification model is greater than a current performance threshold.
[0232] If the model performance score of the current classification model is greater than the current performance threshold, the electronic device determines the i th operator as a target operator and determines a target quantization algorithm corresponding to the i th operator. Then, the electronic device can increment the value of i by 1 and further update the current operator set, and return to determine whether i is greater than m. If the model performance score of the current classification model is less than or equal to the current performance threshold, the electronic device directly increments the value of i by 1 and further updates the current operator set, and returns to determine whether i is greater than m. The current performance threshold is the model performance score of the model obtained after the target operator in the current operator set is quantized.
[0233] When the model error of the current classification model is greater than the preset error threshold, the electronic device can increment the value of i by 1 and further update the current operator set, and return to determine whether i is greater than m.
[0234] It should be understood that when i is greater than m, i.e., i is m+1, it can be indicated that the electronic device completes the quantization determination operation of the m operators and obtains at least one target operator. In this case, the electronic device can stop the determination loop and generate a target classification model.
[0235] The information classification model generation method provided by the embodiments of the present disclosure can also be applied to the electronic device 101 in the application scenarios shown in the foregoing Figure 1
[0236] The information classification model generation method provided by the embodiments of the present disclosure will be described in detail below with reference to the accompanying drawings.
[0237] As shown in the foregoing Figure 11 When the information classification model generation method is applied to the electronic device, the information classification model generation method can include: S1001-S1004.
[0238] S1001, the electronic device obtains an initial classification model for determining a classification result of to-be-classified information.
[0239] The initial classification model includes m operators. Any operator is used for performing classification processing associated with information classification on the to-be-classified information. m is a positive integer.
[0240] In a possible manner, the to-be-classified information can be picture information, text information, or video information. The picture information can be picture information containing specific elements (for example, human faces, animals, and plants), or picture information having specific features (for example, color features, contour features, and style features). The text information can be text information containing specific characters (for example, Arabic characters and English characters), or text information having specific features (for example, emotional features and geometric features). The video information can be video information containing specific content (for example, sports content, game content, and dance content), or video information having specific features (for example, dialect features and time length features).
[0241] Correspondingly, when the to-be-classified information is picture information, the initial classification model can be an AI model for classifying picture information based on specific elements in the picture information, or an AI model for classifying picture information based on specific features possessed by the picture information. For example, when the specific element contained in the picture information is a lion, the initial classification model can determine that the classification result of the picture information is a lion class picture. When the color feature possessed by the picture information is black and white, the initial classification model can determine that the classification result of the picture information is a black and white class picture.
[0242] When the information to be classified is text information, the initial classification model can be an AI model that classifies the text information based on specific elements in the text information, or an AI model that classifies the text information based on specific features possessed by the text information. For example, when the specific character contained in the text information is an English character, the initial classification model can determine that the classification result of the text information is English text. When the sentiment feature possessed by the text information is a positive sentiment, the initial classification model can determine that the classification result of the text information is positive text.
[0243] When the information to be classified is video information, the initial classification model can be an AI model that classifies the video information based on specific content in the video information, or an AI model that classifies the video information based on specific features possessed by the video information. For example, when the specific content in the video information is sports content, the initial classification model can determine that the classification result of the video information is sports video. When the specific feature possessed by the video information is a dialect feature of A, the initial classification model can determine that the classification result of the video information is a video of the dialect of A.
[0244] In one possible manner, when the information to be classified is picture information, the classification processing associated with information classification performed by the operator on the information to be classified can be denoising processing, transformation processing, smoothing processing, and the like. When the information to be classified is text information, the classification processing associated with information classification performed by the operator on the information to be classified can be segmentation processing, recognition processing, and fusion processing, and the like. When the information to be classified is video information, the classification processing associated with information classification performed by the operator on the information to be classified can be denoising processing and grayscale transformation processing, and the like.
[0245] It should be noted that when classifying the information to be classified, the initial classification model usually needs to perform multiple types of classification processing associated with information classification on the information to be classified, such as denoising, segmentation, feature extraction, feature selection, and the like, to determine the classification result of the information to be classified.
[0246] It should be understood that the initial classification model is implemented by the m operators constituting the initial classification model when completing a plurality of classification processes on the information to be classified, and a certain processing time is required for the entire process. Further, each of the m operators is composed of parameters and calculation formulas. Moreover, in order to improve the calculation accuracy of the operators, the parameters constituting the operators are generally floating-point data. However, an operator with floating-point data parameters and an operator with fixed-point data parameters require different times to complete the same classification process. Therefore, in order to improve the running speed of the initial classification model, the initial classification model can be quantized, that is, the plurality of parameters of the m operators constituting the initial classification model are quantized from floating-point data to fixed-point data.
[0247] In an implementable manner, when the staff deploys the initial classification model for determining the classification result of the information to be classified to the processor, in order to improve the running speed of the initial classification model and reduce the occupation of the initial classification model on the resources such as storage resources and calculation resources on the processor, the initial classification model can be quantized by the electronic device in advance.
[0248] Specifically, in combination with Figure 2 , the staff can perform a file sending operation (such as clicking a send button) directed to the electronic device through the input module of the terminal to send the model file of the initial classification model stored in the storage module of the terminal to the electronic device. In response to the file sending operation, the communication module of the terminal can send the model file of the initial classification model to the electronic device. Correspondingly, the electronic device can receive the model file of the initial classification model from the terminal. Then, the electronic device can parse the model file of the initial classification model to obtain the m operators in the initial classification model. Subsequently, the electronic device can quantize the m operators to improve the running speed of the initial classification model.
[0249] S1002, the electronic device determines the influence degree level of the classification process associated with each operator on the classification result of the information to be classified according to the operation sequence and type of the classification process associated with each operator.
[0250] It should be noted that in order to determine the classification result of the information to be classified, the m operators constituting the initial classification model need to perform a plurality of types of classification processes. That is, the types of the m operators are relatively diverse. For example, the m operators can include a convolution operator for implementing convolution operation, a normalization operator for implementing normalization operation, and a pooling operator for implementing pooling operation.
[0251] Further, the operation results obtained by different types of operations often have different degrees of influence on the classification results determined by the initial classification model. Therefore, the operation precisions of different types of operators often have different degrees of influence on the classification results of the information to be classified. For example, the degree of influence of the operation precision of the convolution operation on the classification results of the information to be classified is generally higher than the degree of influence of the operation precision of the normalization operation on the classification results of the information to be classified. Moreover, the degrees of influence on the classification results of the information to be classified are often different when the operation sequence is before or after a specific type of operator. For example, when an operator is before a normalization operator, because the normalization operator performs normalization operation on the operation result of the operator, the degree of influence of the operation precision of the operator when it is before the normalization operator on the classification results of the information to be classified is generally lower than the degree of influence of the operation precision of the operator when it is after the normalization operator on the classification results of the information to be classified.
[0252] Based on this, in order to improve the running speed of the initial classification model while ensuring the implementation effect of the initial classification model, the electronic device can first determine the degree of influence of the classification processing associated with each operator in the m operators on the classification results of the information to be classified, and then preferentially select operators with lower degrees of influence on the classification results of the information to be classified for quantization, so as to quantize as many operators as possible in the m operators, thereby more effectively improving the running speed of the initial classification model and ensuring the quantization effect of the quantization processing of the initial classification model.
[0253] In an implementable manner, after obtaining the m operators in the initial classification model, the electronic device can first determine the operation sequence and type of the classification processing associated with each operator in the m operators, then determine the degree of influence of the classification processing associated with each operator on the classification results of the information to be classified according to the type of the classification processing associated with each operator, and sort the operators according to the operation sequence of the classification processing associated with each operator to obtain the degree of influence of the classification processing associated with each operator on the classification results of the information to be classified. In this way, the electronic device can preferentially quantize a specific type of operator according to the degree of influence of the classification processing associated with each operator on the classification results of the information to be classified, so as to quantize more operators in the m operators.
[0254] In a possible example, the preset initial classification model includes five operators, which are operator a, operator b, operator c, operator d and operator e. Among them, operator d and operator e are specific types of operators. Without determining the influence degree levels corresponding to the five operators, the electronic device can sequentially quantize operator a, operator b, operator c, operator d and operator e. In the process of quantizing the initial classification model by the electronic device, the accuracy of the initial classification model can meet the accuracy requirement after operator a and operator b are quantized, and then does not meet the accuracy requirement after operator c is quantized. In this case, the electronic device can only quantize operator a and operator b in the initial classification model.
[0255] With the determination of the influence degree levels corresponding to the five operators, the electronic device can preferentially quantize operator d and operator e. In the process of quantizing the initial classification model by the electronic device, the accuracy of the initial classification model can meet the accuracy requirement after operator d, operator e, operator a and operator b are quantized, and then does not meet the accuracy requirement after operator c is quantized. In this case, the electronic device can complete the quantization of the four operators of operator d, operator e, operator a and operator b. It can be seen that, after the determination of the influence degree levels corresponding to the m operators constituting the initial classification model, the electronic device can quantize as many operators as possible in the m operators.
[0256] S1003. The electronic device sequentially performs a quantization determination operation on each operator according to the influence degree level corresponding to each operator from low to high, to obtain at least one target operator.
[0257] In a possible manner, the quantization determination operation can be used to determine an operator whose quantized classification model meets the first preset condition as the target operator. The target operator can be an operator whose quantization can reduce the operation time consumption of the initial classification model, and the influence degree on the operation accuracy of the initial classification model is relatively low.
[0258] In a possible manner, the first preset condition can include that the relative gap between the classification result of the classification information determined by the quantized classification model and the classification result of the classification information determined by the initial classification model is less than a preset threshold, and the running time consumption of the classification result determined by the quantized classification model is less than the running time consumption of the classification result determined by the initial classification model. The preset threshold can be preset in the electronic device by the staff in advance.
[0259] In an implementable manner, after determining the influence degree levels corresponding to the m operators, the electronic device can sequentially perform quantization determination operations on the operators in the order from low to high of the influence degree levels corresponding to the operators, that is, preferentially performing quantization determination operations on the operators whose influence on the classification result of the to-be-classified information by the associated classification processing is low. Specifically, after selecting an operator according to the influence degree levels corresponding to the operators, the electronic device can quantize the selected operator. Then, the electronic device can replace the selected operator in the initial classification model before quantization with the selected operator after quantization to obtain the initial classification model after updating the selected operator, that is, a classification model after quantization. Then, the electronic device can determine the classification result of the to-be-classified information based on the classification model after quantization, and test the running time of the classification model after quantization to determine whether the classification model after quantization meets the first preset condition.
[0260] If it is determined that the relative gap between the classification result of the to-be-classified information determined by the classification model after quantization and the classification result of the to-be-classified information determined by the initial classification model is less than the preset threshold, and the running time of the classification result determined by the classification model after quantization is less than the running time of the classification result determined by the initial classification model, the selected operator is determined to be a target operator. Then, the electronic device can select a next operator in the influence degree levels corresponding to the operators based on the initial classification model after updating the selected operator, and then perform a quantization determination operation on the selected next operator. If not, the electronic device determines that the selected operator is not a target operator. Then, the electronic device can select a next operator in the influence degree levels corresponding to the operators based on the initial classification model without updating the selected operator, and then perform a quantization determination operation on the selected next operator. In this way, after the electronic device performs quantization determination operations on the m operators according to the influence degree levels corresponding to the m operators, at least one target operator can be obtained.
[0261] S1004, the electronic device quantizes at least one target operator in the initial classification model to generate a target classification model for determining the classification result of the to-be-classified information.
[0262] In a possible manner, the running time of the target classification model is less than the running time of the initial classification model, and the relative gap between the result output by the target classification model and the result output by the initial classification model is less than or equal to a preset threshold.
[0263] In an implementable manner, since the target operator is quantized, the running time of the initial classification model can be reduced without affecting the implementation effect of the initial classification model. Therefore, after obtaining at least one target operator, the electronic device can quantize at least one target operator in the initial classification model to generate a target classification model.
[0264] In a possible example, in combination with the example in S1002 above, on the premise of the same precision condition, the preset electronic device can sequentially quantize the operators a and b in the initial classification model to obtain model A when the influence degree level corresponding to each operator is not determined. The electronic device can first perform a quantization determination operation on each operator according to the influence degree level corresponding to each operator, and then quantize the operators d, e, a, and b in the initial classification model to obtain model B (i.e., the target classification model) after obtaining the four target operators d, e, a, and b.
[0265] When GPU1 needs to determine the classification result of the information 1 to be classified, model A is deployed on GPU1. Since 3 of the 5 operators that constitute model A are not quantized, that is, 2 of the 5 operators are based on fixed-point data and 3 are based on floating-point data. Therefore, when GPU1 calls model A to determine the classification result of the information 1 to be classified, it needs to run 2 operators based on fixed-point data and 3 operators based on floating-point data.
[0266] When model B (i.e., the target classification model) is deployed on GPU1, since only 1 of the 5 operators that constitute model B is not quantized, that is, 4 of the 5 operators are based on fixed-point data and 1 is based on floating-point data. Therefore, when GPU1 calls model B to determine the classification result of the information 1 to be classified, it needs to run 4 operators based on fixed-point data and 1 operator based on floating-point data.
[0267] It can be seen that, compared with calling model A to determine the classification result of the information 1 to be classified, which requires running 3 operators based on floating-point data, calling model B (i.e., the target classification model) to determine the classification result of the information 1 to be classified only requires running 1 operator based on floating-point data. It should be understood that, compared with an operator based on floating-point data, an operator based on fixed-point data requires significantly less running time. Therefore, the target classification model can process the information 1 faster while ensuring accuracy.
[0268] The technical solutions provided by the above embodiments at least bring the following beneficial effects: As can be seen from S1001-S1004, after the electronic device obtains the initial classification model for determining the classification result of the information to be classified, it can determine the influence degree level of the classification processing associated with each operator on the classification result of the information to be classified according to the operation order and type of the classification processing associated with each operator in the initial classification model, and further perform a quantization determination operation on each operator in the order from low to high according to the influence degree level corresponding to each operator to obtain at least one target operator, thereby quantizing each target operator in the initial classification model to generate a target classification model.
[0269] Since the m operators in the initial classification model have different levels of influence on the classification results of the information to be classified, the influence of each operator on the accuracy of the initial classification model after quantization is also different. Based on this, the present disclosure first determines the level of influence of each operator associated with the classification process on the classification results of the information to be classified, and then selects as many target operators as possible from the m operators in the order of the corresponding influence levels from low to high, so as to further quantize the multiple target operators and generate a target classification model. Compared with the general technical manner of quantizing part of the parameters by relying on manual experience, the present disclosure quantizes the model by the electronic device in the manner of determining one by one according to the influence level, which not only saves human resources, but also ensures that as many operators as possible in the initial classification model are quantized to obtain the target classification model, thereby improving the running speed of the business application without affecting the implementation effect of the business application.
[0270] In an embodiment, in combination with Figure 11 In the above S1002, when the electronic device determines the level of influence of each operator associated with the classification process on the classification results of the information to be classified according to the operation order and type of the classification process associated with each operator, as shown in the following table, the present disclosure provides an optional implementation manner, which specifically includes S1101-S1105. Figure 12
[0271] S1101, the electronic device determines the operation order of the classification process associated with the n structural blocks.
[0272] In one possible manner, the m operators constituting the initial classification model are generally distributed in each structural block. That is, the initial classification model generally includes n structural blocks, and each structural block includes at least one of the m operators. n is a positive integer less than m. It should be understood that one operator is located in only one structural block.
[0273] In one possible manner, any structural block can be used to perform the classification process associated with information classification (such as denoising processing and fusion processing, etc.) on the information to be classified. It should be understood that the classification process associated with information classification performed by the structural block on the information to be classified is implemented based on the at least one operator included.
[0274] In one possible manner, after the electronic device parses the model file of the initial classification model to obtain the n structural blocks, it can arrange the sequence numbers of the n structural blocks in order according to the calculation logic of the n structural blocks, from the structural block at the beginning of the operation to the structural block at the end of the operation, to determine the operation order of the classification process associated with the n structural blocks.
[0275] S1102, the electronic device determines, according to a first preset rule, an influence degree level of the classification processing of the n structural blocks on the classification result of the to-be-classified information.
[0276] The first preset rule includes: when the first structural block and the second structural block in the n structural blocks are both preset type structural blocks, and the operation order of the first structural block is before the operation order of the second structural block, or when the first structural block is a preset type structural block and the second structural block is not a preset type structural block, or when the first structural block and the second structural block are both not preset type structural blocks and the operation order of the first structural block is before the operation order of the second structural block, it is determined that the influence degree level of the first structural block is lower than that of the second structural block. The preset type structural block is a structural block including a preset type operator. The preset type operator is an operator with a normalization function; the first structural block is any one of the n structural blocks. The second structural block is any one of the n structural blocks except the first structural block.
[0277] In one possible manner, for the preset type structural block including the preset type operator, the operation start operator and the operation end operator in the preset type structural block can be the preset type operator.
[0278] It should be noted that when the preset type operator is included, the result obtained by the preset type structural block processing data often does not require high precision. That is, after the floating point type data in the preset type structural block is converted into fixed point type data, the initial classification model is less affected by the precision.
[0279] In one possible example, the preset initial classification model includes 6 structural blocks, which are structural block 1 with sequence number 1, structural block 2 with sequence number 2, structural block 3 with sequence number 3, structural block 4 with sequence number 4, structural block 5 with sequence number 5, and structural block 6 with sequence number 6. Moreover, the structural block 3 and the structural block 5 are preset type structural blocks.
[0280] According to the first preset rule, since the structural block 3 and the structural block 5 are preset type structural blocks, and the operation order of the structural block 3 is before the operation order of the structural block 5. Therefore, the electronic device can determine that the influence degree level of the structural block 3 is lower than that of the structural block 5.
[0281] Since the structural block 5 is a preset type structural block and the structural block 1 is not a preset type structural block, the electronic device can determine that the influence degree level of the structural block 5 is lower than that of the structural block 1.
[0282] Since the structural block 1 and the structural block 2 are both not preset type structural blocks, and the operation order of the structural block 1 is before the operation order of the structural block 2. Therefore, the electronic device can determine that the influence degree level of the structural block 1 is lower than that of the structural block 2.
[0283] By analogy, the electronic device can determine that the influence degree level of the structural block 3 is the first level, the influence degree level of the structural block 5 is the second level, the influence degree level of the structural block 1 is the third level, the influence degree level of the structural block 2 is the fourth level, the influence degree level of the structural block 4 is the fifth level, and the influence degree level of the structural block 6 is the sixth level.
[0284] S1103, the electronic device determines the operation order of the classification processing associated with the at least one operator in each structural block.
[0285] Specifically, after the electronic device parses the model file of the initial classification model to obtain n structural blocks, the electronic device can further determine at least one operator included in each structural block, and according to the calculation logic of each structural block, sequentially arrange the sequence number of the at least one operator in each structural block from the operation starting operator to the operation ending operator to determine the operation order of the classification processing associated with the at least one operator in each structural block.
[0286] S1104, the electronic device determines the influence degree level of the classification result of the classification processing associated with the at least one operator in each structural block on the to-be-classified information according to a second preset rule.
[0287] The second preset rule includes: when the next operator of the first operator and the next operator of the second operator in the structural block are both preset type operators, and the operation order of the first operator is located before the operation order of the second operator, or when the next operator of the first operator is a preset type operator and the next operator of the second operator is not a preset type operator, or when the next operator of the first operator and the next operator of the second operator are both not preset type operators and the operation order of the first operator is located before the operation order of the second operator, it is determined that the influence degree level of the first operator is lower than that of the second operator. The first operator is any one operator in the structural block. The second operator is any one operator in the structural block except the first operator.
[0288] It should be noted that when the next operator of an operator is a preset type operator, the next operator will perform normalization processing on the result output by the operator. Therefore, the electronic device can determine that the result output by the operator does not need to have high precision, that is, after converting the floating-point data in the operator to fixed-point data, the influence of the precision on the preset type structural block is small. In this way, the influence of the precision on the initial classification model is also small.
[0289] In a possible example, in combination with the example of S1102, the preset structure block 3 includes 6 operators, which are an operator 1 with a sequence number of 1, an operator 2 with a sequence number of 2, an operator 3 with a sequence number of 3, an operator 4 with a sequence number of 4, an operator 5 with a sequence number of 5, and an operator 6 with a sequence number of 6. In addition, the operator 2 and the operator 6 are preset type operators.
[0290] According to the second preset rule, since the operator 2 following the operator 1 and the operator 6 following the operator 5 are preset type operators, and the operation sequence of the operator 1 is before that of the operator 5, the electronic device can determine that the influence degree level of the operator 1 is lower than that of the operator 5.
[0291] Since the operator 6 following the operator 5 is a preset type operator, and the operator 3 following the operator 2 is not a preset type operator, the electronic device can determine that the influence degree level of the operator 5 is lower than that of the operator 2.
[0292] Since the operator 3 following the operator 2 and the operator 4 following the operator 3 are not preset type operators, and the operation sequence of the operator 2 is before that of the operator 3, the electronic device can determine that the influence degree level of the operator 2 is lower than that of the operator 3.
[0293] By analogy, the electronic device can determine that the influence degree level of the operator 1 is the first level, the influence degree level of the operator 5 is the second level, the influence degree level of the operator 2 is the third level, the influence degree level of the operator 3 is the fourth level, the influence degree level of the operator 4 is the fifth level, and the influence degree level of the operator 6 is the sixth level.
[0294] S1105, the electronic device determines the influence degree level corresponding to each operator according to the influence degree levels corresponding to the n structure blocks and the influence degree levels corresponding to at least one operator in each structure block.
[0295] Specifically, after determining the influence degree levels corresponding to the n structure blocks and the influence degree levels corresponding to at least one operator in each structure block, the electronic device can sort the n structure blocks according to the influence degree levels of each structure block, and sort at least one operator in each structure block according to the influence degree levels of at least one operator in each structure block, to determine the influence degree levels corresponding to each operator.
[0296] In a possible example, in combination with the examples of S1102 and S1104 described above, the electronic device can first sort the six structural blocks into structural block 3, structural block 5, structural block 1, structural block 2, structural block 4, and structural block 6 according to the influence degree levels of the six structural blocks in the initial classification model. Then, the electronic device can sort the six operators in the structural block 3 into operator 1, operator 5, operator 2, operator 3, operator 4, and operator 6 according to the influence degree levels of the six operators in the structural block 3. In this way, the electronic device can obtain the influence degree levels of the operators after sorting the operators in the structural block 5, the structural block 1, the structural block 2, the structural block 4, and the structural block 6.
[0297] The technical solutions provided in the above examples at least have the following beneficial effects: As can be seen from S1101-S1105, a specific implementation manner is given in which the electronic device determines the influence degree levels of the classification processing associated with each operator on the classification result of the to-be-classified information according to the operation order and type of the classification processing associated with each operator. After determining the operation order of the classification processing associated with the n structural blocks, the electronic device determines the influence degree levels of the classification processing associated with the n structural blocks on the classification result of the to-be-classified information according to the first preset rule, and after determining the operation order of the classification processing associated with at least one operator in each structural block, the electronic device determines the influence degree levels of the classification processing associated with at least one operator in each structural block on the classification result of the to-be-classified information according to the second preset rule, so as to determine the influence degree levels of each operator according to the influence degree levels of the n structural blocks and the influence degree levels of at least one operator in each structural block. Subsequently, the electronic device can determine the target operator according to the influence degree levels of the m operators, thereby improving the probability of determining the target operator with the maximum number and providing higher guarantee than artificial experience.
[0298] In an embodiment, in combination with Figure 11 In S1003 described above, the electronic device sequentially performs the quantization determination operation on each operator according to the influence degree levels of the operators from low to high, and when at least one target operator is obtained, the electronic device can determine the target operator according to the influence degree levels of the m operators. Figure 13 As shown in the above S1003, the present disclosure provides an alternative implementation manner, specifically including S1201-S1204.
[0299] S1201, the electronic device quantizes each operator in the current operator set to obtain a current classification model.
[0300] The current operator set includes the target operator in the i th operator and the first i-1 operators in the order of the influence degree levels of the operators from low to high. i is a positive integer less than or equal to m. The current classification model is the model obtained after quantization of the i th operator.
[0301] In a possible example, in combination with the example in S1002, the influence degree levels corresponding to the five operators in the preset initial classification model are operator d, operator e, operator a, operator b and operator c. When the electronic device starts to perform the quantization determination operation on the five operators based on the influence degree levels corresponding to the five operators, that is, when i is equal to 1, the current operator set includes the first operator (that is, operator d) in the order from low to high of the influence degree levels corresponding to the five operators, and at this time, there is no target operator. In this case, after the electronic device quantizes the first operator (that is, operator d), the electronic device can replace the unquantized operator d in the initial classification model with the quantized operator d to obtain the current classification model, that is, the model obtained after quantization of operator d.
[0302] Then, if it is determined that operator d is the target operator, when i is equal to 2, the current operator set includes the second operator (that is, operator e) in the order from low to high of the influence degree levels corresponding to the five operators and operator d. In this case, after the electronic device quantizes operator d and operator e, the electronic device can replace the unquantized operator d in the initial classification model with the quantized operator d, and replace the unquantized operator e in the initial classification model with the quantized operator e, to obtain the current classification model, that is, the model obtained after quantization of operator e.
[0303] S1202, the electronic device determines the i th operator as the target operator when the current classification model meets the first preset condition, and updates the value of i.
[0304] In a possible manner, the first preset condition can further include that a relative gap between the classification result of the to-be-classified information determined by the current classification model and the classification result of the to-be-classified information determined by the initial classification model is less than or equal to a preset threshold, and a running time consumed by the current classification model to determine the classification result is less than a current time threshold. The current time threshold is a running time consumed by a classification model obtained after quantization of each target operator in the current operator set to determine the classification result.
[0305] In an implementable manner, when the current classification model meets the first preset condition, it can be indicated that the operation accuracy of the current classification model meets the requirement. Moreover, since the current duration threshold is the running time consumption of the model obtained after quantization of the target operator in the current operator set, that is, the running time consumption of the previous current classification model before the current classification model. Therefore, if the running time consumption of the current classification model is less than the current duration threshold, it can be indicated that the running time consumption of the current classification model is lower than the running time consumption of the previously determined current classification model, that is, it can be indicated that the running time consumption of the current classification model is the shortest, and the operation speed can be improved and the operation accuracy can be ensured after quantization of the i th operator. In this case, the electronic device can determine the i th operator as the target operator, and update the value of i, that is, increment the value of i by 1, to then determine the next operator in the influence degree level corresponding to each operator.
[0306] S1203, the electronic device updates the value of i when the current classification model does not meet the first preset condition.
[0307] In an implementable manner, when the current classification model does not meet the first preset condition, it indicates that the i th operator cannot improve the operation speed of the initial classification model after being quantized. Or, the i th operator can improve the operation speed of the initial classification model after being quantized, but cannot guarantee the operation accuracy. In these cases, the i th operator cannot be determined as the target operator. Therefore, the electronic device can directly update the value of i, that is, increment the value of i by 1.
[0308] S1204, the electronic device repeatedly quantizes each operator in the current operator set until i is greater than m, to obtain at least one target operator.
[0309] In an implementable manner, after updating the value of i, that is, incrementing the value of i by 1, the electronic device can first update the current operator set according to the value of i after incrementing (i.e., i+1), and then quantize each operator in the updated current operator set to obtain an updated current classification model, and determine whether the updated current classification model meets the first preset condition. In this way, until i is greater than m, the electronic device can obtain at least one target operator.
[0310] In a possible example, in combination with the example in S1201, the influence degree levels corresponding to the 5 operators in the preset initial classification model are operator d, operator e, operator a, operator b and operator c. When the electronic device starts to perform the quantization determination operation on the 5 operators based on the influence degree levels corresponding to the 5 operators, that is, i is equal to 1, the current operator set includes the first operator (i.e., operator d) in the order from low to high in the influence degree levels corresponding to the 5 operators, and at this time there is no target operator.
[0311] Then, if the current classification model obtained by quantizing each operator in the current operator set meets the first preset condition, the electronic device can determine the operator d as the target operator, and increment the value of i by 1. At this time, i is equal to 2, and the current operator set is: the operator d and the second operator (i.e., the operator e).
[0312] Then, if the current classification model obtained by quantizing each operator in the current operator set meets the first preset condition, the electronic device can determine the operator d and the operator e as the target operators, and increment the value of i by 1. At this time, i is equal to 3, and the current operator set is: the operator d, the operator e, and the third operator (i.e., the operator a).
[0313] Then, if the current classification model obtained by quantizing each operator in the current operator set does not meet the first preset condition, the electronic device can determine the operator d and the operator e as the target operators, and increment the value of i by 1. At this time, i is equal to 4, and the current operator set is: the operator d, the operator e, and the fourth operator (i.e., the operator b).
[0314] Then, if the current classification model obtained by quantizing each operator in the current operator set meets the first preset condition, the electronic device can determine the operator d, the operator e, and the operator b as the target operators, and increment the value of i by 1. At this time, i is equal to 5, and the current operator set is: the operator d, the operator e, the operator b, and the fifth operator (i.e., the operator c).
[0315] Then, if the current classification model obtained by quantizing each operator in the current operator set does not meet the first preset condition, the electronic device can determine the operator d, the operator e, and the operator b as the target operators, and increment the value of i by 1. At this time, since i is equal to 6, the electronic device ends the execution of the quantization determination operation in accordance with the condition that i is greater than m.
[0316] In this way, the electronic device can obtain the target operators including the operator d, the operator e, and the operator b.
[0317] The above embodiment provides at least the following beneficial effects: As can be seen from S1201-S1204, a specific implementation manner in which the electronic device sequentially executes the quantization determination operation on each operator in accordance with the order from low to high of the influence degree level corresponding to each operator, and obtains at least one target operator is given. After quantizing each operator in the current operator set to obtain the current classification model, the electronic device can determine whether the current classification model meets the first preset condition. If yes, the electronic device can determine the i th operator as the target operator meeting the quantization condition, and increment the value of i by 1. If no, the electronic device directly increments the value of i by 1. Then, the electronic device can repeatedly quantize each operator in the current operator set until i is greater than m, and at least one target operator is obtained.
[0318] In an embodiment, when the electronic device quantizes each operator in the current set of operators to obtain the current classification model, the present disclosure provides an optional implementation, specifically comprising: S1301-S1303. Figure 14
[0319] S1301. The electronic device quantizes each target operator according to a target quantization algorithm corresponding to each target operator in the current set of operators to obtain a first model.
[0320] It should be noted that when the target operator is included in the current set of operators, it indicates that the electronic device has quantized the target operator before and has determined the target quantization method corresponding to the target operator. In this case, the electronic device can quantize each target operator according to the target quantization algorithm corresponding to each target operator in the current set of operators to obtain the first model. For specific descriptions of this case, please refer to the specific implementation of S1302-S1303 below, which will not be repeated here.
[0321] When the target operator is not included in the current set of operators, it indicates that the current set of operators is the first set of operators, or the previous current set of operators does not meet the first preset condition. In this case, the electronic device can determine that there is no first model.
[0322] S1302. The electronic device quantizes the i-th operator according to a plurality of preset quantization algorithms based on the first model to obtain a plurality of second models corresponding one-to-one to the plurality of preset quantization algorithms.
[0323] It should be noted that when quantizing an operator for processing at least two variables, a scale can generally be determined first to convert the floating-point data in the operator to fixed-point data. Since the scale needs to be determined, the value range of the floating-point data and the value range of the fixed-point data need to be known. Therefore, in order to determine the scale, the minimum (min) and maximum (max) of the floating-point data in the operator need to be determined first to obtain the value range of the floating-point data. The value range of the fixed-point data can be set according to the type of quantized data. It should be understood that the specific determination formula of the scale can be understood by those skilled in the art with reference to the prior art, which will not be repeated here.
[0324] In one possible manner, the fixed-point data can be set as int16 type, and the value range of the fixed-point data can be (-32768, +32767). After the target classification model is obtained by setting the fixed-point data as int16 type, if the target classification model with the fixed-point data as Int8 type is needed, the scaling factor obtained when the fixed-point data is set as int16 type can be changed to directly obtain the target classification model with the fixed-point data as Int8 type. At the same time, the model error between the target classification model obtained based on the fixed-point data as int16 type and the initial classification model based on the floating-point data as fp16 type is less than 1 / 215, and the theoretical accuracies of the two are in the same order of magnitude. The model error between the target classification model obtained based on the fixed-point data as int16 type and the initial classification model based on the floating-point data as fp32 type is also between 10e-2 and 10e-3.
[0325] In addition, when determining the minimum value and the maximum value of the floating-point data in the one operator, there are usually multiple calibration algorithms. For example, entropy, mean-square error (MSE), percentile, and other algorithms. In addition, after obtaining the scaling factor according to the value range of the floating-point data and the value range of the fixed-point data, there are also multiple counting reservation methods. For example, rounding and ceiling algorithms. At the same time, each calibration algorithm can also adjust the size of the parameter to calibrate when determining the minimum value and the maximum value of the floating-point data in the one operator. For example, the percentile method can adjust the percentage parameter to any value from 0% to 100%.
[0326] When quantizing an operator for processing a variable and a weight, each per channel quantization method and each per tensor quantization method can also be selected.
[0327] Based on this, when quantizing the one operator, in order to reduce the error as much as possible to obtain the highest possible accuracy, the electronic device of the present disclosure is pre-configured with multiple preset quantization algorithms. The multiple preset quantization algorithms can include multiple quantization algorithms based on the percentile method and the rounding method of multiple percentage parameters, and can also include multiple quantization algorithms based on the percentile method and the ceiling method of multiple percentage parameters, or any one of the quantization algorithms that can quantize the one operator. Here, they will not be listed one by one.
[0328] Specifically, after performing S1301, if the first model does not exist, the electronic device can determine that the current operator set only includes the i-th operator. In this case, the electronic device can quantize the i-th operator according to the plurality of preset quantization algorithms to obtain a plurality of second models corresponding to the plurality of preset quantization algorithms.
[0329] If the first model exists, the electronic device can determine that the current operator set includes at least one target operator in addition to the i-th operator. In this case, the electronic device can quantize the i-th operator once according to each preset quantization algorithm to obtain a plurality of quantized i-th operators corresponding to the plurality of preset quantization algorithms. Then, the electronic device can combine each quantized i-th operator with the first model once to obtain a plurality of second models corresponding to the plurality of preset quantization algorithms.
[0330] In one possible example, in combination with the example in S1002 described above, when the current operator set includes the first operator (i.e., operator d) in the order of the influence degree level of each operator from low to high, and there is no target operator, the electronic device can perform S1301 to determine that there is no first model, and quantize the operator d according to the plurality of preset quantization algorithms to obtain a plurality of second models corresponding to the plurality of preset quantization algorithms.
[0331] Further, the electronic device can determine the second model that meets the second preset condition from the plurality of second models as the current classification model, and determine the quantization algorithm corresponding to the second model that meets the second preset condition as the target quantization algorithm corresponding to the operator d. Specifically, the process can refer to the description of S1303 and S1401 below.
[0332] When the current operator set is updated to the operator d and the second operator (i.e., operator e), the electronic device can quantize the operator d according to the target quantization algorithm corresponding to the target operator (i.e., operator d) in the current operator set to obtain a first model. Then, the electronic device can quantize the i-th operator (i.e., operator e) in the current operator set according to the plurality of preset quantization algorithms based on the first model to obtain a plurality of second models corresponding to the plurality of preset quantization algorithms. Until a plurality of target operators including the operator d, the operator e, and the operator b are obtained.
[0333] S1303, the electronic device determines the second model that meets the second preset condition from the plurality of second models as the current classification model.
[0334] The second preset condition includes that the relative gap between the classification result of the to-be-classified information determined by the second model and the classification result of the to-be-classified information determined by the initial classification model is less than or equal to a preset threshold, and the running time of the classification result determined by the second model is less than or equal to a preset time threshold.
[0335] In one possible approach, the electronic device can identify the second model with the shortest running time to determine the classification result when the relative difference between the classification result of the information to be classified determined by the multiple second models and the classification result of the information to be classified determined by the initial classification model is less than or equal to a preset threshold, and the running time of the preset second model to determine the classification result is set as a preset time threshold.
[0336] Based on this, after obtaining multiple second models, the electronic device can determine the second model as the current classification model if the relative difference between the classification result of the information to be classified determined by the multiple second models and the classification result of the information to be classified determined by the initial classification model is less than or equal to a preset threshold, and the running time to determine the classification result is less than or equal to a preset time threshold. In other words, the current classification model is the second model among the multiple second models that meets the accuracy requirements and has the fastest running speed.
[0337] The technical solution provided by the above embodiments brings at least the following beneficial effects: As shown in S1301-S1303, a specific implementation method for an electronic device to quantize each operator in the current operator set to obtain the current classification model is given. Based on the first model, the electronic device can quantize each operator as a single variable using multiple preset quantization algorithms to obtain multiple second models. Then, among the multiple second models, the current classification model that meets the second preset condition is determined, i.e., the second model with the best quantization effect is determined as the current classification model. Therefore, based on the target operator of the determined target quantization algorithm, the electronic device can evaluate the different quantization effects of multiple preset quantization algorithms on an operator, thereby identifying the preset quantization algorithm most suitable for that operator and achieving a differentiated evaluation of the superiority of multiple preset quantization algorithms.
[0338] In one feasible example, combining Figure 14 ,like Figure 15 As shown, the information classification model generation method provided in this disclosure also includes: S1401.
[0339] S1401. The electronic device determines the preset quantization algorithm corresponding to the second model that meets the second preset conditions as the target quantization algorithm corresponding to the i-th operator.
[0340] Specifically, after determining the current classification model in the plurality of second models, the electronic device can determine the preset quantization algorithm corresponding to the second model that meets the second preset condition as the target quantization algorithm corresponding to the i-th operator. In this way, when the current classification model meets the first preset condition, the electronic device can determine the i-th operator in the current operator set as the target operator, and determine the target quantization algorithm corresponding to the i-th operator as the target quantization algorithm corresponding to the target operator.
[0341] Subsequently, when the target operator (i.e., the i-th operator) needs to be quantized, the electronic device can conveniently quantize the target operator according to the target quantization algorithm corresponding to the target operator, thereby accelerating the quantization speed of the initial classification model.
[0342] In a possible example, in combination with the example in S1002 above, when the current operator set includes the first operator (i.e., operator d) in the order of the influence degree level of each operator from low to high, and there is no target operator, if the current classification model obtained after each operator in the current operator set is quantized meets the first preset condition, the electronic device can determine the i-th operator (i.e., operator d) in the current operator set as the target operator, and determine the quantization algorithm corresponding to the current classification model as the target quantization algorithm corresponding to the operator d.
[0343] When the current operator set is updated to the operator d and the second operator (i.e., operator e), if the current classification model obtained after each operator in the current operator set is quantized meets the first preset condition, the electronic device can determine the i-th operator (i.e., operator e) in the current operator set as the target operator, and determine the quantization algorithm corresponding to the current classification model as the target quantization algorithm corresponding to the operator e. Until the target operator including the operator d, the operator e and the operator b, and the target quantization algorithm corresponding to the operator d, the target quantization algorithm corresponding to the operator e and the target quantization algorithm corresponding to the operator b are obtained.
[0344] The technical solutions provided by the above embodiments at least bring the following beneficial effects: As can be known from S1401, after the electronic device determines the target quantization algorithm most suitable for the i-th operator in the current operator set from the plurality of preset quantization algorithms on the basis of the target operator for which the target quantization algorithm has been determined, the electronic device can establish the correspondence between the i-th operator in the current operator set and the target quantization algorithm. In this way, after the i-th operator in the current operator set is determined as the target operator, the electronic device can conveniently quantize the i-th operator in the current operator set.
[0345] In a possible example, in combination with Figure 11In the S1004, the electronic device quantizes at least one target operator in the initial classification model to generate a target classification model for determining a classification result of the information to be classified. Figure 16 As shown in the S1501, the present disclosure provides an optional implementation, which specifically includes the following steps.
[0346] In the S1501, the electronic device quantizes each target operator according to a target quantization algorithm corresponding to the target operator to generate a target classification model.
[0347] Specifically, when the electronic device obtains the plurality of target operators, the electronic device also obtains the target quantization algorithm corresponding to each target operator. Therefore, the electronic device can quantize each target operator according to the target quantization algorithm corresponding to the target operator to obtain the target classification model.
[0348] In a possible example, in combination with the example in the S1401, the plurality of target operators include the operator d, the operator e, and the operator b. The electronic device can quantize the operator d according to the target quantization algorithm corresponding to the operator d, then quantize the operator e according to the target quantization algorithm corresponding to the operator e, and then quantize the operator b according to the target quantization algorithm corresponding to the operator b. In this way, the electronic device can complete the quantization of the initial classification model to obtain the target classification model.
[0349] The above-mentioned embodiments provide at least the following beneficial effects: As shown in the S1501, a specific implementation of the electronic device quantizing each target operator in the initial classification model to obtain a target classification model is given. After obtaining the plurality of target operators, since each target operator corresponds to a target quantization algorithm, the electronic device does not need to distinguish the plurality of preset quantization algorithms, and can conveniently quantize each target operator in the target operators according to the target quantization algorithm corresponding to the target operator to obtain the target classification model.
[0350] In an embodiment, when the electronic device determines the second model meeting the second preset condition in the plurality of second models as the current classification model, as shown in the S1601-S1602, the present disclosure provides an optional implementation, which includes the following steps. Figure 17
[0351] In the S1601, the electronic device classifies the information to be classified based on the second model to obtain running information of the second model.
[0352] The running information includes a classification result of the information to be classified determined by the second model and a running time consumed by the second model to determine the classification result.
[0353] Specifically, after obtaining the second model, the electronic device can classify the to-be-classified information based on the second model, and monitor the running process of the second model. In this way, the electronic device can obtain the classification result of the to-be-classified information determined by the second model. At the same time, the electronic device can monitor the time information of starting and stopping running of the second model to determine the running time consumption of the second model to determine the classification result.
[0354] In S1602, when the relative gap between the classification result of the to-be-classified information determined by the second model and the classification result of the to-be-classified information determined by the initial classification model is less than or equal to a preset threshold, and the running time consumption of the second model to determine the classification result is less than or equal to a preset time threshold, the electronic device determines that the second model is the current classification model.
[0355] It should be noted that, since a large number of parameters in the initial classification model are floating point data. Therefore, the classification result obtained by the initial classification model by classifying the to-be-classified information has good accuracy. Based on this, in order to accurately determine the error of the second model, the electronic device can determine the relative gap between the classification result of the to-be-classified information determined by the second model and the classification result of the to-be-classified information determined by the initial classification model as the model error of the second model.
[0356] In a possible manner, the electronic device can determine the relative gap between the classification result of the to-be-classified information determined by the second model and the classification result of the to-be-classified information determined by the initial classification model by using a first formula. The first formula is:
[0357] R = ∑abs(r-Q) / ∑(r).
[0358] Wherein, R is the relative gap between the classification result of the to-be-classified information determined by the second model and the classification result of the to-be-classified information determined by the initial classification model. r is the classification result of the to-be-classified information determined by the second model. Q is the classification result of the to-be-classified information determined by the initial classification model. ∑abs is used to represent the absolute value of the value in the parentheses. ∑ is used to sum all values in the parentheses.
[0359] The technical solutions provided by the above embodiments have at least the following beneficial effects: As can be seen from the above S1601-S902, a specific implementation manner in which the electronic device determines a second model that meets a second preset condition from multiple second models as a current classification model is given. The electronic device can classify to-be-classified information based on the second model, obtain running information of the second model, and determine the second model as the current classification model when a relative gap between a classification result of the to-be-classified information determined by the second model and a classification result of the to-be-classified information determined by the initial classification model is less than or equal to a preset threshold, and a running time of the classification result determined by the second model is less than or equal to a preset time threshold. In this way, the electronic device can more accurately determine the quantification effect of the second model, and better evaluate the performance of the second model when actually deployed on a coprocessor such as a GPU.
[0360] It can be understood that, in actual implementation, the terminal / server described in the embodiments of the present disclosure can include one or more hardware structures and / or software modules for implementing the foregoing corresponding picture classification model generation method, and these execution hardware structures and / or software modules can constitute an electronic device. Those skilled in the art should easily realize that, in combination with the algorithm steps of each example described in the embodiments disclosed herein, the present disclosure can be realized in the form of hardware or a combination of hardware and computer software. Whether a certain function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional technicians 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 present disclosure.
[0361] Based on such understanding, the embodiments of the present disclosure also correspondingly provide a picture classification model generation apparatus. Figure 18 The structure schematic diagram of the picture classification model generation apparatus provided by the embodiments of the present disclosure is shown. As shown in the figure, Figure 18 The picture classification model generation apparatus can include an acquisition unit 1701, a determination unit 1702, and a processing unit 1703.
[0362] The acquisition unit 1701 is configured to acquire an initial classification model used to determine a classification result of a to-be-classified picture; the initial classification model includes m operators; any operator is used to perform classification processing associated with picture classification on the to-be-classified picture; m is a positive integer;
[0363] The determination unit 1702 is configured to determine an influence degree level of the classification processing associated with each operator on the classification result of the to-be-classified picture according to an operation order and a type of the classification processing associated with each operator;
[0364] The processing unit 1703 is configured to sequentially perform quantization determination operations on each operator in an order from low to high of the influence degree level corresponding to each operator to obtain at least one target operator; the quantization determination operation is used to determine an operator whose quantized classification model satisfies a first preset condition as a target operator.
[0365] The processing unit 1703 is further configured to quantize the at least one target operator in the initial classification model to generate a target classification model used to determine a classification result of the picture to be classified.
[0366] Optionally, the initial classification model includes n structural blocks; each structural block includes at least one operator; any structural block is used to perform classification processing associated with picture classification on the picture to be classified; n is a positive integer smaller than m; the determining unit 1702 is specifically configured to: determine an operation order of the classification processing associated with the n structural blocks; determine an influence degree level of the classification processing associated with the n structural blocks on the classification result of the picture to be classified according to a first preset rule; determine an operation order of the classification processing associated with the at least one operator in each structural block; determine an influence degree level of the classification processing associated with the at least one operator in each structural block on the classification result of the picture to be classified according to a second preset rule; and determine the influence degree level corresponding to each operator according to the influence degree level corresponding to the n structural blocks and the influence degree level corresponding to the at least one operator in each structural block.
[0367] Optionally, the first preset rule includes: when a first structural block and a second structural block in the n structural blocks are both preset type structural blocks, and the operation order of the first structural block is located before the operation order of the second structural block, or when the first structural block is a preset type structural block and the second structural block is not a preset type structural block, or when the first structural block and the second structural block are both not preset type structural blocks and the operation order of the first structural block is located before the operation order of the second structural block, it is determined that the influence degree level of the first structural block is lower than that of the second structural block; the preset type structural block is a structural block including a preset type operator; the preset type operator is an operator with a normalization function; the first structural block is any one of the n structural blocks; and the second structural block is any one of the n structural blocks except the first structural block.
[0368] Optionally, the second preset rule comprises: when a next operator of the first operator and a next operator of the second operator in the structural block are both preset type operators, and an operation order of the first operator is located before an operation order of the second operator, or when the next operator of the first operator is a preset type operator and the next operator of the second operator is not a preset type operator, or when the next operator of the first operator and the next operator of the second operator are both not preset type operators and the operation order of the first operator is located before the operation order of the second operator, it is determined that the influence degree level of the first operator is lower than that of the second operator; the first operator is any one of the operators in the structural block; and the second operator is any one of the operators in the structural block except the first operator.
[0369] Optionally, the processing unit 1703 is specifically configured to: quantize each operator in a current operator set to obtain a current classification model; the current operator set comprises: a target operator in i-1 operators and an i th operator in an order of influence degree levels of the operators from low to high; i is a positive integer less than or equal to m; the current classification model is a model obtained after quantization of the i th operator; when the current classification model meets a first preset condition, the i th operator is determined as the target operator, and a value of i is updated; the first preset condition comprises: a relative gap between a classification result of a to-be-classified picture determined by the current classification model and a classification result of the to-be-classified picture determined by an initial classification model is less than or equal to a preset threshold, and a running time consumption of the classification result determined by the current classification model is less than a current time threshold; the current time threshold is a running time consumption of the classification result determined by a classification model obtained after quantization of each target operator in the current operator set; when the current classification model does not meet the first preset condition, the value of i is updated; and the quantization of each operator in the current operator set is repeated until i is greater than m, to obtain at least one target operator.
[0370] Optionally, the processing unit 1703 is specifically configured to: quantize each target operator in the current operator set according to a target quantization algorithm corresponding to each target operator to obtain a first model; quantize the i th operator according to a plurality of preset quantization algorithms based on the first model to obtain a plurality of second models corresponding to the plurality of preset quantization algorithms one by one; and determine, as the current classification model, a second model that meets a second preset condition from the plurality of second models.
[0371] Optionally, the determination unit 1702 is further configured to determine, as the target quantization algorithm corresponding to the i th operator, a preset quantization algorithm corresponding to a second model that meets the second preset condition.
[0372] Optionally, the processing unit 1703 is specifically configured to: quantize each target operator according to a target quantization algorithm corresponding to each target operator to generate a target classification model.
[0373] Optionally, the second preset condition comprises: a relative difference between the classification result of the to-be-classified picture determined by the second model and the classification result of the to-be-classified picture determined by the initial classification model is less than or equal to a preset threshold, and an operation time consumed by the second model to determine the classification result is less than or equal to a preset time threshold; the processing unit 1703 is specifically configured to: classify the to-be-classified picture based on the second model to obtain operation information of the second model; the operation information comprises the classification result of the to-be-classified picture determined by the second model and the operation time consumed by the second model to determine the classification result; and when the relative difference between the classification result of the to-be-classified picture determined by the second model and the classification result of the to-be-classified picture determined by the initial classification model is less than or equal to the preset threshold, and the operation time consumed by the second model to determine the classification result is less than or equal to the preset time threshold, determine that the second model is the current classification model.
[0374] Based on such understanding, the embodiments of the present disclosure also correspondingly provide an information classification model generation apparatus. Figure 19 The structure schematic diagram of the information classification model generation apparatus provided by the embodiments of the present disclosure is shown. As shown in the figure, Figure 19 the information classification model generation apparatus can comprise: an acquisition unit 1801, a determination unit 1802 and a processing unit 1803;
[0375] The acquisition unit 1801 is configured to acquire an initial classification model used to determine a classification result of to-be-classified information; the initial classification model comprises m operators; any operator is used to perform classification processing associated with information classification on the to-be-classified information; m is a positive integer;
[0376] The determination unit 1802 is configured to determine an influence degree level of the classification processing associated with each operator on the classification result of the to-be-classified information according to an operation order and a type of the classification processing associated with each operator;
[0377] The processing unit 1803 is configured to sequentially perform quantization determination operations on each operator in an order from low to high of the influence degree level corresponding to each operator to obtain at least one target operator; the quantization determination operation is used to determine an operator whose classification model obtained after quantization satisfies a first preset condition as the target operator;
[0378] The processing unit 1803 is further configured to quantize at least one target operator in the initial classification model to generate a target classification model used to determine the classification result of the to-be-classified information.
[0379] Optionally, the initial classification model comprises n structural blocks; each of the structural blocks comprises at least one operator; any of the structural blocks is configured to perform a classification process associated with information classification on the information to be classified; n is a positive integer smaller than m; the determining unit 1802 is specifically configured to: determine an operation sequence of the classification processes associated with the n structural blocks; determine a degree of influence level of the classification processes associated with the n structural blocks on a classification result of the information to be classified according to a first preset rule; determine an operation sequence of the classification processes associated with the at least one operator in each of the structural blocks; determine a degree of influence level of the classification processes associated with the at least one operator in each of the structural blocks on the classification result of the information to be classified according to a second preset rule; and determine a degree of influence level corresponding to each of the operators according to the degree of influence level corresponding to the n structural blocks and the degree of influence level corresponding to the at least one operator in each of the structural blocks.
[0380] Optionally, the first preset rule comprises: when a first structural block and a second structural block in the n structural blocks are both preset type structural blocks, and the operation sequence of the first structural block is located before the operation sequence of the second structural block, or when the first structural block is a preset type structural block and the second structural block is not a preset type structural block, or when the first structural block and the second structural block are both not preset type structural blocks and the operation sequence of the first structural block is located before the operation sequence of the second structural block, it is determined that the degree of influence level of the first structural block is lower than that of the second structural block; the preset type structural block is a structural block comprising a preset type operator; the preset type operator is an operator with a normalization function; the first structural block is any one of the n structural blocks; and the second structural block is any one of the n structural blocks except the first structural block.
[0381] Optionally, the second preset rule comprises: when a first operator and a second operator in a structural block are both preset type operators, and the operation sequence of the first operator is located before the operation sequence of the second operator, or when the first operator is a preset type operator and the second operator is not a preset type operator, or when the first operator and the second operator are both not preset type operators and the operation sequence of the first operator is located before the operation sequence of the second operator, it is determined that the degree of influence level of the first operator is lower than that of the second operator; the first operator is any one of the operators in the structural block; and the second operator is any one of the operators in the structural block except the first operator.
[0382] Optionally, the processing unit 1803 is specifically configured to: quantize each operator in the current operator set to obtain a current classification model; the current operator set includes: target operators in the i th operator and the first i-1 operators in the order of the influence degree grades corresponding to each operator from low to high; i is a positive integer less than or equal to m; the current classification model is a model obtained after quantization of the i th operator; when the current classification model meets a first preset condition, the i th operator is determined as the target operator, and the value of i is updated; the first preset condition includes: a relative gap between a classification result of the to-be-classified information determined by the current classification model and a classification result of the to-be-classified information determined by the initial classification model is less than or equal to a preset threshold, and a running time consumption of the classification result determined by the current classification model is less than a current time threshold; the current time threshold is a running time consumption of the classification result determined by the classification model obtained after quantizing each target operator in the current operator set; when the current classification model does not meet the first preset condition, the value of i is updated; and the quantization of each operator in the current operator set is repeated until i is greater than m, and at least one target operator is obtained.
[0383] Optionally, the processing unit 1803 is specifically configured to: quantize each target operator in the current operator set according to a target quantization algorithm corresponding to each target operator to obtain a first model; quantize the i th operator according to a plurality of preset quantization algorithms based on the first model to obtain a plurality of second models corresponding one by one to the plurality of preset quantization algorithms; and determine a second model meeting a second preset condition in the plurality of second models as the current classification model.
[0384] Optionally, the determination unit 1802 is further configured to determine a preset quantization algorithm corresponding to the second model meeting the second preset condition as the target quantization algorithm corresponding to the i th operator.
[0385] Optionally, the processing unit 1803 is specifically configured to: quantize each target operator according to a target quantization algorithm corresponding to each target operator to generate a target classification model.
[0386] Optionally, the second preset condition comprises: a relative difference between the classification result of the to-be-classified information determined by the second model and the classification result of the to-be-classified information determined by the initial classification model is less than or equal to a preset threshold, and an operation time consumed by the second model to determine the classification result is less than or equal to a preset time threshold; the processing unit 1803 is specifically configured to: classify the to-be-classified information based on the second model to obtain operation information of the second model; the operation information comprises the classification result of the to-be-classified information determined by the second model and the operation time consumed by the second model to determine the classification result; and when the relative difference between the classification result of the to-be-classified information determined by the second model and the classification result of the to-be-classified information determined by the initial classification model is less than or equal to the preset threshold, and the operation time consumed by the second model to determine the classification result is less than or equal to the preset time threshold, determine that the second model is the current classification model.
[0387] As described above, the embodiments of the present disclosure can divide the functional modules of the server according to the method examples described above. Among them, the integrated modules can be realized in the form of hardware or in the form of software functional modules. In addition, it needs to be explained that the division of modules in the embodiments of the present disclosure is illustrative, and is only a logical function division. When actually implemented, there can be another division manner. For example, each functional module can be divided corresponding to each function, or two or more functions can be integrated in one processing module.
[0388] As for the picture classification model generation apparatus and the information classification model generation apparatus in the above embodiments, the specific manner in which each module performs operations and the beneficial effects possessed have been described in detail in the foregoing method embodiments, and will not be described here again.
[0389] The embodiments of the present disclosure also provide a terminal. The terminal can be a mobile phone, a computer, or the like. Figure 20 A structure schematic diagram of a terminal provided by the embodiments of the present disclosure is shown. The terminal can be a picture classification model generation apparatus and / or an information classification model generation apparatus, and can include at least one processor 61, a communication bus 62, a memory 63, and at least one communication interface 64.
[0390] The processor 61 can be a central processing unit (CPU), a micro processing unit, an ASIC, or one or more integrated circuits for controlling program execution of the present disclosure scheme.
[0391] The communication bus 62 can include a path for transmitting information between the above components.
[0392] The communication interface 64, using any transceiver-like mechanism, is used to communicate with other devices and / or computer networks, such as a server, an Ethernet network, a radio access network (RAN), a wireless local area network (WLAN), and so on.
[0393] The memory 63 can be a read-only memory (ROM) or other type of static storage device that can store static information and instructions; a random access memory (RAM), or other type of dynamic storage device that can store information and instructions; an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disk storage, a magnetic disk storage or other magnetic storage devices, or any other medium capable of storing instructions or data that can be accessed by a computer, but not limited to. The memory can exist independently, connected to the processing unit through a bus. The memory can also be integrated with the processing unit.
[0394] The memory 63 is configured to store application codes for implementing the solutions of the present disclosure, and the processor 61 is configured to control the execution of the application codes. The processor 61 is configured to execute the application codes stored in the memory 63, so as to realize the functions in the methods of the present disclosure.
[0395] In a specific implementation, as an example, the processor 61 can include one or more CPUs, such as the CPU0 and the CPU1 in the Figure 20 In a specific implementation, as an example, the processor 61 can include one or more CPUs, such as the CPU0 and the CPU1 in the
[0396] In a specific implementation, as an example, the terminal can include multiple processors, such as the processor 61 and the processor 65 in the Figure 20 In a specific implementation, as an example, the terminal can include multiple processors, such as the processor 61 and the processor 65 in the
[0397] In a specific implementation, as an embodiment, the terminal can further include an input device 66 and an output device 67. The input device 66 and the output device 67 are in communication, and can accept user input in a variety of ways. For example, the input device 66 can be a mouse, a keyboard, a touch screen device, a sensor device, or the like. The output device 67 is in communication with the processor 61, and can display information in a variety of ways. For example, the output device 67 can be a liquid crystal display (LCD), a light emitting diode (LED) display device, or the like.
[0398] Those skilled in the art can understand that, Figure 20 The structure shown in the figure is not a limitation on the terminal, and the terminal can include more or fewer components than shown in the figure, or combine certain components, or use different component arrangements.
[0399] The embodiments of the present disclosure also provide a server. Figure 21 A structure diagram of a server provided by the embodiments of the present disclosure is shown. The server can be a picture classification model generation apparatus and / or an information classification model generation apparatus. The server can have a large difference due to different configurations or performances, and can include one or more processors 71 and one or more memories 72. The memory 72 stores at least one instruction, and the at least one instruction is loaded and executed by the processor 71 to implement the picture classification model generation method provided by each method embodiment and / or the information classification model generation method provided by the embodiments shown above. Of course, the server can also have a wired or wireless network interface, a keyboard, and an input and output interface, and the like, so as to perform input and output. The server can also include other components for implementing device functions, which are not described here.
[0400] The present disclosure also provides a computer readable storage medium including instructions, the computer readable storage medium storing the instructions, and when the instructions in the computer readable storage medium are executed by a processor of a computer device, the computer is enabled to execute the picture classification model generation method provided by the embodiments shown above and / or the information classification model generation method provided by the embodiments shown above. For example, the computer readable storage medium can be a memory 63 including instructions, and the instructions can be executed by the processor 61 of the terminal to complete the above method. For another example, the computer readable storage medium can be a memory 72 including instructions, and the instructions can be executed by the processor 71 of the server to complete the above method. Alternatively, the computer readable storage medium can be a non-transitory computer readable storage medium, for example, the non-transitory computer readable storage medium can be a ROM, a RAM, a CD-ROM, a magnetic tape, a floppy disk, and an optical data storage device, or the like.
[0401] The present disclosure also provides a computer program product, comprising computer instructions which, when run on an electronic device, cause the electronic device to perform the above method of generating a picture classification model Figures 3-10 the method of generating an information classification model shown in any of the accompanying drawings, and / or the above method of generating a picture classification model Figures 11-17 the method of generating an information classification model shown in any of the accompanying drawings.
[0402] Other embodiments of the present disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the features disclosed herein. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure following, in general, the principles of the present disclosure and including such features to the extent that they are not disclosed in the prior art. The specification and examples are to be regarded as illustrative only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0403] It should be understood that the present disclosure is not limited to the precise structures herein described and illustrated in the drawings, and that various modifications and changes can be made without departing from its scope. The scope of the present disclosure is limited only by the claims that follow.
Claims
1. A method for generating an image classification model, characterized in that, include: Obtain an initial classification model to determine the classification result of the image to be classified; The initial classification model includes m operators; Any of the operators described herein is used to perform classification processing associated with image classification for the image to be classified; m is a positive integer; Based on the operation order and type of the classification processing associated with each operator, determine the degree of influence of the classification processing associated with each operator on the classification result of the image to be classified; The operators are sequentially quantized in order of increasing influence level to obtain at least one target operator; the quantization operation is used to determine the operators whose classification models obtained after quantization satisfy the first preset condition as the target operators; The at least one target operator in the initial classification model is quantized to generate a target classification model for determining the classification result of the image to be classified.
2. The image classification model generation method according to claim 1, characterized in that, The initial classification model includes n structural blocks; each structural block includes at least one operator; any structural block is used to perform classification processing associated with image classification for the image to be classified; n is a positive integer less than m; the step of determining the degree of influence of the classification processing associated with each operator on the classification result of the image to be classified, based on the operation order and type of the classification processing associated with each operator, includes: Determine the operational order of the classification processing associated with the n structural blocks; The degree of influence of the classification processing associated with the n structural blocks on the classification result of the image to be classified is determined according to the first preset rule; Determine the operational order of the classification processing associated with at least one of the operators in each of the structural blocks; The degree of influence of the classification processing associated with at least one of the operators in each of the structural blocks on the classification result of the image to be classified is determined according to the second preset rule. The influence level of each operator is determined based on the influence level corresponding to the n structural blocks and the influence level corresponding to at least one operator in each structural block.
3. The image classification model generation method according to claim 2, characterized in that, The first preset rule includes: when both the first and second structural blocks among the n structural blocks are preset type structural blocks and the operation order of the first structural block is before the operation order of the second structural block; or, when the first structural block is the preset type structural block and the second structural block is not the preset type structural block; or, when neither the first nor the second structural block is the preset type structural block and the operation order of the first structural block is before the operation order of the second structural block, the influence level of the first structural block is determined to be lower than that of the second structural block; the preset type structural block is a structural block including a preset type operator; the preset type operator is an operator with normalization function; the first structural block is any one of the n structural blocks; the second structural block is any one of the n structural blocks other than the first structural block.
4. The image classification model generation method according to claim 3, characterized in that, The second preset rule includes: when the operator following the first operator and the operator following the second operator in the structure block are both operators of the preset type, and the operation order of the first operator is before the operation order of the second operator; or, when the operator following the first operator is the preset type operator and the operator following the second operator is not the preset type operator; or, when neither the operator following the first operator nor the operator following the second operator is the preset type operator, and the operation order of the first operator is before the operation order of the second operator, the influence level of the first operator is determined to be lower than that of the second operator; the first operator is any operator in the structure block; the second operator is any operator in the structure block other than the first operator.
5. The image classification model generation method according to claim 1, characterized in that, The step of performing quantization judgment operations on each of the operators in ascending order of their respective influence levels to obtain at least one target operator includes: Each operator in the current set of operators is quantized to obtain the current classification model; the current set of operators includes: the i-th operator in the order of influence level from low to high and the target operator in the first i-1 operators; i is a positive integer less than or equal to m; the current classification model is the quantized model corresponding to the i-th operator; When the current classification model meets the first preset condition, the i-th operator is determined as the target operator, and the value of i is updated; the first preset condition includes: the relative difference between the classification result of the image to be classified determined by the current classification model and the classification result of the image to be classified determined by the initial classification model is less than or equal to a preset threshold, and the running time of the current classification model to determine the classification result is less than the current time threshold; the current time threshold is the running time of the classification model to determine the classification result after quantizing each target operator in the current operator set; When the current classification model does not meet the first preset condition, update the value of i; The quantization of each operator in the current set of operators is repeated until i is greater than m, at least one of the target operators is obtained.
6. The image classification model generation method according to claim 5, characterized in that, The step of quantizing each operator in the current set of operators to obtain the current classification model includes: Based on the target quantization algorithm corresponding to each target operator in the current operator set, each target operator is quantized to obtain the first model; Based on the first model, the i-th operator is quantized according to multiple preset quantization algorithms to obtain multiple second models that correspond one-to-one with the multiple preset quantization algorithms; The second model that meets the second preset condition among the plurality of second models is determined as the current classification model.
7. The image classification model generation method according to claim 6, characterized in that, Also includes: The preset quantization algorithm corresponding to the second model that meets the second preset condition is determined as the target quantization algorithm corresponding to the i-th operator.
8. The image classification model generation method according to claim 7, characterized in that, The step of quantizing at least one target operator in the initial classification model to generate a target classification model for determining the classification result of the image to be classified includes: Based on the target quantization algorithm corresponding to each target operator, each target operator is quantized to generate the target classification model.
9. The image classification model generation method according to claim 6, characterized in that, The second preset condition includes: the relative difference between the classification result of the image to be classified determined by the second model and the classification result of the image to be classified determined by the initial classification model is less than or equal to the preset threshold, and the running time of the second model to determine the classification result is less than or equal to the preset time threshold; determining the second model that meets the second preset condition among the plurality of second models as the current classification model includes: The image to be classified is classified based on the second model to obtain the running information of the second model; the running information includes the classification result of the image to be classified determined by the second model and the running time of the second model in determining the classification result; When the relative difference between the classification result of the image to be classified determined by the second model and the classification result of the image to be classified determined by the initial classification model is less than or equal to the preset threshold, and the running time of the second model to determine the classification result is less than or equal to the preset time threshold, the second model is determined to be the current classification model.
10. A method for generating an information classification model, characterized in that, include: Obtain an initial classification model to determine the classification result of the information to be classified; The initial classification model includes m operators; Each of the operators is used to perform classification processing associated with information classification on the information to be classified; m is a positive integer; the information to be classified includes text information or video information; Based on the operation order and type of the classification processing associated with each operator, determine the degree of influence of the classification processing associated with each operator on the classification result of the information to be classified. The operators are sequentially quantized in order of increasing influence level to obtain at least one target operator; the quantization operation is used to determine the operators whose classification models obtained after quantization satisfy the first preset condition as the target operators; The at least one target operator in the initial classification model is quantized to generate a target classification model for determining the classification result of the information to be classified.
11. The information classification model generation method according to claim 10, characterized in that, The step of performing quantization judgment operations on each of the operators in ascending order of their respective influence levels to obtain at least one target operator includes: Each operator in the current set of operators is quantized to obtain the current classification model; the current set of operators includes: the i-th operator in the order of influence level from low to high and the target operator in the first i-1 operators; i is a positive integer less than or equal to m; the current classification model is the quantized model corresponding to the i-th operator; When the current classification model meets the first preset condition, the i-th operator is determined as the target operator, and the value of i is updated; the first preset condition includes: the relative difference between the classification result of the information to be classified determined by the current classification model and the classification result of the information to be classified determined by the initial classification model is less than or equal to a preset threshold, and the running time of the current classification model to determine the classification result is less than the current time threshold; the current time threshold is the running time of the classification model to determine the classification result after quantizing each target operator in the current operator set; When the current classification model does not meet the first preset condition, update the value of i; The quantization of each operator in the current set of operators is repeated until i is greater than m, at least one of the target operators is obtained.
12. An image classification model generation device, characterized in that, include: Acquisition unit, determination unit, and processing unit; The acquisition unit is configured to acquire an initial classification model for determining the classification result of the image to be classified; The initial classification model includes m operators; each of the operators is used to perform classification processing associated with image classification for the image to be classified; m is a positive integer; The determining unit is configured to determine the degree of influence of the classification processing associated with each operator on the classification result of the image to be classified, based on the operation order and type of the classification processing associated with each operator. The processing unit is configured to perform quantization judgment operations on each of the operators in ascending order of their respective influence levels to obtain at least one target operator; the quantization judgment operation is used to determine the operators whose quantized classification models satisfy a first preset condition as the target operators; The processing unit is further configured to quantize at least one target operator in the initial classification model to generate a target classification model for determining the classification result of the image to be classified.
13. An information classification model generation device, characterized in that, include: Acquisition unit, determination unit, and processing unit; The acquisition unit is configured to acquire an initial classification model for determining the classification result of the information to be classified; The initial classification model includes m operators; each operator is used to perform classification processing related to information classification on the information to be classified; m is a positive integer; the information to be classified includes text information or video information; The determining unit is configured to determine the degree of influence of the classification processing associated with each operator on the classification result of the information to be classified, based on the operation order and type of the classification processing associated with each operator. The processing unit is configured to perform quantization judgment operations on each of the operators in ascending order of their respective influence levels to obtain at least one target operator; the quantization judgment operation is used to determine the operators whose quantized classification models satisfy a first preset condition as the target operators; The processing unit is further configured to quantize at least one target operator in the initial classification model to generate a target classification model for determining the classification result of the information to be classified.
14. An electronic device, characterized in that, The electronic device includes: processor; Memory used to store the processor's executable instructions; The processor is configured to execute the instructions to implement the image classification model generation method as described in any one of claims 1-9 or the information classification model generation method as described in any one of claims 10-11.
15. A computer-readable storage medium storing instructions thereon, characterized in that, When the instructions in the computer-readable storage medium are executed by the processor of the electronic device, the electronic device is able to perform the image classification model generation method as described in any one of claims 1-9 or the information classification model generation method as described in any one of claims 10-11.
Citation Information
Patent Citations
Operation method of neural network model, chip, electronic equipment and storage medium
CN120144258A