CN115994318A - Picture and information classification model generation method, device, equipment and storage medium - Google Patents

Picture and information classification model generation method, device, equipment and storage medium Download PDF

Info

Publication number
CN115994318A
CN115994318A CN202310063834.6A CN202310063834A CN115994318A CN 115994318 A CN115994318 A CN 115994318A CN 202310063834 A CN202310063834 A CN 202310063834A CN 115994318 A CN115994318 A CN 115994318A
Authority
CN
China
Prior art keywords
operator
classification
classification model
model
target
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310063834.6A
Other languages
Chinese (zh)
Inventor
王思凯
叶旭诚
任永雄
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Dajia Internet Information Technology Co Ltd
Original Assignee
Beijing Dajia Internet Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Dajia Internet Information Technology Co Ltd filed Critical Beijing Dajia Internet Information Technology Co Ltd
Priority to CN202310063834.6A priority Critical patent/CN115994318A/en
Publication of CN115994318A publication Critical patent/CN115994318A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The disclosure relates to a method, a device, equipment and a storage medium for generating a picture and information classification model, which relate to the technical field of computers and can ensure the effect of quantization processing on the model. The method for generating the picture classification model comprises the following steps: acquiring an initial classification model for determining a classification result of a picture to be classified; the initial classification model comprises m operators; determining the degree of influence 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 the type of the classification processing associated with each operator; sequentially executing quantization judgment operation on each operator according to the order of the corresponding influence degree level of each operator from low to high to obtain at least one target operator; the quantization judgment operation is used for determining an operator of the classification model obtained after quantization meeting 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 picture to be classified.

Description

Picture and information classification model generation method, device, equipment and storage medium
Technical Field
The disclosure relates to the field of computer technology, and in particular, to a method, a device, equipment and a storage medium for generating a picture and information classification model.
Background
Business applications typically require support that relies on business classification models, such as classification models for pictures, text, video, etc., where floating-point type parameters are prevalent, which is likely to result in significant time, computational and memory resources being consumed for the operation of the business classification model.
In order to reduce the running consumption of the service classification model, thereby improving the implementation speed of the service application and reducing the running load of the service application, the related technology proposes that the service classification model can be quantized, but the quantization processing of the service classification model is often more dependent on the experience of an algorithm engineer, and the quantization quality and the quantization effect are difficult to ensure, so that the running speed and the implementation effect of the service application are influenced.
Disclosure of Invention
The method, the device, the equipment and the storage medium for generating the picture and information classification model can ensure the quantization effect of the quantization processing of the model and can improve the running speed of the business application without affecting the implementation effect of the business application.
The technical scheme of the embodiment of the disclosure is as follows:
according to a first aspect of an embodiment of the present disclosure, there is provided a method for generating a picture classification model, including: acquiring an initial classification model for determining a classification result of a picture to be classified; the initial classification model comprises m operators; any operator is used for carrying out classification processing associated with picture classification aiming at pictures to be classified; m is a positive integer; determining the degree of influence 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 the type of the classification processing associated with each operator; sequentially executing quantization judgment operation on each operator according to the order of the corresponding influence degree level of each operator from low to high to obtain at least one target operator; the quantization judgment operation is used for determining an operator of the classification model obtained after quantization meeting 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 picture to be classified.
Optionally, the initial classification model includes n structural blocks; each structure block includes at least one operator; any structure block is used for carrying out classification processing associated with picture classification aiming at pictures to be classified; n is a positive integer less than m; according to the operation sequence and the type of the classification processing associated with each operator, the specific method for determining the influence degree level of the classification processing associated with each operator on the classification result of the picture to be classified comprises the following steps: determining the operation sequence of classification processing associated with n structural blocks; determining 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; determining the operation sequence of 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 picture to be classified according to a second preset rule; and determining the influence degree grade corresponding to each operator according to the influence degree grade corresponding to the n structural blocks and the influence degree grade corresponding to at least one operator in each structural block.
Optionally, the first preset rule includes: when the first structural block and the second structural block in the n structural blocks are both the preset type structural blocks and the operation sequence of the first structural block is positioned before the operation sequence 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 the first structural block and the second structural block are not the preset type structural block and the operation sequence of the first structural block is positioned before the operation sequence of the second structural block, determining that the influence degree level of the first structural block is lower than that of the second structural block; the preset type structure block is a structure block comprising a preset type operator; the operator with the preset type is an operator with a normalization function; the first structural block is any one of n structural blocks; the second structural block is any one of the n structural blocks except the first structural block.
Optionally, the second preset rule includes: determining that the degree of influence level of the first operator is lower than that of the second operator 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 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; the first operator is any operator in the structural block; the second operator is any one of the structural blocks except the first operator.
Optionally, the specific method for obtaining at least one target operator sequentially executes quantization judgment operation on each operator according to the order of the corresponding influence degree level of each operator from low to high includes: quantizing each operator in the current operator set to obtain a current classification model; the current operator set includes: the corresponding influence degree level of each operator is from the ith operator and the target operator in the previous i-1 operators in the sequence from low to high; i is a positive integer less than or equal to m; the current classification model is a quantized model corresponding to the ith operator; when the current classification model accords with a first preset condition, determining an ith operator as a target operator, and updating the value of i; the first preset condition includes: the relative difference between the classification result of the picture to be classified determined by the current classification model and the classification result of the picture to be classified determined by the initial classification model is smaller than or equal to a preset threshold value, and the running time of the current classification model to the classification result is smaller than a current time threshold value; the current time length threshold value is used for determining the operation time consumption of the classification result for the classification model obtained after each target operator in the current operator set is quantized; updating the value of i when the current classification model does not accord with the first preset condition; and repeatedly quantizing each operator in the current operator set until i is greater than m, and obtaining at least one target operator.
Optionally, the specific method for quantifying each operator in the current operator set to obtain the current classification model includes: quantizing each target operator according to a target quantization algorithm corresponding to each target operator in the current operator set to obtain a first model; based on the first model, respectively quantizing the ith operator according to a plurality of preset quantization algorithms to obtain a plurality of second models which are in one-to-one correspondence with the preset quantization algorithms; and determining a second model meeting a second preset condition from the plurality of second models as a current classification model.
Optionally, the method for generating the picture classification model further includes: and determining a preset quantization algorithm corresponding to the second model meeting the second preset condition as a target quantization algorithm corresponding to the ith operator.
Optionally, the specific method for quantizing at least one target operator in the initial classification model to generate the target classification model for determining the classification result of the picture to be classified includes: and quantizing each target operator according to a target quantization algorithm corresponding to each target operator to generate a target classification model.
Optionally, the second preset condition includes: the relative difference 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 smaller than or equal to a preset threshold value, and the running time of the second model to the classification result is smaller than or equal to a preset time length threshold value; the specific method for determining the second model meeting the second preset condition in the plurality of second models as the current classification model comprises the following steps: classifying the pictures to be classified based on the second model to obtain operation information of the second model; the operation information comprises a classification result of the picture to be classified, which is determined by the second model, and operation time consumption of the classification result, which is determined by the second model; and when the relative difference between the classification result of the picture to be classified, which is determined by the second model, and the classification result of the picture to be classified, which is determined by the initial classification model, is smaller than or equal to a preset threshold value, and the running time consumption of the classification result, which is determined by the second model, is smaller than or equal to a preset time length threshold value, determining the second model as the current classification model.
According to a second aspect of the embodiments of the present disclosure, there is provided an information classification model generating method, including: acquiring an initial classification model for determining a classification result of information to be classified; the initial classification model comprises m operators; any operator is used for carrying out classification processing associated with information classification aiming at the information to be classified; m is a positive integer; determining 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 sequence and the type of the classification processing associated with each operator; sequentially executing quantization judgment operation on each operator according to the order of the corresponding influence degree level of each operator from low to high to obtain at least one target operator; the quantization judgment operation is used for determining an operator of the classification model obtained after quantization meeting 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 information to be classified.
Optionally, the initial classification model includes n structural blocks; each structure block includes at least one operator; any structure block is used for carrying out classification processing associated with information classification on the information to be classified; n is a positive integer less than m; according to the operation sequence and the type of the classification processing associated with each operator, the specific method for determining the influence degree level of the classification processing associated with each operator on the classification result of the information to be classified comprises the following steps: determining the operation sequence of classification processing associated with n structural blocks; determining the influence degree level of the classification processing associated with the n structural blocks on the classification result of the information to be classified according to a first preset rule; determining the operation sequence of 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 information to be classified according to a second preset rule; and determining the influence degree grade corresponding to each operator according to the influence degree grade corresponding to the n structural blocks and the influence degree grade corresponding to at least one operator in each structural block.
Optionally, the first preset rule includes: when the first structural block and the second structural block in the n structural blocks are both the preset type structural blocks and the operation sequence of the first structural block is positioned before the operation sequence 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 the first structural block and the second structural block are not the preset type structural block and the operation sequence of the first structural block is positioned before the operation sequence of the second structural block, determining that the influence degree level of the first structural block is lower than that of the second structural block; the preset type structure block is a structure block comprising a preset type operator; the operator with the preset type is an operator with a normalization function; the first structural block is any one of n structural blocks; the second structural block is any one of the n structural blocks except the first structural block.
Optionally, the second preset rule includes: determining that the degree of influence level of the first operator is lower than that of the second operator 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 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; the first operator is any operator in the structural block; the second operator is any one of the structural blocks except the first operator.
Optionally, the specific method for obtaining at least one target operator sequentially executes quantization judgment operation on each operator according to the order of the corresponding influence degree level of each operator from low to high includes: quantizing each operator in the current operator set to obtain a current classification model; the current operator set includes: the corresponding influence degree level of each operator is from the ith operator and the target operator in the previous i-1 operators in the sequence from low to high; i is a positive integer less than or equal to m; the current classification model is a quantized model corresponding to the ith operator; when the current classification model accords with a first preset condition, determining an ith operator as a target operator, and updating the value of i; 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 smaller than or equal to a preset threshold value, and the running time of the current classification model to the classification result is smaller than a current time threshold value; the current time length threshold value is used for determining the operation time consumption of the classification result for the classification model obtained after each target operator in the current operator set is quantized; updating the value of i when the current classification model does not accord with the first preset condition; and repeatedly quantizing each operator in the current operator set until i is greater than m, and obtaining at least one target operator.
Optionally, the specific method for quantifying each operator in the current operator set to obtain the current classification model includes: quantizing each target operator according to a target quantization algorithm corresponding to each target operator in the current operator set to obtain a first model; based on the first model, respectively quantizing the ith operator according to a plurality of preset quantization algorithms to obtain a plurality of second models which are in one-to-one correspondence with the preset quantization algorithms; and determining a second model meeting a second preset condition from the plurality of second models as a current classification model.
Optionally, the information classification model generating method further includes: and determining a preset quantization algorithm corresponding to the second model meeting the second preset condition as a target quantization algorithm corresponding to the ith operator.
Optionally, the specific method for quantizing at least one target operator in the initial classification model to generate the target classification model for determining the classification result of the information to be classified includes: and quantizing each target operator according to a target quantization algorithm corresponding to each target operator to generate a target classification model.
Optionally, the second preset condition includes: the relative difference 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 smaller than or equal to a preset threshold value, and the running time of the second model to the classification result is smaller than or equal to a preset time length threshold value; the specific method for determining the second model meeting the second preset condition in the plurality of second models as the current classification model comprises the following steps: classifying the information to be classified based on the second model to obtain operation information of the second model; the operation information comprises a classification result of the information to be classified determined by the second model and operation time consumption from the second model to the classification result; and when the relative difference 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 smaller than or equal to a preset threshold value and the running time consumption of the classification result determined by the second model is smaller than or equal to a preset time length threshold value, determining the second model as the current classification model.
According to a third aspect of the embodiments of the present disclosure, there is provided a picture classification model generating apparatus, including: the device comprises an acquisition unit, a determination unit and a processing unit; an acquisition unit configured to acquire an initial classification model for determining a classification result of a picture to be classified; the initial classification model comprises m operators; any operator is used for carrying out classification processing associated with picture classification aiming at pictures to be classified; m is a positive integer; a determining unit configured to determine, according to an operation order and a type of the classification processing associated with each operator, a degree of influence level of the classification processing associated with each operator on a classification result of the picture to be classified; the processing unit is configured to sequentially execute quantization judgment operation on each operator according to the order of the corresponding influence degree level of each operator from low to high to obtain at least one target operator; the quantization judgment operation is used for determining an operator of the classification model obtained after quantization meeting a first preset condition as a target operator; the processing unit is further configured to quantize at least one target operator in the initial classification model to generate a target classification model used for determining a classification result of the picture to be classified.
Optionally, the initial classification model includes n structural blocks; each structure block includes at least one operator; any structure block is used for carrying out classification processing associated with picture classification aiming at pictures to be classified; n is a positive integer less than m; the determining unit is specifically configured to: determining the operation sequence of classification processing associated with n structural blocks; determining 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; determining the operation sequence of 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 picture to be classified according to a second preset rule; and determining the influence degree grade corresponding to each operator according to the influence degree grade corresponding to the n structural blocks and the influence degree grade corresponding to at least one operator in each structural block.
Optionally, the first preset rule includes: when the first structural block and the second structural block in the n structural blocks are both the preset type structural blocks and the operation sequence of the first structural block is positioned before the operation sequence 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 the first structural block and the second structural block are not the preset type structural block and the operation sequence of the first structural block is positioned before the operation sequence of the second structural block, determining that the influence degree level of the first structural block is lower than that of the second structural block; the preset type structure block is a structure block comprising a preset type operator; the operator with the preset type is an operator with a normalization function; the first structural block is any one of n structural blocks; the second structural block is any one of the n structural blocks except the first structural block.
Optionally, the second preset rule includes: determining that the degree of influence level of the first operator is lower than that of the second operator 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 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; the first operator is any operator in the structural block; the second operator is any one of the structural blocks except the first operator.
Optionally, the processing unit is specifically configured to: quantizing each operator in the current operator set to obtain a current classification model; the current operator set includes: the corresponding influence degree level of each operator is from the ith operator and the target operator in the previous i-1 operators in the sequence from low to high; i is a positive integer less than or equal to m; the current classification model is a quantized model corresponding to the ith operator; when the current classification model accords with a first preset condition, determining an ith operator as a target operator, and updating the value of i; the first preset condition includes: the relative difference between the classification result of the picture to be classified determined by the current classification model and the classification result of the picture to be classified determined by the initial classification model is smaller than or equal to a preset threshold value, and the running time of the current classification model to the classification result is smaller than a current time threshold value; the current time length threshold value is used for determining the operation time consumption of the classification result for the classification model obtained after each target operator in the current operator set is quantized; updating the value of i when the current classification model does not accord with the first preset condition; and repeatedly quantizing each operator in the current operator set until i is greater than m, and obtaining at least one target operator.
Optionally, the processing unit is specifically configured to: quantizing each target operator according to a target quantization algorithm corresponding to each target operator in the current operator set to obtain a first model; based on the first model, respectively quantizing the ith operator according to a plurality of preset quantization algorithms to obtain a plurality of second models which are in one-to-one correspondence with the preset quantization algorithms; and determining a second model meeting a second preset condition from the plurality of second models as a current classification model.
Optionally, the determining unit is further configured to determine a preset quantization algorithm corresponding to the second model meeting the second preset condition as a target quantization algorithm corresponding to the ith operator.
Optionally, the processing unit is specifically configured to: and quantizing each target operator according to a target quantization algorithm corresponding to each target operator to generate a target classification model.
Optionally, the second preset condition includes: the relative difference 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 smaller than or equal to a preset threshold value, and the running time of the second model to the classification result is smaller than or equal to a preset time length threshold value; a processing unit, specifically configured to: classifying the pictures to be classified based on the second model to obtain operation information of the second model; the operation information comprises a classification result of the picture to be classified, which is determined by the second model, and operation time consumption of the classification result, which is determined by the second model; and when the relative difference between the classification result of the picture to be classified, which is determined by the second model, and the classification result of the picture to be classified, which is determined by the initial classification model, is smaller than or equal to a preset threshold value, and the running time consumption of the classification result, which is determined by the second model, is smaller than or equal to a preset time length threshold value, determining the second model as the current classification model.
According to a fourth aspect of the embodiments of the present disclosure, there is provided an information classification model generating apparatus, including: the device comprises an acquisition unit, a determination unit and a processing unit; an acquisition unit configured to acquire an initial classification model for determining a classification result of the information to be classified; the initial classification model comprises m operators; any operator is used for carrying out classification processing associated with information classification aiming at the information to be classified; m is a positive integer; a determining unit configured to determine a degree of influence level of the classification processing associated with each operator on the classification result of the information to be classified, according to an operation order and a type of the classification processing associated with each operator; the processing unit is configured to sequentially execute quantization judgment operation on each operator according to the order of the corresponding influence degree level of each operator from low to high to obtain at least one target operator; the quantization judgment operation is used for determining an operator of the classification model obtained after quantization meeting a first preset condition as a target operator; the processing unit is further configured to quantize at least one target operator in the initial classification model, and generate a target classification model used for determining a classification result of the information to be classified.
Optionally, the initial classification model includes n structural blocks; each structure block includes at least one operator; any structure block is used for carrying out classification processing associated with information classification on the information to be classified; n is a positive integer less than m; the determining unit is specifically configured to: determining the operation sequence of classification processing associated with n structural blocks; determining the influence degree level of the classification processing associated with the n structural blocks on the classification result of the information to be classified according to a first preset rule; determining the operation sequence of 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 information to be classified according to a second preset rule; and determining the influence degree grade corresponding to each operator according to the influence degree grade corresponding to the n structural blocks and the influence degree grade corresponding to at least one operator in each structural block.
Optionally, the first preset rule includes: when the first structural block and the second structural block in the n structural blocks are both the preset type structural blocks and the operation sequence of the first structural block is positioned before the operation sequence 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 the first structural block and the second structural block are not the preset type structural block and the operation sequence of the first structural block is positioned before the operation sequence of the second structural block, determining that the influence degree level of the first structural block is lower than that of the second structural block; the preset type structure block is a structure block comprising a preset type operator; the operator with the preset type is an operator with a normalization function; the first structural block is any one of n structural blocks; the second structural block is any one of the n structural blocks except the first structural block.
Optionally, the second preset rule includes: determining that the degree of influence level of the first operator is lower than that of the second operator 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 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; the first operator is any operator in the structural block; the second operator is any one of the structural blocks except the first operator.
Optionally, the processing unit is specifically configured to: quantizing each operator in the current operator set to obtain a current classification model; the current operator set includes: the corresponding influence degree level of each operator is from the ith operator and the target operator in the previous i-1 operators in the sequence from low to high; i is a positive integer less than or equal to m; the current classification model is a quantized model corresponding to the ith operator; when the current classification model accords with a first preset condition, determining an ith operator as a target operator, and updating the value of i; 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 smaller than or equal to a preset threshold value, and the running time of the current classification model to the classification result is smaller than a current time threshold value; the current time length threshold value is used for determining the operation time consumption of the classification result for the classification model obtained after each target operator in the current operator set is quantized; updating the value of i when the current classification model does not accord with the first preset condition; and repeatedly quantizing each operator in the current operator set until i is greater than m, and obtaining at least one target operator.
Optionally, the processing unit is specifically configured to: quantizing each target operator according to a target quantization algorithm corresponding to each target operator in the current operator set to obtain a first model; based on the first model, respectively quantizing the ith operator according to a plurality of preset quantization algorithms to obtain a plurality of second models which are in one-to-one correspondence with the preset quantization algorithms; and determining a second model meeting a second preset condition from the plurality of second models as a current classification model.
Optionally, the determining unit is further configured to determine a preset quantization algorithm corresponding to the second model meeting the second preset condition as a target quantization algorithm corresponding to the ith operator.
Optionally, the processing unit is specifically configured to: and quantizing each target operator according to a target quantization algorithm corresponding to each target operator to generate a target classification model.
Optionally, the second preset condition includes: the relative difference 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 smaller than or equal to a preset threshold value, and the running time of the second model to the classification result is smaller than or equal to a preset time length threshold value; a processing unit, specifically configured to: classifying the information to be classified based on the second model to obtain operation information of the second model; the operation information comprises a classification result of the information to be classified determined by the second model and operation time consumption from the second model to the classification result; and when the relative difference 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 smaller than or equal to a preset threshold value and the running time consumption of the classification result determined by the second model is smaller than or equal to a preset time length threshold value, determining the second model as the current classification model.
According to a fifth aspect of embodiments of the present disclosure, there is provided an electronic device, which may include: a processor and a memory for storing processor-executable instructions; wherein the processor is configured to execute the instructions to implement any of the optional map tile classification model generation methods of the first aspect above or any of the optional information classification model generation methods of the second aspect above.
According to a sixth aspect of embodiments of the present disclosure, there is provided a computer-readable storage medium having instructions stored thereon, which when executed by a processor of an electronic device, enable the electronic device to perform any one of the optional map classification model generation methods of the first aspect or any one of the optional information classification model generation methods of the second aspect.
According to a seventh aspect of embodiments of the present disclosure, there is provided a computer program product comprising computer instructions which, when run on a processor on an electronic device, cause the electronic device to perform the picture classification model generation method as optional in any of the first aspects or the information classification model generation method as optional in any of the second aspects.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
The technical scheme provided by the embodiment of the disclosure at least brings the following beneficial effects:
based on any one of the above aspects, in the method for generating a picture classification model provided by the present disclosure, after an initial classification model for determining a classification result of a picture to be classified is obtained, an influence degree level of classification processing associated with each operator on the classification result of the picture to be classified may be determined according to an operation sequence and a type of classification processing associated with each operator in the initial classification model, and further quantization judgment operations may be sequentially performed on each operator according to an order from low to high of the influence degree level corresponding to each operator, so as to obtain at least one target operator, thereby performing quantization on each target operator in the initial classification model to generate a target classification model.
Since the m operators in the initial classification model have different degrees of influence on the classification result of the picture to be classified, the operators have different influences on the precision of the initial classification model after being quantized. Based on the method, after 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 is determined, as many target operators as possible can be selected from m operators according to the order of the influence degree level corresponding to each operator from low to high, so that a plurality of target operators can be further quantized, and a target classification model is generated. Compared with the mode that the general technology relies on manual selection of partial parameters to quantize, the method and the device quantize the models in a mode that the electronic equipment judges the degree of influence one by one, not only can save labor efficiency, but also can ensure that as many operators in the initial classification model are quantized to obtain the target classification model, so that the operation speed of the business application can be improved while the implementation effect of the business application is not influenced.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the disclosure and together with the description, serve to explain the principles of the disclosure and do not constitute an undue limitation on the disclosure.
Fig. 1 illustrates a schematic structural diagram of a system for generating a picture classification model according to an embodiment of the present disclosure;
fig. 2 illustrates a schematic structural diagram of a terminal provided in an embodiment of the present disclosure;
fig. 3 is a schematic flow chart of a method for generating a picture classification model according to an embodiment of the disclosure;
FIG. 4 is a flowchart illustrating a method for generating a classification model of a picture according to an embodiment of the present disclosure;
FIG. 5 is a flowchart illustrating a method for generating a classification model of a picture according to an embodiment of the present disclosure;
FIG. 6 is a flowchart illustrating a method for generating a classification model of a picture according to an embodiment of the present disclosure;
fig. 7 is a flowchart illustrating another method for generating a picture classification model according to an embodiment of the present disclosure;
FIG. 8 is a flowchart illustrating a method for generating a classification model of a picture according to an embodiment of the present disclosure;
FIG. 9 is a flowchart illustrating a method for generating a classification model of a picture according to an embodiment of the present disclosure;
FIG. 10 is a flowchart illustrating yet another method for generating a classification model of a picture according to an embodiment of the present disclosure;
FIG. 11 is a schematic flow chart of a method for generating an information classification model according to an embodiment of the disclosure;
FIG. 12 is a flowchart of another method for generating an information classification model according to an embodiment of the disclosure;
FIG. 13 is a flowchart of another method for generating an information classification model according to an embodiment of the disclosure;
FIG. 14 is a flow chart illustrating yet another method for generating an information classification model according to an embodiment of the present disclosure;
FIG. 15 is a flowchart of another method for generating an information classification model according to an embodiment of the present disclosure;
FIG. 16 is a flowchart of another method for generating an information classification model according to an embodiment of the present disclosure;
FIG. 17 is a flowchart of another method for generating an information classification model according to an embodiment of the present disclosure;
fig. 18 shows a schematic structural diagram of a picture classification model generating apparatus according to an embodiment of the present disclosure;
fig. 19 is a schematic structural diagram of an information classification model generating device according to an embodiment of the present disclosure;
fig. 20 is a schematic structural view of still another terminal according to an embodiment of the present disclosure;
Fig. 21 shows a schematic structural diagram of a server according to an embodiment of the present disclosure.
Detailed Description
In order to enable those skilled in the art to better understand the technical solutions of the present disclosure, the technical solutions of the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings.
It should be noted that the terms "first," "second," and the like in the description and claims of the present disclosure and in the foregoing figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the disclosure described herein may be capable of operation in sequences other than those illustrated or described herein. The implementations described in the following exemplary examples are not representative of all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with some aspects of the present disclosure as detailed in the accompanying claims.
It will be further understood that the terms "comprises" and/or "comprising," when used in this specification, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, and/or components.
The data referred to in this disclosure may be data authorized by the user or sufficiently authorized by the parties.
The following explains related concepts related to the embodiments of the present disclosure for easy understanding.
1. AI model
The AI model is a mathematical model (e.g., neural network) used in implementing AI by machine learning, and can be used in various application scenarios such as biology, medical treatment, traffic, etc.: when the target event is prediction of the sensitivity of the cell line to the drug, various kinds of data such as gene mutation data and gene expression data of the cell line may be input to the AI model to predict the sensitivity of the cell line to the drug, etc. using the AI model.
The AI model is essentially an algorithm that includes a large number of parameters and calculation formulas (or rules of calculation). Among the large number of parameters that AI models include are typically floating point data.
AI models can be generally seen as being made up of a plurality of building blocks (blocks). In constructing the AI model, a convolutional neural network (convolutional neural networks, CNN) structure, a transducer structure, or the like may be generally used. For example, a transducer structure is typically composed of 12 building blocks. Also, the matrix multiplication (general matrix multiplication, GEMM) operation is the main calculation method for processing data by the AI model.
And quantizing the floating point type data in the AI model, namely quantizing the floating point type data into fixed point type data.
The quantization effect of the AI model is often affected by the structure of the model itself, the data type of the parameters, and the complex factors such as the hardware and software characteristics of the co-processor such as the deployed GPU.
2. And (5) a structural block.
The structure block is a unit composed of operators (operators) for realizing basic operations such as convolution operation and pooling operation. The plurality of building blocks may form an AI model according to certain computational logic.
3. Operator
An operator is a mapping of one function space to another function space for implementing basic operations such as convolution operations and pooling operations on data. The AI model includes parameters and computational formulas, specifically deployed in a plurality of operators that make up the AI model. That is, the operator is composed of parameters and a calculation formula.
Currently, to ease the burden of a particular processing task of a microprocessor, a heterogeneous processing unit may be generally configured for the microprocessor. The heterogeneous processing unit may be a coprocessor. A coprocessor may be a hardware circuit block that may be used to process specific algorithms or logic operations, which may be understood as a special accelerator. Also, to achieve faster computation speeds, coprocessors can typically handle specific algorithms or logic operations based on single instruction multiple data (single instruction multiple data, SIMD) technology.
Often different types of coprocessors may be selected when handling different scene requirements. For example, a math co-processor (math co-processor) may control digital processing, and a graphics processor (graphics processing unit, GPU) may process video rendering, etc. In order to improve performance such as calculation speed and accuracy when the coprocessor processes the service, a service classification model, that is, an AI model having a service classification function, may be generally deployed on the coprocessor. For example, business classification models for pictures, business classification models for text, and business classification models for video, where floating point type parameters are prevalent, are likely to result in significant time, computing, and memory resources being consumed for the operation of the business classification models.
In the general technology, in order to reduce the running consumption of the service classification model, thereby improving the implementation speed of the service application and reducing the running load of the service application, it is proposed that the service classification model can be quantized, but the quantization processing of the service classification model is often more dependent on the experience of an algorithm engineer, and the quantization quality and the quantization effect are difficult to ensure, so that the running speed and the implementation effect of the service application are affected.
In order to solve the above-mentioned problems, an embodiment of the present disclosure provides a method for generating a picture classification model, after an electronic device obtains an initial classification model for determining a classification result of a picture to be classified, the electronic device may determine, according to an operation sequence and a type of classification processing associated with each operator in the initial classification model, an influence degree level of classification processing associated with each operator on the classification result of the picture to be classified, and further sequentially perform quantization judgment operations on each operator according to an order from low to high of the influence degree level corresponding to each operator, so as to obtain at least one target operator, thereby performing quantization on each target operator in the initial classification model to generate the target classification model.
Since the m operators in the initial classification model have different degrees of influence on the classification result of the picture to be classified, the operators have different influences on the precision of the initial classification model after being quantized. Based on the method, after 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 is determined, as many target operators as possible can be selected from m operators according to the order of the influence degree level corresponding to each operator from low to high, so that a plurality of target operators can be further quantized, and a target classification model is generated. Compared with the mode that the general technology relies on manual selection of partial parameters to quantize, the method and the device quantize the models in a mode that the electronic equipment judges the degree of influence one by one, not only can save labor efficiency, but also can ensure that as many operators in the initial classification model are quantized to obtain the target classification model, so that the operation speed of the business application can be improved while the implementation effect of the business application is not influenced.
In the quantization of the model, two modes of quantization (post training quantization, PTQ) after training and Quantization (QAT) introduced in training are generally adopted. When the PTQ mode is adopted, the model of various types can be realized by automatically calling forward methods, and the model quantization speed is higher. In the QAT mode, the model is required to be trained a plurality of times, the period for quantizing the model is long, and there is a possibility that the training does not converge. The method for generating the picture classification model is a PTQ mode, is suitable for various models, namely insensitive to application scenes of the models, has good universality, and can avoid the problems of extra calculation amount or memory occupation amount and the like caused by multiple training of the models.
Fig. 1 is a schematic diagram of a system for generating a classification model of a picture according to an embodiment of the disclosure, where, as shown in fig. 1, the system for generating a classification model of a picture may include: electronic device 101 and terminal 102, electronic device 101 may establish a connection with terminal 102 over a wired network or a wireless network.
In the present disclosure, the electronic device 101 is mainly configured to store a resource file required for quantifying a picture classification model or an information classification model, for example: a resource file including a first sort rule, a second sort rule, a first preset condition, a second preset condition, and the like, and a resource file including a service for performing a quantization decision operation. The electronic device 101 may quantize the initial classification model to obtain a target classification model upon receiving a model quantization request including the initial classification model transmitted by the terminal 102, and transmit the target classification model to the terminal 102.
In one implementation, the terminal 102 may be used to construct an initial classification model.
In some embodiments, the electronic device 101 may further include or be connected to a database, and the resource file required for quantifying the model may be stored in the database. When the initial classification model needs to be quantified, the electronic device 101 may invoke a stored resource file in the database.
The electronic device 101 may be a server, a terminal, or other electronic devices for text processing, which is not limited in this disclosure.
When the electronic device 101 is a server, the electronic device 101 may be a single server or may be a server cluster including a plurality of servers. In some implementations, the server cluster may also be a distributed cluster. The present disclosure is not limited to a specific implementation of the server.
When the electronic device 101 is a terminal, the electronic device 101 and the terminal 102 may be two independent terminals or may be integrated into the same terminal, which is not particularly limited in this disclosure.
It is easy to understand that when the electronic device 101 and the terminal 102 are integrated in the same terminal, the communication between the electronic device 101 and the terminal 102 is a communication between internal modules of the terminal. In this case, the communication flow therebetween is the same as "in the case where the electronic device 101 and the terminal 102 are independent of each other".
For ease of understanding, the present disclosure will be mainly described by taking the case where the electronic device 101 and the terminal 102 are separately provided.
The terminal 102 may be a mobile phone, a tablet computer, a desktop, a laptop, a handheld computer, a notebook, an ultra-mobile personal computer (ultra-mobile personal computer, UMPC), a netbook, a cellular phone, a personal digital assistant (personal digital assistant, PDA), an augmented reality (augmented reality, AR) \virtual reality (VR) device, or the like, which may install and use a content community application, and the specific form of the terminal is not particularly limited in this disclosure. The system can perform man-machine interaction with a user through one or more modes of a keyboard, a touch pad, a touch screen, a remote controller, voice interaction or handwriting equipment and the like.
Alternatively, in the text processing system shown in fig. 1, the electronic device 101 may be connected to at least one terminal 102. The present disclosure is not limited in the number and type of terminals 102.
Referring to fig. 1, as shown in fig. 2, a schematic structure diagram of a terminal 102 according to an embodiment of the disclosure is provided. The terminal 102 may be configured with an input module 21, a communication module 22, and a storage module 23. The input module 21 may be an external input device of a computer such as a mouse or a keyboard, or may be a touch screen, and is mainly used for performing operations such as clicking operations for implementing specific functions (e.g., a model file sending function) by a worker. The communication module 22 may be any transceiver-like device for communicating with other devices (e.g., the electronic device 101) or a communication network. For example, communication module 22 may send a model file of the initial classification model to electronic device 101. The storage module 23 may be a memory type device, and may be used to store resource files such as model files of the initial classification model.
The method for generating the picture classification model provided by the embodiment of the present disclosure may be applied to the electronic device 101 in the application scenario shown in fig. 1.
The following describes in detail a method for generating a picture classification model according to an embodiment of the present disclosure with reference to the accompanying drawings.
As shown in fig. 3, when the picture classification model generation method is applied to an electronic device, the picture classification model generation method may include: S301-S304.
S301, the electronic equipment acquires an initial classification model for determining a classification result of the picture to be classified.
Wherein the initial classification model includes m operators. Any operator is used for carrying out classification processing associated with picture classification aiming at pictures to be classified. m is a positive integer.
In a possible manner, the pictures to be classified may be pictures containing specific elements (such as faces, animals, plants, etc.), or may be pictures with specific characteristics (such as color characteristics, outline characteristics, style characteristics, etc.). Correspondingly, the initial classification model can be an AI model for classifying the pictures to be classified based on specific elements in the pictures to be classified, or can be an AI model for classifying the pictures to be classified based on specific features of the pictures to be classified. For example, when the specific element contained in the picture to be classified is lion, the initial classification model may determine that the classification result of the picture to be classified is lion class picture. When the color features of the pictures to be classified are black and white, the initial classification model can determine that the classification result of the pictures to be classified is black and white.
In a possible manner, the classification processing associated with the picture classification performed by the operator for the picture to be classified may be processing of a type such as denoising processing, transformation processing, and smoothing processing.
It should be noted that, when the initial classification model classifies the picture to be classified, it is generally required to perform denoising, transformation and smoothing, feature extraction, feature selection and other classification processes associated with the picture classification on the picture to be classified, so as to determine the classification result of the picture to be classified.
It should be understood that the initial classification model is implemented by m operators constituting the initial classification model when completing various classification processes with respect to the pictures to be classified, and the entire process requires a certain processing time. Further, each of the m operators is composed of parameters and a calculation formula. In order to improve the calculation accuracy of the operator, the parameters constituting the operator are generally floating point data. However, when an operator whose parameter is floating point type data and an operator whose parameter is fixed point type data complete the same classification process once, the time required for the operator whose parameter is floating point type data is significantly longer than that for the operator whose parameter is fixed point type data. Based on this, in order to increase the running speed of the initial classification model, quantization of the initial classification model, that is, quantization of a plurality of parameters constituting m operators in the initial classification model from floating point type data to fixed point type data, may be considered.
In an implementation manner, when a worker deploys an initial classification model for determining a classification result of a picture to be classified on a processor, in order to improve the running speed of the initial classification model, so as to 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 electronic equipment.
Specifically, in connection with fig. 2, a worker may perform a file transmission operation (e.g., clicking a transmission button) directed to the electronic device through an input module configured by the terminal to transmit a model file of an initial classification model stored in a storage module of the terminal to the electronic device. In response to the file transmission operation, the communication module configured by the terminal may transmit a model file of the initial classification model to the electronic device. Accordingly, the electronic device may receive a model file from the initial classification model of the terminal. The electronic device may then parse the model file of the initial classification model to obtain m operators in the initial classification model. Subsequently, the electronic device may quantize the m operators to promote the operation speed of the initial classification model.
S302, the electronic equipment determines the 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 the type of the classification processing associated with each operator.
It should be noted that, in order to determine the classification result of the picture to be classified, m operators constituting the initial classification model need to perform multiple types of classification processing. That is, the types of m operators are relatively diverse. For example, the m operators may include a convolution operator for implementing a convolution operation, a normalization operator for implementing a normalization operation, a pooling operator for implementing a pooling operation, and the like.
Further, the degree of influence on the classification result determined by the initial classification model is often different due to the operation results obtained by different types of operations. Therefore, the degree of influence of the operation precision of different types of operators on the classification result of the picture to be classified is often different. For example, the degree of influence of the operation accuracy of the convolution operation on the classification result of the picture to be classified is generally higher than the degree of influence of the operation accuracy of the normalization operation on the classification result of the picture to be classified. Moreover, when the operation sequence is located before the specific type operator and after the specific type operator, the degree of influence on the classification result of the picture to be classified is often different. For example, when one operator is located before the normalization operator, since the normalization operator performs a normalization operation on the operation result of the one operator, the degree of influence of the operation precision of the one operator located before the normalization operator on the classification result of the picture to be classified is generally lower than the degree of influence of the operation precision of the one operator located after the normalization operator on the classification result of the picture to be classified.
Based on the above, in order to improve the running speed of the initial classification model and ensure the implementation effect of the initial classification model, the electronic device can determine the influence degree level of the classification processing associated with each operator in the m operators on the classification result of the picture to be classified, and then preferentially select the operator with 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 improving the running speed of the initial classification model more effectively and ensuring the quantization effect of the quantization processing on the initial classification model.
In an implementation manner, after the electronic device obtains m operators in the initial classification model, the operation sequence and the type of classification processing associated with each operator in the m operators can be determined first, then according to the type of classification processing associated with each operator, the influence degree of classification processing associated with each operator on the classification result of the picture to be classified is determined, and according to the operation sequence of classification processing associated with each operator, the operators are ordered to obtain the influence degree grade of classification processing associated with each operator on the classification result of the picture to be classified. In this way, the electronic device can preferentially quantize the operators of the specific type according to the degree of influence level of the classification processing associated with each operator on the classification result of the picture to be classified, so as to quantize more operators in the m operators.
In a possible example, the preset initial classification model includes 5 operators, respectively operator a, operator b, operator c, operator d, and operator e. Wherein, the operator d and the operator e are operators of a specific type. In the case where the degree of influence levels corresponding to the 5 operators are not determined, the electronic device may quantize the operator a, the operator b, the operator c, the operator d, and the operator e in order. Then in the process of quantizing the initial classification model by the electronic device, the precision of the initial classification model may meet the precision requirement after the operators a and b are quantized, and then the precision requirement is not met after the operator c is quantized. In this case, the electronic device can only quantize the operators a and b in the initial classification model.
In the case of determining the degree of influence levels corresponding to these 5 operators, the electronic device may preferentially quantize the operator d and the operator e. Then in the process of quantizing the initial classification model by the electronic device, the precision of the initial classification model may meet the precision requirement after the operators d, e, a and b are quantized, and then may not meet the precision requirement after the operator c is quantized. In this case, the electronic device may complete quantization for the four operators operator d, operator e, operator a, and operator b. It can be seen that after determining the impact level corresponding to the m operators that compose the initial classification model, the electronic device may quantize as many operators as possible of the m operators.
S303, the electronic equipment sequentially executes quantization judgment operation on each operator according to the order of the influence degree grades corresponding to each operator from low to high to obtain at least one target operator.
In one possible manner, the quantization determining operation may be used to determine, as the target operator, an operator for which the classification model obtained after quantization satisfies the first preset condition. The target operator can be an operator which can reduce the operation time consumption of the initial classification model after being quantized and has lower influence on the operation precision of the initial classification model.
In one possible manner, the first preset condition may include that a relative difference between a classification result of the picture to be classified determined by the classification model obtained after quantization and a classification result of the picture to be classified determined by the initial classification model is smaller than a preset threshold, and that running time of the classification result determined by the classification model obtained after quantization is smaller than that of the classification result determined by the initial classification model. The preset threshold may be preset in the electronic device by a worker.
In an implementation manner, after determining the influence degree levels corresponding to the m operators, the electronic device may sequentially perform quantization judgment operations on the operators according to the order from low to high of the influence degree levels corresponding to the operators, that is, perform quantization judgment operations preferentially on operators with lower influence degrees of the associated classification processing on the classification result of the picture to be classified. Specifically, after selecting one operator according to the influence degree level corresponding to each operator, the electronic device may quantize the selected operator. Then, the electronic device may use the quantized selected operator to replace the selected operator before quantization in the initial classification model, so as to obtain an initial classification model after updating the selected operator, that is, a quantized classification model. Then, the electronic device may determine a classification result of the picture to be classified based on the quantized classification model, and test the quantized classification model to determine a running time consuming to the classification result, so as to determine whether the quantized classification model meets a first preset condition.
And if the relative difference between the classification result of the picture to be classified determined by the classification model obtained after quantization and the classification result of the picture to be classified determined by the initial classification model is smaller than a preset threshold value, and the running time of the classification result determined by the classification model obtained after quantization is smaller than the running time of the classification result determined by the initial classification model, determining the selected operator as a target operator. Then, the electronic device may select a subsequent operator in the influence degree levels corresponding to the respective operators on the basis of the initial classification model after updating the selected operator, and then perform a quantization judgment operation on the selected subsequent operator. If not, the electronic device determines that the selected operator is not the target operator. Then, the electronic device may select a subsequent operator in the influence degree levels corresponding to the respective operators on the basis of the initial classification model of the selected operator being not updated, and then perform a quantization judgment operation on the selected subsequent operator. And the electronic equipment executes quantization judgment operation on the m operators according to the influence degree level corresponding to the m operators, so that at least one target operator can be obtained.
S304, the electronic equipment quantifies 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.
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 difference 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.
In one implementation manner, the calculation time consumption of the initial classification model can be reduced after the target operator is quantized, and the implementation effect of the initial classification model is not affected. Therefore, after obtaining the at least one target operator, the electronic device may quantize the at least one target operator in the initial classification model to generate the target classification model.
In a possible example, in combination with the example in S302, on the premise of being based on the same precision condition, when the degree of influence level corresponding to each operator is not determined by the preset electronic device, the operator a and the operator b in the initial classification model may be quantized in sequence to obtain the model a. When determining the influence degree level corresponding to each operator, the electronic device may perform quantization judgment operation on each operator according to the influence degree level corresponding to each operator, and after four target operators of operator d, operator e, operator a and operator B are obtained, quantize operator d, operator e, operator a and operator B in the initial classification model to obtain a model B (i.e. a target classification model).
When the GPU1 needs to determine the classification result of the picture 1 to be classified, under the condition that the model a is deployed on the GPU1, 3 operators forming the model a are not quantized, namely 2 operators based on fixed point type data, and 3 operators based on floating point type data. Therefore, when the GPU1 invokes the model a to determine the classification result of the picture 1 to be classified, 2 operators based on fixed point type data and 3 operators based on floating point type data need to be run.
In the case where the model B (i.e., the object classification model) is deployed on the GPU1, since only 1 of the 5 operators that constitute the model B is unquantized, i.e., 4 of the 5 operators are operators based on fixed-point type data, and 1 is an operator based on floating-point type data. Therefore, when the GPU1 invokes the model B to determine the classification result of the picture 1 to be classified, 4 operators based on fixed point type data and 1 operator based on floating point type data need to be run.
As can be seen, compared with the call model a determining that the classification result of the picture 1 to be classified needs to run 3 operators based on floating point type data, the call model B (i.e. the target classification model) determining that the classification result of the picture 1 to be classified needs to run only 1 operator based on floating point type data. It will be appreciated that the run length required for fixed point data based operators is significantly reduced compared to floating point data based operators. Therefore, the target classification model can process the picture 1 faster on the premise of ensuring the accuracy.
The technical scheme provided by the embodiment at least brings the following beneficial effects: S301-S304 can know that after the electronic device obtains an initial classification model for determining the classification result of the picture to be classified, according to the operation sequence and the type of classification processing associated with each operator in the initial classification model, 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, and further quantization judgment operation is sequentially carried out on each operator according to the order of the influence degree level corresponding to each operator from low to high, so as to obtain at least one target operator, and each target operator in the initial classification model is quantized to generate a target classification model.
Since the m operators in the initial classification model have different degrees of influence on the classification result of the picture to be classified, the operators have different influences on the precision of the initial classification model after being quantized. Based on the method, after 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 is determined, as many target operators as possible can be selected from m operators according to the order of the influence degree level corresponding to each operator from low to high, so that a plurality of target operators can be further quantized, and a target classification model is generated. Compared with the mode that the general technology relies on manual selection of partial parameters to quantize, the method and the device quantize the models in a mode that the electronic equipment judges the degree of influence one by one, not only can save labor efficiency, but also can ensure that as many operators in the initial classification model are quantized to obtain the target classification model, so that the operation speed of the business application can be improved while the implementation effect of the business application is not influenced.
In one embodiment, in conjunction with fig. 3, in S302, when the electronic device determines, according to the operation sequence and the type of the classification processing associated with each operator, the degree of influence level of the classification processing associated with each operator on the classification result of the picture to be classified, as shown in fig. 4, the disclosure provides an alternative implementation manner, which specifically includes: s401 to S405.
S401, the electronic device determines the operation sequence of classification processing associated with the n structural blocks.
In one possible approach, the m operators that make up the initial classification model are typically distributed in individual building blocks. That is, the initial classification model generally includes n structural blocks, and each structural block includes at least one operator of the m operators. n is a positive integer less than m. It should be appreciated that one operator is located in only one structural block.
In one possible manner, any of the structural blocks may be used to perform classification processing (e.g., segmentation processing, fusion processing, etc.) associated with picture classification for a picture to be classified. It will be appreciated that the classification process associated with picture classification by the structural block for the picture to be classified is effected on the basis of at least one operator included.
In an implementation manner, after the electronic device analyzes the model file of the initial classification model to obtain n structural blocks, the sequence numbers of the n structural blocks can be sequentially arranged from the structural block with initial operation to the structural block with terminated operation according to the calculation logic of the n structural blocks, so as to determine the operation sequence of classification processing associated with the n structural blocks.
S402, the electronic equipment 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.
The first preset rule comprises the following steps: when the first and second blocks of the n blocks are both of a preset type and the operation order of the first block is before the operation order of the second block, or when the first block is of a preset type and the second block is not of a preset type, or when the first and second blocks are not of a preset type and the operation order of the first block is before the operation order of the second block, it is determined that the degree of influence of the first block is lower than that of the second block. The preset type structure block is a structure block comprising a preset type operator. The operator with the preset type is an operator with a normalization function; the first structural block is any one of n structural blocks. The second structural block is any one of the n structural blocks except the first structural block.
In one possible manner, for a preset type structure block including a preset type operator, the operation initiation operator and the operation termination operator in the preset type structure block may be preset type operators.
It should be noted that, when the preset type of algorithm is included, the result obtained by processing the data by the preset type of structure block does not need to have excessively high precision. That is, after floating point type data in a preset type structure block is converted into fixed point type data, the initial classification model is less affected by precision.
In a possible example, the preset initial classification model includes 6 blocks, namely, a block 1 with a sequence number of 1, a block 2 with a sequence number of 2, a block 3 with a sequence number of 3, a block 4 with a sequence number of 4, a block 5 with a sequence number of 5, and a block 6 with a sequence number of 6. And, the structural blocks 3 and 5 are preset type structural blocks.
Then, according to the first preset rule, since the structural blocks 3 and 5 are structural blocks of a preset type, and the operation sequence of the structural blocks 3 is located before the operation sequence of the structural blocks 5. Thus, the electronic device can determine that the influence level of the structural block 3 is lower than that of the structural block 5.
Since the structural block 5 is a preset type structural block, and the structural block 1 is not a preset type structural block. Thus, the electronic device can determine that the influence level of the structural block 5 is lower than that of the structural block 1.
Since neither block 1 nor block 2 is a preset type of block, and the order of operation of block 1 is before the order of operation of block 2. Thus, the electronic device can determine that the influence level of the structural block 1 is lower than that of the structural block 2.
By analogy, the electronic device may determine that the influence level of the structural block 3 is a first level, the influence level of the structural block 5 is a second level, the influence level of the structural block 1 is a third level, the influence level of the structural block 2 is a fourth level, the influence level of the structural block 4 is a fifth level, and the influence level of the structural block 6 is a sixth level.
S403, the electronic equipment determines the operation sequence of classification processing associated with at least one operator in each structural block.
Specifically, after analyzing the model file of the initial classification model to obtain n structural blocks, the electronic device may further determine at least one operator included in each structural block, and sequentially arrange the sequence number of at least one operator in each structural block from the operation start operator to the operation end operator according to the calculation logic of each structural block, so as to determine the operation sequence of classification processing associated with at least one operator in each structural block.
S404, the electronic equipment 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.
The second preset rule comprises the following steps: and determining that the influence degree level of the first operator is lower than that of the second operator 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 sequence of the first operator is positioned before the operation sequence of the second operator, or when the next operator of the first operator is the preset type operator and the next operator of the second operator is not the preset type operator, or when the next operator of the first operator and the next operator of the second operator are both not the preset type operator and the operation sequence of the first operator is positioned before the operation sequence of the second operator. The first operator is any operator in the structural block. The second operator is any operator except the first operator in the structural block.
It should be noted that, when the following operator of one operator is a preset type operator, the result output by the one operator is normalized by the following operator. Therefore, the electronic device can determine that the result output by the operator does not need to have excessive precision, that is, after the floating point type data in the operator is converted into the fixed point type data, the precision influence on the preset type structure block is less. Thus, the initial classification model is also less affected by accuracy.
In a possible example, in combination with the example of S402, the preset structural block 3 includes 6 operators, which are an operator 1 with a sequence number 1, an operator 2 with a sequence number 2, an operator 3 with a sequence number 3, an operator 4 with a sequence number 4, an operator 5 with a sequence number 5, and an operator 6 with a sequence number 6. And, the operator 2 and the operator 6 are preset type operators.
Then according to the second preset rule, since the following operator 2 of the operator 1 and the following operator 6 of the operator 5 are operators of preset type and the operation sequence of the operator 1 is located before the operation sequence of the operator 5. Thus, the electronic device can determine that the degree of influence of operator 1 is lower than operator 5.
Since the latter operator 6 of the operator 5 is a preset type operator and the latter operator 3 of the operator 2 is not a preset type operator. Thus, the electronic device can determine that the degree of influence of operator 5 is lower than operator 2.
Since neither the operator 3 following the operator 2 nor the operator 4 following the operator 3 is a preset type of operator, and the operation order of the operator 2 is located before the operation order of the operator 3. Thus, the electronic device can determine that the degree of influence of operator 2 is lower than operator 3.
And so on, the electronic device can determine that the influence degree level of the operator 1 is a first level, the influence degree level of the operator 5 is a second level, the influence degree level of the operator 2 is a third level, the influence degree level of the operator 3 is a fourth level, the influence degree level of the operator 4 is a fifth level, and the influence degree level of the operator 6 is a sixth level.
S405, the electronic device determines the influence degree grade corresponding to each operator according to the influence degree grade corresponding to the n structural blocks and the influence degree grade corresponding to at least one operator in each structural block.
Specifically, after determining 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, the electronic device may sort the n structural blocks according to the influence degree level of each structural block, and sort at least one operator in each structural block according to the influence degree level of at least one operator in each structural block, so as to determine the influence degree level corresponding to each operator.
In a possible example, in combination with the examples of S402 and S404, the electronic device may first sort 6 structural blocks into the structural block 3, the structural block 5, the structural block 1, the structural block 2, the structural block 4, and the structural block 6 according to the influence level corresponding to the 6 structural blocks in the initial classification model. Then, the electronic device may order the 6 operators in the structural block 3 into an operator 1, an operator 5, an operator 2, an operator 3, an operator 4 and an operator 6 according to the influence level corresponding to the 6 operators in the structural block 3. And by analogy, after the operators in the structural blocks 5, 1, 2, 4 and 6 are ordered, the electronic equipment can obtain the corresponding influence degree level of each operator.
The technical scheme provided by the embodiment at least brings the following beneficial effects: as can be seen from S401 to S405, a specific implementation manner of determining, by the electronic device, a degree of 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 the type of the classification process associated with each operator is provided. After the operation sequence of the classification processing associated with the n structural blocks is determined, the electronic device determines the influence degree grade 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 operation sequence of the classification processing associated with at least one operator in each structural block is determined, the influence degree grade 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 that the influence degree grade corresponding to the n structural blocks and the influence degree grade corresponding to at least one operator in each structural block are determined. Subsequently, the electronic equipment can determine the target operators according to the influence degree grades corresponding to the m operators, the probability of determining the maximum number of the target operators is improved, and the electronic equipment has higher assurance than manual experience.
In one embodiment, in conjunction with fig. 3, in S303, the electronic device sequentially performs the quantization determining operation on each operator according to the order from low to high of the impact level corresponding to each operator, and when at least one target operator is obtained, as shown in fig. 5, the disclosure provides an alternative implementation manner, which specifically includes: S501-S504.
S501, the electronic equipment quantizes each operator in the current operator set to obtain a current classification model.
Wherein the current operator set comprises: the corresponding influence degree level of each operator is the ith operator and the target operator in the first i-1 operators in the sequence from low to high. i is a positive integer less than or equal to m. The current classification model is a quantized model corresponding to the ith operator.
In a possible example, in combination with the example in S302, the impact degree levels corresponding to the 5 operators in the initial classification model are preset to be operator d, operator e, operator a, operator b and operator c. When the electronic device starts to execute the quantization judgment operation on the 5 operators based on the influence degree grades corresponding to the 5 operators, namely, when i is equal to 1, the current operator set comprises the first operator (namely, operator d) in the sequence from low to high of the influence degree grades corresponding to the 5 operators, and no target operator exists at the moment. In this case, after the electronic device quantizes the first operator (i.e., operator d), the unquantized operator d in the initial classification model may be replaced by the quantized operator d, so as to obtain the current classification model, i.e., the quantized model obtained corresponding to the operator d.
Next, if the operator d is determined to be the target operator, if i is equal to 2, the current operator set includes the second operator (i.e., operator e) and operator d in the order of the 5 operators from low to high in the degree of influence level. In this case, after the electronic device quantizes the operator d and the operator e, the unquantized operator d in the initial classification model may be replaced by the quantized operator d, and the unquantized operator e in the initial classification model may be replaced by the quantized operator e, so as to obtain the current classification model, that is, the quantized model corresponding to the operator e.
S502, when the current classification model accords with a first preset condition, the electronic equipment determines an ith operator as a target operator and updates the value of i.
In one possible manner, the first preset condition may further include: the relative difference between the classification result of the picture to be classified determined by the current classification model and the classification result of the picture to be classified determined by the initial classification model is smaller than or equal to a preset threshold value, and the running time of the current classification model to the classification result is smaller than a current time threshold value. The current duration threshold determines the running time consumption to the classification result for the classification model obtained after quantizing each target operator in the current operator set.
In an implementation manner, when the current classification model meets the first preset condition, the operation precision of the current classification model can be indicated to meet the requirement. And, since the current time length threshold is the time consumption of the operation of the model obtained after the target operator in the current operator set is quantized, that is, the time consumption of the operation of the last current classification model before the current classification model is obtained by the current time length threshold. Therefore, if the running time of the current classification model is smaller than the current time threshold, the running time of the current classification model can be indicated to be lower than the running time of the current classification model determined before, namely, the running time of the current classification model can be indicated to be shortest, and the calculation speed can be improved and the calculation precision can be ensured after the ith operator is quantized. In this case, the electronic device may determine the ith 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 impact level corresponding to each operator.
S503, when the current classification model does not accord with the first preset condition, the electronic equipment updates the value of i.
In one implementation manner, when the current classification model does not meet the first preset condition, it is indicated that the operation speed of the initial classification model cannot be improved after the ith operator is quantized. Or, the ith operator can improve the operation speed of the initial classification model after being quantized, but cannot guarantee the operation precision. In these cases, the ith operator may not 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.
S504, the electronic equipment repeatedly quantizes each operator in the current operator set until i is greater than m, and at least one target operator is obtained.
In one implementation manner, after updating the value of i, i.e., increasing the value of i by 1, the electronic device may update the current operator set according to the value of i (i.e., i+1) after increasing the value of i, 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 a first preset condition. And so on until i is greater than m, the electronic device may obtain at least one target operator.
In a possible example, in combination with the example in S501, the impact degree levels corresponding to the 5 operators in the initial classification model are preset to be operator d, operator e, operator a, operator b and operator c. When the electronic device starts to execute the quantization judgment operation on the 5 operators based on the influence degree grades corresponding to the 5 operators, namely, when i is equal to 1, the current operator set comprises the first operator (namely, operator d) in the sequence from low to high of the influence degree grades corresponding to the 5 operators, and no target operator exists at the moment.
Then, if the current classification model obtained after each operator in the current operator set is quantized meets a first preset condition, the electronic device can determine the operator d as a target operator and increment the value of i by 1. At this point i is equal to 2, the current operator set is: operator d and a second operator (i.e., operator e).
Then, if the current classification model obtained after each operator in the current operator set is quantized meets a first preset condition, the electronic device can determine an operator d and an operator e as target operators, and increment the value of i by 1. At this point i is equal to 3, the current operator set is: operator d, operator e and a third operator (i.e. operator a).
Then, if the current classification model obtained after each operator in the current operator set is quantized does not meet the first preset condition, the electronic device may determine the operator d and the operator e as target operators, and increment the value of i by 1. At this point i is equal to 4, the current operator set is: operator d, operator e and fourth operator (i.e. operator b).
Then, if the current classification model obtained after each operator in the current operator set is quantized meets a first preset condition, the electronic device can determine an operator d, an operator e and an operator b as target operators, and increment the value of i by 1. At this point i is equal to 5, the current operator set is: operator d, operator e, operator b, and a fifth operator (i.e., operator c).
Then, if the current classification model obtained after each operator in the current operator set is quantized does not meet the first preset condition, the electronic device can determine an operator d, an operator e and an operator b as 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 satisfied, and the electronic apparatus ends executing the quantization judgment operation.
In this way, the electronic device can obtain a target operator comprising operator d, operator e and operator b.
The technical scheme provided by the embodiment at least brings the following beneficial effects: as can be seen from S501-S504, a specific implementation manner of performing quantization judgment operations on each operator sequentially by the electronic device according to the order from low to high of the impact level corresponding to each operator is provided. The electronic device quantizes each operator in the current operator set to obtain a current classification model, and then can judge whether the current classification model meets a first preset condition. If yes, the electronic device can determine the ith operator as a target operator conforming to the quantization condition, and increment the value of i by 1. If not, the electronic equipment directly increases the value of i by 1. The electronic device may then repeat the quantization of each operator in the current set of operators until i is greater than m, resulting in at least one target operator.
In one 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 disclosure provides an alternative implementation, specifically including: S601-S603.
S601, the electronic equipment quantizes each target operator according to a target quantization algorithm corresponding to each target operator in the current operator set to obtain a first model.
It should be noted that, when the current operator set includes the target operator, it indicates that the electronic device has quantized the target operator before and has determined the target quantization mode corresponding to the target operator. In this case, the electronic device may quantize each target operator according to a target quantization algorithm corresponding to each target operator in the current operator set, so as to obtain the first model. Specifically, for a specific description of this case, reference may be made to the following specific implementation manners of S602-S603, which are not described herein.
When the current operator set does not comprise the target operator, the current operator set is indicated to be the first operator set, or the current operator set before updating the current operator set does not accord with the first preset condition. In this case, the electronic device may determine that the first model is not present.
S602, the electronic equipment quantizes the ith operator according to a plurality of preset quantization algorithms based on the first model to obtain a plurality of second models which are in one-to-one correspondence with the preset quantization algorithms.
It should be noted that, when quantization is performed for an operator for processing at least two variables, a scale factor (scale) may be generally determined first to convert floating point type data in the one operator into fixed point type data. Since the scale factor is determined, the range of values of floating point type data and the range of values of fixed point type data are 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 appreciated that, regarding the specific determination formula of the scaling factor, those skilled in the art can understand with reference to the prior art, and will not be described herein.
In one possible way, the fixed-point data may be set to be of the int16 type, and the fixed-point data may have a range of values (-32768, +32767). And after setting the fixed-point data as the int16 type to obtain the target classification model, If the target classification model with the fixed-point data of the Int8 type is required to be obtained, the scaling factor obtained when the fixed-point data of the Int16 type is changed, and the target classification model of the Int8 type can be directly obtained. Meanwhile, the model error between the target classification model obtained for the int16 type based on the fixed-point data and the initial classification model for the fp16 type based on the floating-point data is less than 1/2 15 The theoretical precision of the two is in the same level position. The model error between the target classification model based on the fixed point type data for the int16 type and the initial classification model based on the floating point type data for the fp32 type is also between 10e-2 and 10 e-3.
Also, there are typically multiple calibration algorithms in determining the minimum and maximum values of floating point type data in the one operator. Such as algorithms for unordered state measurement (entopy), mean-square error (MSE), and percentile (percentile) methods. In addition, there are a plurality of count reservation methods after obtaining the scaling factor from the value range of the floating point type data and the value range of the fixed point type data. Such as rounding and rounding up (ceil) algorithms. Meanwhile, each calibration algorithm can also adjust the size of the parameter for calibration when determining the minimum value and the maximum value of floating point type data in the operator. For example, the percentile method may adjust the percentage (percentage) parameter to any value from 0% to 100%.
Algorithms such as quantization per channel (per channel quantization) and quantization per tensor (per tensor quantization) are also typically chosen for quantization against an operator that handles a variable and a weight.
Based on this, in order to reduce errors as much as possible when quantizing the one operator, to obtain as high accuracy as possible, a plurality of preset quantization algorithms are preconfigured in the electronic device of the present disclosure. The plurality of preset quantization algorithms may include a plurality of quantization algorithms based on a percentile method and a rounding method of the plurality of percentile parameters, may further include a plurality of quantization algorithms based on a percentile method and a rounding method of the plurality of percentile parameters, or any one of the quantization algorithms described above may quantize the one operator. And are not listed here.
Specifically, after performing S601, if the first model does not exist, the electronic device may determine that the current operator set includes only the ith operator. In this case, the electronic device may quantize the ith operator according to a plurality of preset quantization algorithms to obtain a plurality of second models corresponding to the plurality of preset quantization algorithms one by one.
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 ith operator. In this case, the electronic device may quantize the ith operator once according to each preset quantization algorithm, so as to obtain a plurality of quantized ith operators corresponding to a plurality of preset quantization algorithms one by one. Then, the electronic device may combine each quantized ith operator and the first model once to obtain a plurality of second models corresponding to a plurality of preset quantization algorithms one by one.
In a possible example, in combination with the example in S302 above, when the current operator set includes the first operator (i.e., the operator d) in the order of the low-to-high degree of influence levels corresponding to the operators, and the target operator is not present, the electronic device may perform S601 to determine that the first model is not present, and quantize the operator d according to a plurality of preset quantization algorithms, so as to obtain a plurality of second models corresponding to the plurality of preset quantization algorithms one-to-one.
Further, the electronic device may determine a second model meeting a second preset condition from the plurality of second models as the current classification model, and determine a quantization algorithm corresponding to the second model meeting the second preset condition as the target quantization algorithm corresponding to the operator d. Specifically, the process may refer to the descriptions of S603 and S701 described below.
Updating the current operator set as follows: when the operator d and the second operator (i.e. the operator e) are used, the electronic device can quantize the operator d according to a target quantization algorithm corresponding to a target operator (i.e. the operator d) in the current operator set so as to obtain a first model. Then, the electronic device quantizes an ith operator (i.e. operator e) in the current operator set according to a plurality of preset quantization algorithms based on the first model, so as to obtain a plurality of second models corresponding to the preset quantization algorithms one by one. Until a plurality of target operators including operator d, operator e and operator b are obtained.
S603, the electronic device determines a second model meeting a second preset condition from the plurality of second models as a current classification model.
Wherein the second preset condition includes: the relative difference 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 smaller than or equal to a preset threshold value, and the running time of the second model to the classification result is smaller than or equal to a preset time length threshold value.
In an implementation manner, the electronic device may determine, as the preset second model, a second model that is determined to have the shortest running time to the classification result and determines, as the preset duration threshold, a relative difference between the classification result of the picture to be classified determined from the plurality of second models and the classification result of the picture to be classified determined from the initial classification model to be less than or equal to the preset threshold.
Based on the above, after obtaining the plurality of second models, the electronic device may determine, as the current classification model, a second model in which a relative difference between a classification result of the picture to be classified determined in the plurality of second models and a classification result of the picture to be classified determined by the initial classification model is less than or equal to a preset threshold value, and it is determined that a running time required for the classification result is less than or equal to a preset time period threshold value. That is, the current classification model is the second model which meets the accuracy requirement among the plurality of second models and has the highest model running speed.
The technical scheme provided by the embodiment at least brings the following beneficial effects: from S601-S603, a specific implementation of the electronic device to quantize each operator in the current operator set to obtain the current classification model is provided. The electronic device may quantize each operator through a plurality of preset quantization algorithms based on the first model in a manner that each operator is a single variable, so as to obtain a plurality of second models, thereby determining a current classification model meeting a second preset condition in the plurality of second models, that is, determining a second model with the best quantization effect as the current classification model. Therefore, the electronic device can evaluate different quantization effects of the plurality of preset quantization algorithms on one operator on the basis of the determined target operator of the target quantization algorithm, so that the preset quantization algorithm most suitable for the one operator is screened out, and the differential evaluation of superiority of the plurality of preset quantization algorithms is realized.
In an example that may be implemented, in conjunction with fig. 6, as shown in fig. 7, the method for generating a picture classification model provided in the present disclosure further includes: s701, performing operation.
S701, the electronic device determines a preset quantization algorithm corresponding to a second model meeting a second preset condition as a target quantization algorithm corresponding to an ith operator.
Specifically, after determining the current classification model in the plurality of second models, the electronic device may determine a preset quantization algorithm corresponding to the second model that meets a second preset condition as a target quantization algorithm corresponding to the ith operator. In this way, when the current classification model meets the first preset condition, the electronic device may determine the ith operator in the current operator set as a target operator, and determine a target quantization algorithm corresponding to the ith operator as a target quantization algorithm corresponding to the target operator.
Subsequently, when the target operator (i.e. the ith operator) needs to be quantized, the electronic equipment can conveniently quantize the target operator according to a target quantization algorithm corresponding to the target operator, so that the speed of quantizing the initial classification model is increased.
In a possible example, in combination with the example in S302, when the current operator set includes the first operator (i.e., operator d) in the order from low to high of the influence level corresponding to each operator, and there is no target operator, if the current classification model obtained after quantization of each operator in the current operator set meets the first preset condition, the electronic device may determine the ith 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 operator d.
Updating the current operator set as follows: when the operator d and the second operator (i.e. the operator e) are used, 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 ith operator (i.e. the operator e) in the current operator set as a target operator, and determine a quantization algorithm corresponding to the current classification model as a target quantization algorithm corresponding to the operator e. Until a target operator comprising an operator d, an operator e and an operator b is obtained, and a target quantization algorithm corresponding to the operator d, a target quantization algorithm corresponding to the operator e and a target quantization algorithm corresponding to the operator b.
The technical scheme provided by the embodiment at least brings the following beneficial effects: as known from S701, the electronic device may establish a correspondence between the ith operator and the target quantization algorithm in the current operator set after determining, from a plurality of preset quantization algorithms, the target quantization algorithm that is most suitable for the ith operator in the current operator set based on the target operator for which the target quantization algorithm has been determined. In this way, after determining the ith operator in the current operator set as the target operator, the electronic device may conveniently quantize the ith operator in the current operator set.
In an example that may be implemented, in conjunction with fig. 3, in S304, the electronic device quantizes at least one target operator in the initial classification model, and when generating a target classification model for determining a classification result of a picture to be classified, as shown in fig. 8, the disclosure provides an alternative implementation, which specifically includes: s801.
S801, the electronic equipment quantizes each target operator according to a target quantization algorithm corresponding to each target operator, and a target classification model is generated.
Specifically, the electronic device obtains the target quantization algorithm corresponding to each target operator while obtaining the plurality of target operators. Therefore, the electronic device can quantize each target operator according to the target quantization algorithm corresponding to each target operator so as to obtain the target classification model.
In a possible example, in combination with the example in S701, the plurality of target operators includes an operator d, an operator e, and an operator b. The electronic device may 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 may complete the quantification of the initial classification model to obtain the target classification model.
The technical scheme provided by the embodiment at least brings the following beneficial effects: as can be seen from the above S801, a specific implementation manner of the electronic device to quantize each target operator in the initial classification model to obtain the target classification model is provided. After the plurality of target operators are obtained, as each target operator corresponds to a target quantization algorithm, the electronic equipment does not need to screen a plurality of preset quantization algorithms, and each target operator in the target operators can be quantized conveniently through the target quantization algorithm corresponding to each target operator so as to obtain a target classification model.
In one embodiment, when the electronic device determines a second model meeting a second preset condition from the plurality of second models as the current classification model, as shown in fig. 9, an optional implementation manner provided in the disclosure includes: S901-S902.
S901, the electronic equipment classifies the pictures to be classified based on the second model to obtain the running information of the second model.
The operation information comprises a classification result of the picture to be classified, which is determined by the second model, and operation time consumption of the classification result, which is determined by the second model.
Specifically, after the electronic device obtains the second model, the image to be classified may be classified based on the second model, and an operation process of the second model may be monitored. Thus, the electronic equipment can obtain the classification result of the picture to be classified, which is determined by the second model. Meanwhile, the electronic device can monitor time information of starting operation and stopping operation of the second model to determine time consumption of operation from the second model to the classification result.
S902, when the relative difference between the classification result of the picture to be classified, which is determined by the second model, and the classification result of the picture to be classified, which is determined by the initial classification model, is smaller than or equal to a preset threshold value, and the running time consumption of the classification result, which is determined by the second model, is smaller than or equal to a preset time length threshold value, the second model is determined to be the current classification model by the electronic device.
It should be noted that, since a large number of parameters in the initial classification model are floating point type data. Therefore, the initial classification model has good precision in classifying results obtained by classifying the pictures to be classified. Based on this, in order to accurately determine the error of the second model, the electronic device may determine, as the model error of the second model, a 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.
In a possible manner, the electronic device may determine, through the first formula, a 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. The first formula is:
R=∑abs(r-Q)/∑(r)。
and R is the relative difference (relative difference) 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. And r is a classification result of the picture to be classified, which is determined by the second model. Q is the classification result of the picture to be classified, which is determined by the initial classification model. Σabs is used to represent the absolute value of the bracketed value. Σ is used to sum all values in brackets.
The technical scheme provided by the embodiment at least brings the following beneficial effects: as can be seen from the foregoing S901 to S902, a specific implementation manner of the electronic device to determine, as the current classification model, a second model that meets a second preset condition from a plurality of second models is provided. The electronic equipment can classify the pictures to be classified based on the second model to obtain operation information of the second model, and when the relative difference between the classification result of the pictures to be classified determined by the second model and the classification result of the pictures to be classified determined by the initial classification model is smaller than or equal to a preset threshold value and the operation time consumption of the classification result determined by the second model is smaller than or equal to a preset time length threshold value, the second model is determined to be the current classification model. Therefore, the electronic device can more accurately determine the quantization effect of the second model and better evaluate the performance of the second model when the second model is actually deployed on a coprocessor such as a GPU.
In one example that may be implemented, as shown in fig. 10, a flowchart of a method for generating a picture classification model is provided in the present disclosure. After the electronic device obtains the model file of the initial classification model, the model file may be parsed to determine a model map representing the overall structure of the initial classification model. The electronic device may then determine the type of the model map (e.g., CNN structure and transducer structure, etc.) to determine the computational logic of the initial classification model.
Then, the electronic device may determine, according to the calculation logic of the initial classification model and the first preset rule, the impact level corresponding to the n structural blocks forming the initial classification model, and determine, according to the calculation logic of each structural block and the second preset rule, the impact level corresponding to at least one operator in each structural block. Further, the electronic device may obtain the impact level corresponding to the m operators that compose the initial classification model.
Then, the electronic device may perform quantization judgment operations on the m operators according to the influence level corresponding to the m operators. If the target operator does not exist 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 may determine the second model satisfying the second preset condition as the current classification model. If the target operators exist in the current operator set, the electronic equipment can quantize each target operator according to a target quantization algorithm corresponding to each target operator in the current operator set so as to obtain a first model. Then, the electronic device quantizes the ith operator in the current operator set according to a plurality of preset quantization algorithms based on the first model, so that a plurality of second models corresponding to the preset quantization algorithms one by one can be obtained. Further, the electronic device may determine the second model satisfying the second preset condition as the current classification model.
When the ith operator is the mth operator, after the electronic device determines that the ith operator is a target operator or not, each target operator can be quantized according to a target quantization algorithm corresponding to each target operator in the current operator set, so as to obtain a target classification model.
Then, the electronic device may run the current classification model to determine a classification result of the picture to be classified, so as to determine an index parameter of the current classification model. The index parameters may include parameters such as model errors, running time and resource occupancy of the current classification model. Further, the electronic device may score the model performance of the current classification model according to the running time and the resource occupation of the current classification model, so as to obtain a model performance score of the current classification model.
When the model error of the current classification model is less than or equal to the preset error threshold, the electronic device may further determine whether the model performance score of the current classification model is greater than the current performance threshold.
If the model performance score of the current classification model is greater than the current performance threshold, the electronic equipment determines the ith operator as a target operator and determines a target quantization algorithm corresponding to the ith operator. Then, the electronic device may increment the value of i by 1, 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 smaller than or equal to the current performance threshold, the electronic equipment directly increases the value of i by 1, further updates the current operator set and returns to judge whether i is larger than m. The current performance threshold is a model performance score of the model obtained after the target operator in the current operator set is quantized.
When the model error of the current classification model is greater than a preset error threshold, the electronic device can increment the value of i by 1, further update the current operator set and return to judge whether i is greater than m.
It should be understood that when i is greater than m, i.e., i is m+1, it may indicate that the electronic device has completed the quantization determining operation on the m operators, and at least one target operator is obtained. In this case, the electronic device may stop the decision loop and generate the target classification model.
The method for generating the information classification model provided in the embodiment of the present disclosure may also be applied to the electronic device 101 in the application scenario shown in fig. 1.
The method for generating the information classification model according to the embodiment of the present disclosure is described in detail below with reference to the accompanying drawings.
As shown in fig. 11, when the information classification model generation method is applied to an electronic device, the information classification model generation method may include: S1001-S1004.
S1001, the electronic equipment acquires an initial classification model for determining a classification result of the information to be classified.
Wherein the initial classification model includes m operators. Any operator is used for carrying out classification processing associated with information classification aiming at the information to be classified. m is a positive integer.
In a possible manner, the information to be classified may be picture information, text information or video information. The picture information may be picture information containing specific elements (e.g., faces, animals, plants, etc.), or may be picture information having specific characteristics (e.g., color characteristics, outline characteristics, style characteristics, etc.). The text information may be text information containing specific characters (for example, an arabic character, an english character, or the like), or may be text information having specific features (for example, an emotion feature, a geometric feature, or the like). The video information may be video information containing specific content (for example, sports content, game content, dance content, etc.), or may be video information having specific characteristics (for example, dialect characteristics, time duration characteristics, etc.).
Accordingly, when the information to be classified is the picture information, the initial classification model may be an AI model for classifying the picture information based on a specific element in the picture information, or may be an AI model for classifying the picture information based on a specific feature included in the picture information. For example, when the specific element contained in the picture information is a lion, the initial classification model may determine that the classification result of the picture information is a lion-class picture. When the color features of the picture information are black and white, the initial classification model can determine that the classification result of the picture information is black and white type pictures.
When the information to be classified is text information, the initial classification model may be an AI model for classifying the text information based on a specific element in the text information, or may be an AI model for classifying the text information based on a specific feature of the text information. For example, when the specific character contained in the text information is an english character, the initial classification model may determine that the classification result of the text information is an english-type text. When the emotion feature of the text information is forward emotion, the initial classification model can determine that the classification result of the text information is forward class text.
When the information to be classified is video information, the initial classification model may be an AI model for classifying the video information based on specific contents in the video information, or may be an AI model for classifying the video information based on specific features included in the video information. For example, when the specific content in the video information is sports-like content, the initial classification model may determine that the classification result of the video information is sports-like video. When the specific feature of the video information is the a dialect feature, the initial classification model can determine that the classification result of the video information is the a dialect video.
In a possible manner, when the information to be classified is picture information, the classification processing associated with information classification performed by the operator for the information to be classified may be a type of processing such as denoising processing, transformation processing, and smoothing processing. When the information to be classified is text information, the classification processing associated with information classification by the operator for the information to be classified may be processing of the type of segmentation processing, recognition processing, fusion processing, or the like. When the information to be classified is video information, the classification processing associated with information classification by the operator for the information to be classified may be processing of the type such as denoising processing and gradation conversion processing.
It should be noted that, when the initial classification model classifies the information to be classified, it is generally required to perform denoising, segmentation, feature extraction, feature selection and other classification processes associated with information classification on the information to be classified, so as to determine a classification result of the information to be classified.
It should be understood that the initial classification model is implemented by m operators constituting the initial classification model when various classification processes on information to be classified are completed, and the entire process requires a certain processing time. Further, each of the m operators is composed of parameters and a calculation formula. In order to improve the calculation accuracy of the operator, the parameters constituting the operator are generally floating point data. However, when an operator whose parameter is floating point type data and an operator whose parameter is fixed point type data complete the same classification process once, the time required for the operator whose parameter is floating point type data is significantly longer than that for the operator whose parameter is fixed point type data. Based on this, in order to increase the running speed of the initial classification model, quantization of the initial classification model, that is, quantization of a plurality of parameters constituting m operators in the initial classification model from floating point type data to fixed point type data, may be considered.
In an implementation manner, when a worker deploys an initial classification model for determining a classification result of information to be classified on a processor, in order to improve an operation speed of the initial classification model, so as to reduce occupation of the initial classification model on resources such as storage resources and computing resources on the processor, the initial classification model may be quantized by an electronic device.
Specifically, in connection with fig. 2, a worker may perform a file transmission operation (e.g., clicking a transmission button) directed to the electronic device through an input module configured by the terminal to transmit a model file of an initial classification model stored in a storage module of the terminal to the electronic device. In response to the file transmission operation, the communication module configured by the terminal may transmit a model file of the initial classification model to the electronic device. Accordingly, the electronic device may receive a model file from the initial classification model of the terminal. The electronic device may then parse the model file of the initial classification model to obtain m operators in the initial classification model. Subsequently, the electronic device may quantize the m operators to promote the operation speed of the initial classification model.
S1002, the electronic equipment determines 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 sequence and the type of the classification processing associated with each operator.
It should be noted that, in order to determine the classification result of the information to be classified, m operators constituting the initial classification model need to perform multiple types of classification processing. That is, the types of m operators are relatively diverse. For example, the m operators may include a convolution operator for implementing a convolution operation, a normalization operator for implementing a normalization operation, a pooling operator for implementing a pooling operation, and the like.
Further, the degree of influence on the classification result determined by the initial classification model is often different due to the operation results obtained by different types of operations. Therefore, the degree of influence of the operation precision of different types of operators on the classification result of the information to be classified is often different. For example, the degree of influence of the operation accuracy of the convolution operation on the classification result of the information to be classified is generally higher than the degree of influence of the operation accuracy of the normalization operation on the classification result of the information to be classified. Also, when the operation order is located before the specific type operator and after the specific type operator, the degree of influence on the classification result of the information to be classified is often different. For example, when one operator is located before the normalization operator, since the normalization operator performs a normalization operation on the operation result of the one operator, the degree of influence of the operation precision of the one operator located before the normalization operator on the classification result of the information to be classified is generally lower than the degree of influence of the operation precision of the one operator located after the normalization operator on the classification result of the information to be classified.
Based on the above, in order to improve the running speed of the initial classification model and ensure the implementation effect of the initial classification model, the electronic device can determine the influence degree level of the classification processing associated with each operator in the m operators on the classification result of the information to be classified, and then preferentially select the operator with lower influence degree on the classification result of the information to be classified for quantization so as to quantize as many operators as possible in the m operators, thereby improving the running speed of the initial classification model more effectively and ensuring the quantization effect of the quantization processing on the initial classification model.
In an implementation manner, after the electronic device obtains m operators in the initial classification model, the operation sequence and the type of classification processing associated with each operator in the m operators can be determined first, then according to the type of classification processing associated with each operator, the influence degree of classification processing associated with each operator on the classification result of the information to be classified is determined, and according to the operation sequence of classification processing associated with each operator, the operators are ordered to obtain the influence degree level of classification processing associated with each operator on the classification result of the information to be classified. In this way, the electronic device can preferentially quantize the operators of the specific type according to the degree of influence level of the classification processing associated with each operator on the classification result of the information to be classified, so as to quantize more operators in the m operators.
In a possible example, the preset initial classification model includes 5 operators, respectively operator a, operator b, operator c, operator d, and operator e. Wherein, the operator d and the operator e are operators of a specific type. In the case where the degree of influence levels corresponding to the 5 operators are not determined, the electronic device may quantize the operator a, the operator b, the operator c, the operator d, and the operator e in order. Then in the process of quantizing the initial classification model by the electronic device, the precision of the initial classification model may meet the precision requirement after the operators a and b are quantized, and then the precision requirement is not met after the operator c is quantized. In this case, the electronic device can only quantize the operators a and b in the initial classification model.
In the case of determining the degree of influence levels corresponding to these 5 operators, the electronic device may preferentially quantize the operator d and the operator e. Then in the process of quantizing the initial classification model by the electronic device, the precision of the initial classification model may meet the precision requirement after the operators d, e, a and b are quantized, and then may not meet the precision requirement after the operator c is quantized. In this case, the electronic device may complete quantization for the four operators operator d, operator e, operator a, and operator b. It can be seen that after determining the impact level corresponding to the m operators that compose the initial classification model, the electronic device may quantize as many operators as possible of the m operators.
S1003, the electronic equipment sequentially executes quantization judgment operation on each operator according to the order of the influence degree grades corresponding to each operator from low to high, so as to obtain at least one target operator.
In one possible manner, the quantization determining operation may be used to determine, as the target operator, an operator for which the classification model obtained after quantization satisfies the first preset condition. The target operator can be an operator which can reduce the operation time consumption of the initial classification model after being quantized and has lower influence on the operation precision of the initial classification model.
In one possible manner, the first preset condition may include that a relative difference between the classification result of the information to be classified determined by the classification model obtained after quantization and the classification result of the information to be classified determined by the initial classification model is smaller than a preset threshold, and that the running time of the classification result determined by the classification model obtained after quantization is smaller than the running time of the classification result determined by the initial classification model. The preset threshold may be preset in the electronic device by a worker.
In an implementation manner, after determining the influence degree levels corresponding to the m operators, the electronic device may sequentially perform quantization judgment operations on the operators according to the order from low to high of the influence degree levels corresponding to the operators, that is, perform quantization judgment operations preferentially on operators with lower influence degrees of the associated classification processing on the classification result of the information to be classified. Specifically, after selecting one operator according to the influence degree level corresponding to each operator, the electronic device may quantize the selected operator. Then, the electronic device may use the quantized selected operator to replace the selected operator before quantization in the initial classification model, so as to obtain an initial classification model after updating the selected operator, that is, a quantized classification model. Then, the electronic device may determine a classification result of the information to be classified based on the quantized classification model, and test the quantized classification model to determine a running time consuming to the classification result, to determine whether the quantized classification model satisfies a first preset condition.
And if the relative difference between the classification result of the information to be classified determined by the classification model obtained after quantization and the classification result of the information to be classified determined by the initial classification model is smaller than a preset threshold value, and the running time of the classification result determined by the classification model obtained after quantization is smaller than the running time of the classification result determined by the initial classification model, determining the selected operator as a target operator. Then, the electronic device may select a subsequent operator in the influence degree levels corresponding to the respective operators on the basis of the initial classification model after updating the selected operator, and then perform a quantization judgment operation on the selected subsequent operator. If not, the electronic device determines that the selected operator is not the target operator. Then, the electronic device may select a subsequent operator in the influence degree levels corresponding to the respective operators on the basis of the initial classification model of the selected operator being not updated, and then perform a quantization judgment operation on the selected subsequent operator. And the electronic equipment executes quantization judgment operation on the m operators according to the influence degree level corresponding to the m operators, so that at least one target operator can be obtained.
S1004, the electronic equipment quantifies 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.
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 difference 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.
In one implementation manner, the calculation time consumption of the initial classification model can be reduced after the target operator is quantized, and the implementation effect of the initial classification model is not affected. Therefore, after obtaining the at least one target operator, the electronic device may quantize the at least one target operator in the initial classification model to generate the target classification model.
In a possible example, in combination with the example in S1002, on the premise of being based on the same precision condition, when the degree of influence level corresponding to each operator is not determined by the preset electronic device, the operator a and the operator b in the initial classification model may be quantized in sequence to obtain the model a. When determining the influence degree level corresponding to each operator, the electronic device may perform quantization judgment operation on each operator according to the influence degree level corresponding to each operator, and after four target operators of operator d, operator e, operator a and operator B are obtained, quantize operator d, operator e, operator a and operator B in the initial classification model to obtain a model B (i.e. a target classification model).
When the GPU1 needs to determine the classification result of the information 1 to be classified, under the condition that the model a is deployed on the GPU1, 3 operators forming the model a are not quantized, namely 2 operators based on fixed point type data, and 3 operators based on floating point type data. Therefore, when the GPU1 invokes the model a to determine the classification result of the information 1 to be classified, 2 operators based on fixed-point data and 3 operators based on floating-point data need to be run.
In the case where the model B (i.e., the object classification model) is deployed on the GPU1, since only 1 of the 5 operators that constitute the model B is unquantized, i.e., 4 of the 5 operators are operators based on fixed-point type data, and 1 is an operator based on floating-point type data. Therefore, when the GPU1 calls the model B to determine the classification result of the information 1 to be classified, 4 operators based on fixed point type data and 1 operator based on floating point type data need to be run.
It can be seen that, compared with the call model a determining that the classification result of the information 1 to be classified needs to run 3 operators based on floating point type data, the call model B (i.e. the target classification model) determining that the classification result of the information 1 to be classified needs to run only 1 operator based on floating point type data. It will be appreciated that the run length required for fixed point data based operators is significantly reduced compared to floating point data based operators. Therefore, the target classification model can process the information 1 more quickly on the premise of ensuring the accuracy.
The technical scheme provided by the embodiment at least brings the following beneficial effects: S1001-S1004 can know that after the electronic device obtains an initial classification model for determining a classification result of information to be classified, according to the operation sequence and the type of classification processing associated with each operator in the initial classification model, the influence degree level of the classification processing associated with each operator on the classification result of the information to be classified can be determined, and further quantization judgment operation is sequentially carried out on each operator according to the order of the influence degree level corresponding to each operator from low to high to obtain at least one target operator, so that each target operator in the initial classification model is quantized to generate a target classification model.
Since the m operators in the initial classification model have different degrees of influence on the classification result of the information to be classified, the operators have different influences on the precision of the initial classification model after being quantized. Based on the method, after the influence degree level of the classification processing associated with each operator in the initial classification model on the classification result of the information to be classified is determined, as many target operators as possible can be selected from m operators according to the order of the influence degree level corresponding to each operator from low to high, so that a plurality of target operators can be further quantized, and a target classification model is generated. Compared with the mode that the general technology relies on manual selection of partial parameters to quantize, the method and the device quantize the models in a mode that the electronic equipment judges the degree of influence one by one, not only can save labor efficiency, but also can ensure that as many operators in the initial classification model are quantized to obtain the target classification model, so that the operation speed of the business application can be improved while the implementation effect of the business application is not influenced.
In one embodiment, in conjunction with fig. 11, in S1002, when the electronic device determines, according to the operation sequence and the type of the classification processing associated with each operator, the degree of influence level of the classification processing associated with each operator on the classification result of the information to be classified, as shown in fig. 12, the disclosure provides an alternative implementation manner, which specifically includes: S1101-S1105.
S1101, the electronic device determines the operation sequence of classification processing associated with the n structural blocks.
In one possible approach, the m operators that make up the initial classification model are typically distributed in individual building blocks. That is, the initial classification model generally includes n structural blocks, and each structural block includes at least one operator of the m operators. n is a positive integer less than m. It should be appreciated that one operator is located in only one structural block.
In one possible manner, any of the structural blocks may be used to perform classification processing (e.g., denoising processing, fusion processing, etc.) associated with information classification with respect to information to be classified. It should be appreciated that the classification process associated with the classification of information by the building block for the information to be classified is implemented based on at least one operator included.
In an implementation manner, after the electronic device analyzes the model file of the initial classification model to obtain n structural blocks, the sequence numbers of the n structural blocks can be sequentially arranged from the structural block with initial operation to the structural block with terminated operation according to the calculation logic of the n structural blocks, so as to determine the operation sequence of classification processing associated with the n structural blocks.
S1102, the electronic equipment determines the influence degree level of the classification processing associated with the n structural blocks on the classification result of the information to be classified according to a first preset rule.
The first preset rule comprises the following steps: when the first and second blocks of the n blocks are both of a preset type and the operation order of the first block is before the operation order of the second block, or when the first block is of a preset type and the second block is not of a preset type, or when the first and second blocks are not of a preset type and the operation order of the first block is before the operation order of the second block, it is determined that the degree of influence of the first block is lower than that of the second block. The preset type structure block is a structure block comprising a preset type operator. The operator with the preset type is an operator with a normalization function; the first structural block is any one of n structural blocks. The second structural block is any one of the n structural blocks except the first structural block.
In one possible manner, for a preset type structure block including a preset type operator, the operation initiation operator and the operation termination operator in the preset type structure block may be preset type operators.
It should be noted that, when the preset type of algorithm is included, the result obtained by processing the data by the preset type of structure block does not need to have excessively high precision. That is, after floating point type data in a preset type structure block is converted into fixed point type data, the initial classification model is less affected by precision.
In a possible example, the preset initial classification model includes 6 blocks, namely, a block 1 with a sequence number of 1, a block 2 with a sequence number of 2, a block 3 with a sequence number of 3, a block 4 with a sequence number of 4, a block 5 with a sequence number of 5, and a block 6 with a sequence number of 6. And, the structural blocks 3 and 5 are preset type structural blocks.
Then, according to the first preset rule, since the structural blocks 3 and 5 are structural blocks of a preset type, and the operation sequence of the structural blocks 3 is located before the operation sequence of the structural blocks 5. Thus, the electronic device can determine that the influence level of the structural block 3 is lower than that of the structural block 5.
Since the structural block 5 is a preset type structural block, and the structural block 1 is not a preset type structural block. Thus, the electronic device can determine that the influence level of the structural block 5 is lower than that of the structural block 1.
Since neither block 1 nor block 2 is a preset type of block, and the order of operation of block 1 is before the order of operation of block 2. Thus, the electronic device can determine that the influence level of the structural block 1 is lower than that of the structural block 2.
By analogy, the electronic device may determine that the influence level of the structural block 3 is a first level, the influence level of the structural block 5 is a second level, the influence level of the structural block 1 is a third level, the influence level of the structural block 2 is a fourth level, the influence level of the structural block 4 is a fifth level, and the influence level of the structural block 6 is a sixth level.
S1103, the electronic device determines the operation sequence of the classification processing associated with at least one operator in each structural block.
Specifically, after analyzing the model file of the initial classification model to obtain n structural blocks, the electronic device may further determine at least one operator included in each structural block, and sequentially arrange the sequence number of at least one operator in each structural block from the operation start operator to the operation end operator according to the calculation logic of each structural block, so as to determine the operation sequence of classification processing associated with at least one operator in each structural block.
S1104, the electronic equipment 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 information to be classified according to a second preset rule.
The second preset rule comprises the following steps: and determining that the influence degree level of the first operator is lower than that of the second operator 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 sequence of the first operator is positioned before the operation sequence of the second operator, or when the next operator of the first operator is the preset type operator and the next operator of the second operator is not the preset type operator, or when the next operator of the first operator and the next operator of the second operator are both not the preset type operator and the operation sequence of the first operator is positioned before the operation sequence of the second operator. The first operator is any operator in the structural block. The second operator is any operator except the first operator in the structural block.
It should be noted that, when the following operator of one operator is a preset type operator, the result output by the one operator is normalized by the following operator. Therefore, the electronic device can determine that the result output by the operator does not need to have excessive precision, that is, after the floating point type data in the operator is converted into the fixed point type data, the precision influence on the preset type structure block is less. Thus, the initial classification model is also less affected by accuracy.
In a possible example, in combination with the example of S1102, the preset structural block 3 includes 6 operators, which are an operator 1 with a sequence number 1, an operator 2 with a sequence number 2, an operator 3 with a sequence number 3, an operator 4 with a sequence number 4, an operator 5 with a sequence number 5, and an operator 6 with a sequence number 6. And, the operator 2 and the operator 6 are preset type operators.
Then according to the second preset rule, since the following operator 2 of the operator 1 and the following operator 6 of the operator 5 are operators of preset type and the operation sequence of the operator 1 is located before the operation sequence of the operator 5. Thus, the electronic device can determine that the degree of influence of operator 1 is lower than operator 5.
Since the latter operator 6 of the operator 5 is a preset type operator and the latter operator 3 of the operator 2 is not a preset type operator. Thus, the electronic device can determine that the degree of influence of operator 5 is lower than operator 2.
Since neither the operator 3 following the operator 2 nor the operator 4 following the operator 3 is a preset type of operator, and the operation order of the operator 2 is located before the operation order of the operator 3. Thus, the electronic device can determine that the degree of influence of operator 2 is lower than operator 3.
And so on, the electronic device can determine that the influence degree level of the operator 1 is a first level, the influence degree level of the operator 5 is a second level, the influence degree level of the operator 2 is a third level, the influence degree level of the operator 3 is a fourth level, the influence degree level of the operator 4 is a fifth level, and the influence degree level of the operator 6 is a sixth level.
S1105, the electronic equipment determines the influence degree grade corresponding to each operator according to the influence degree grade corresponding to the n structural blocks and the influence degree grade corresponding to at least one operator in each structural block.
Specifically, after determining 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, the electronic device may sort the n structural blocks according to the influence degree level of each structural block, and sort at least one operator in each structural block according to the influence degree level of at least one operator in each structural block, so as to determine the influence degree level corresponding to each operator.
In a possible example, in combination with the examples of S1102 and S1104, the electronic device may first sort the 6 structural blocks into the structural block 3, the structural block 5, the structural block 1, the structural block 2, the structural block 4 and the structural block 6 according to the influence level corresponding to the 6 structural blocks in the initial classification model. Then, the electronic device may order the 6 operators in the structural block 3 into an operator 1, an operator 5, an operator 2, an operator 3, an operator 4 and an operator 6 according to the influence level corresponding to the 6 operators in the structural block 3. And by analogy, after the operators in the structural blocks 5, 1, 2, 4 and 6 are ordered, the electronic equipment can obtain the corresponding influence degree level of each operator.
The technical scheme provided by the embodiment at least brings the following beneficial effects: as can be seen from S1101 to S1105, a specific implementation manner of determining, by the electronic device, a degree of influence level of the classification processing associated with each operator on the classification result of the information to be classified according to the operation sequence and the type of the classification processing associated with each operator is provided. After the operation sequence of the classification processing associated with the n structural blocks is determined, the electronic device determines the influence degree grade of the classification processing associated with the n structural blocks on the classification result of the information to be classified according to a first preset rule, and after the operation sequence of the classification processing associated with at least one operator in each structural block is determined, the influence degree grade of the classification processing associated with at least one operator in each structural block on the classification result of the information to be classified is determined according to a second preset rule, so that the influence degree grade corresponding to the n structural blocks and the influence degree grade corresponding to at least one operator in each structural block are determined. Subsequently, the electronic equipment can determine the target operators according to the influence degree grades corresponding to the m operators, the probability of determining the maximum number of the target operators is improved, and the electronic equipment has higher assurance than manual experience.
In one embodiment, in conjunction with fig. 11, in S1003, the electronic device sequentially performs quantization determining operations on each operator according to the order of the level of influence corresponding to each operator from low to high, and when at least one target operator is obtained, as shown in fig. 13, the disclosure provides an alternative implementation manner, which specifically includes: S1201-S1204.
S1201, the electronic equipment quantizes each operator in the current operator set to obtain a current classification model.
Wherein the current operator set comprises: the corresponding influence degree level of each operator is the ith operator and the target operator in the first i-1 operators in the sequence from low to high. i is a positive integer less than or equal to m. The current classification model is a quantized model corresponding to the ith operator.
In a possible example, in combination with the example in S1002, the influence degree levels corresponding to the 5 operators in the initial classification model are preset to be operator d, operator e, operator a, operator b and operator c. When the electronic device starts to execute the quantization judgment operation on the 5 operators based on the influence degree grades corresponding to the 5 operators, namely, when i is equal to 1, the current operator set comprises the first operator (namely, operator d) in the sequence from low to high of the influence degree grades corresponding to the 5 operators, and no target operator exists at the moment. In this case, after the electronic device quantizes the first operator (i.e., operator d), the unquantized operator d in the initial classification model may be replaced by the quantized operator d, so as to obtain the current classification model, i.e., the quantized model obtained corresponding to the operator d.
Next, if the operator d is determined to be the target operator, if i is equal to 2, the current operator set includes the second operator (i.e., operator e) and operator d in the order of the 5 operators from low to high in the degree of influence level. In this case, after the electronic device quantizes the operator d and the operator e, the unquantized operator d in the initial classification model may be replaced by the quantized operator d, and the unquantized operator e in the initial classification model may be replaced by the quantized operator e, so as to obtain the current classification model, that is, the quantized model corresponding to the operator e.
S1202, when the current classification model accords with a first preset condition, the electronic equipment determines an ith operator as a target operator and updates the value of i.
In one possible manner, the first preset condition may further include: 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 smaller than or equal to a preset threshold value, and the running time of the current classification model to the classification result is smaller than a current time length threshold value. The current duration threshold determines the running time consumption to the classification result for the classification model obtained after quantizing each target operator in the current operator set.
In an implementation manner, when the current classification model meets the first preset condition, the operation precision of the current classification model can be indicated to meet the requirement. And, since the current time length threshold is the time consumption of the operation of the model obtained after the target operator in the current operator set is quantized, that is, the time consumption of the operation of the last current classification model before the current classification model is obtained by the current time length threshold. Therefore, if the running time of the current classification model is smaller than the current time threshold, the running time of the current classification model can be indicated to be lower than the running time of the current classification model determined before, namely, the running time of the current classification model can be indicated to be shortest, and the calculation speed can be improved and the calculation precision can be ensured after the ith operator is quantized. In this case, the electronic device may determine the ith 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 impact level corresponding to each operator.
And S1203, when the current classification model does not accord with the first preset condition, the electronic equipment updates the value of i.
In one implementation manner, when the current classification model does not meet the first preset condition, it is indicated that the operation speed of the initial classification model cannot be improved after the ith operator is quantized. Or, the ith operator can improve the operation speed of the initial classification model after being quantized, but cannot guarantee the operation precision. In these cases, the ith operator may not 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.
And S1204, the electronic equipment repeatedly quantizes each operator in the current operator set until i is greater than m, and at least one target operator is obtained.
In one implementation manner, after updating the value of i, i.e., increasing the value of i by 1, the electronic device may update the current operator set according to the value of i (i.e., i+1) after increasing the value of i, 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 a first preset condition. And so on until i is greater than m, the electronic device may obtain at least one target operator.
In a possible example, in combination with the example in S1201, the influence degree levels corresponding to the 5 operators in the initial classification model are preset to be operator d, operator e, operator a, operator b and operator c. When the electronic device starts to execute the quantization judgment operation on the 5 operators based on the influence degree grades corresponding to the 5 operators, namely, when i is equal to 1, the current operator set comprises the first operator (namely, operator d) in the sequence from low to high of the influence degree grades corresponding to the 5 operators, and no target operator exists at the moment.
Then, if the current classification model obtained after each operator in the current operator set is quantized meets a first preset condition, the electronic device can determine the operator d as a target operator and increment the value of i by 1. At this point i is equal to 2, the current operator set is: operator d and a second operator (i.e., operator e).
Then, if the current classification model obtained after each operator in the current operator set is quantized meets a first preset condition, the electronic device can determine an operator d and an operator e as target operators, and increment the value of i by 1. At this point i is equal to 3, the current operator set is: operator d, operator e and a third operator (i.e. operator a).
Then, if the current classification model obtained after each operator in the current operator set is quantized does not meet the first preset condition, the electronic device may determine the operator d and the operator e as target operators, and increment the value of i by 1. At this point i is equal to 4, the current operator set is: operator d, operator e and fourth operator (i.e. operator b).
Then, if the current classification model obtained after each operator in the current operator set is quantized meets a first preset condition, the electronic device can determine an operator d, an operator e and an operator b as target operators, and increment the value of i by 1. At this point i is equal to 5, the current operator set is: operator d, operator e, operator b, and a fifth operator (i.e., operator c).
Then, if the current classification model obtained after each operator in the current operator set is quantized does not meet the first preset condition, the electronic device can determine an operator d, an operator e and an operator b as 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 satisfied, and the electronic apparatus ends executing the quantization judgment operation.
In this way, the electronic device can obtain a target operator comprising operator d, operator e and operator b.
The technical scheme provided by the embodiment at least brings the following beneficial effects: as can be seen from S1201-S1204, a specific implementation manner of performing, by an electronic device, quantization judgment operations on each operator sequentially according to the order from low to high of the impact level corresponding to each operator is provided. The electronic device quantizes each operator in the current operator set to obtain a current classification model, and then can judge whether the current classification model meets a first preset condition. If yes, the electronic device can determine the ith operator as a target operator conforming to the quantization condition, and increment the value of i by 1. If not, the electronic equipment directly increases the value of i by 1. The electronic device may then repeat the quantization of each operator in the current set of operators until i is greater than m, resulting in at least one target operator.
In one embodiment, when the electronic device quantizes each operator in the current operator set to obtain the current classification model, as shown in fig. 14, the disclosure provides an alternative implementation, specifically including: S1301-S1303.
S1301, the electronic equipment quantizes each target operator according to a target quantization algorithm corresponding to each target operator in the current operator set to obtain a first model.
It should be noted that, when the current operator set includes the target operator, it indicates that the electronic device has quantized the target operator before and has determined the target quantization mode corresponding to the target operator. In this case, the electronic device may quantize each target operator according to a target quantization algorithm corresponding to each target operator in the current operator set, so as to obtain the first model. Specifically, for a specific description of this case, reference may be made to the following specific implementation manner of S1302-S1303, which will not be described herein.
When the current operator set does not comprise the target operator, the current operator set is indicated to be the first operator set, or the current operator set before updating the current operator set does not accord with the first preset condition. In this case, the electronic device may determine that the first model is not present.
S1302, the electronic equipment quantizes the ith operator according to a plurality of preset quantization algorithms based on the first model to obtain a plurality of second models which are in one-to-one correspondence with the preset quantization algorithms.
It should be noted that, when quantization is performed for an operator for processing at least two variables, a scale factor (scale) may be generally determined first to convert floating point type data in the one operator into fixed point type data. Since the scale factor is determined, the range of values of floating point type data and the range of values of fixed point type data are 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 appreciated that, regarding the specific determination formula of the scaling factor, those skilled in the art can understand with reference to the prior art, and will not be described herein.
In one possible way, the fixed-point data may be set to be of the int16 type, and the fixed-point data may have a range of values (-32768, +32767). And after setting the fixed-point data as the Int16 type to obtain the target classification model, if the target classification model with the fixed-point data as the Int8 type needs to be obtained, changing the scaling factor obtained when the fixed-point data as the Int16 type can directly obtain the target classification model with the Int8 type. Meanwhile, the model error between a target classification model obtained based on the fixed point type data as the int16 type and an initial classification model based on the floating point type data as the fp16 type is smaller than 1/215, and the theoretical precision of the target classification model and the initial classification model is in the same magnitude position. The model error between the target classification model based on the fixed point type data for the int16 type and the initial classification model based on the floating point type data for the fp32 type is also between 10e-2 and 10 e-3.
Also, there are typically multiple calibration algorithms in determining the minimum and maximum values of floating point type data in the one operator. Such as algorithms for unordered state measurement (entopy), mean-square error (MSE), and percentile (percentile) methods. In addition, there are a plurality of count reservation methods after obtaining the scaling factor from the value range of the floating point type data and the value range of the fixed point type data. Such as rounding and rounding up (ceil) algorithms. Meanwhile, each calibration algorithm can also adjust the size of the parameter for calibration when determining the minimum value and the maximum value of floating point type data in the operator. For example, the percentile method may adjust the percentage (percentage) parameter to any value from 0% to 100%.
Algorithms such as quantization per channel (per channel quantization) and quantization per tensor (per tensor quantization) are also typically chosen for quantization against an operator that handles a variable and a weight.
Based on this, in order to reduce errors as much as possible when quantizing the one operator, to obtain as high accuracy as possible, a plurality of preset quantization algorithms are preconfigured in the electronic device of the present disclosure. The plurality of preset quantization algorithms may include a plurality of quantization algorithms based on a percentile method and a rounding method of the plurality of percentile parameters, may further include a plurality of quantization algorithms based on a percentile method and a rounding method of the plurality of percentile parameters, or any one of the quantization algorithms described above may quantize the one operator. And are not listed here.
Specifically, after executing S1301, if the first model does not exist, the electronic device may determine that the current operator set includes only the ith operator. In this case, the electronic device may quantize the ith operator according to a plurality of preset quantization algorithms to obtain a plurality of second models corresponding to the plurality of preset quantization algorithms one by one.
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 ith operator. In this case, the electronic device may quantize the ith operator once according to each preset quantization algorithm, so as to obtain a plurality of quantized ith operators corresponding to a plurality of preset quantization algorithms one by one. Then, the electronic device may combine each quantized ith operator and the first model once to obtain a plurality of second models corresponding to a plurality of preset quantization algorithms one by one.
In a possible example, in combination with the example in S1002, when the current operator set includes the first operator (i.e., the operator d) in the order of the low-to-high degree of influence levels corresponding to the operators, and the target operator is not present, the electronic device may perform S1301 to determine that the first model is not present, and quantize the operator d according to a plurality of preset quantization algorithms, so as to obtain a plurality of second models corresponding to the plurality of preset quantization algorithms one-to-one.
Further, the electronic device may determine a second model meeting a second preset condition from the plurality of second models as the current classification model, and determine a quantization algorithm corresponding to the second model meeting the second preset condition as the target quantization algorithm corresponding to the operator d. Specifically, the process may refer to the descriptions of S1303 and S1401 described below.
Updating the current operator set as follows: when the operator d and the second operator (i.e. the operator e) are used, the electronic device can quantize the operator d according to a target quantization algorithm corresponding to a target operator (i.e. the operator d) in the current operator set so as to obtain a first model. Then, the electronic device quantizes an ith operator (i.e. operator e) in the current operator set according to a plurality of preset quantization algorithms based on the first model, so as to obtain a plurality of second models corresponding to the preset quantization algorithms one by one. Until a plurality of target operators including operator d, operator e and operator b are obtained.
And S1303, the electronic device determines a second model meeting a second preset condition from the plurality of second models as a current classification model.
Wherein the second preset condition includes: the relative difference 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 smaller than or equal to a preset threshold value, and the running time of the second model to the classification result is smaller than or equal to a preset time length threshold value.
In one implementation manner, the electronic device may determine, as the preset second model, a second model that is determined to have the shortest running time to the classification result and determines, as the preset duration threshold, a relative difference between the classification result of the information to be classified determined from the plurality of second models and the classification result of the information to be classified determined from the initial classification model to be less than or equal to the preset threshold.
Based on the above, after obtaining the plurality of second models, the electronic device may determine, as the current classification model, a second model in which a relative difference between a classification result of the information to be classified determined in the plurality of second models and a classification result of the information to be classified determined by the initial classification model is less than or equal to a preset threshold value, and it is determined that a running time to the classification result is less than or equal to a preset time period threshold value. That is, the current classification model is the second model which meets the accuracy requirement among the plurality of second models and has the highest model running speed.
The technical scheme provided by the embodiment at least brings the following beneficial effects: as known from S1301-S1303, a specific implementation manner of the electronic device to quantize each operator in the current operator set to obtain the current classification model is provided. The electronic device may quantize each operator through a plurality of preset quantization algorithms based on the first model in a manner that each operator is a single variable, so as to obtain a plurality of second models, thereby determining a current classification model meeting a second preset condition in the plurality of second models, that is, determining a second model with the best quantization effect as the current classification model. Therefore, the electronic device can evaluate different quantization effects of the plurality of preset quantization algorithms on one operator on the basis of the determined target operator of the target quantization algorithm, so that the preset quantization algorithm most suitable for the one operator is screened out, and the differential evaluation of superiority of the plurality of preset quantization algorithms is realized.
In an example that may be implemented, in conjunction with fig. 14, as shown in fig. 15, the method for generating an information classification model provided in the present disclosure further includes: s1401.
S1401, the electronic device determines a preset quantization algorithm corresponding to a second model meeting a second preset condition as a target quantization algorithm corresponding to an ith operator.
Specifically, after determining the current classification model in the plurality of second models, the electronic device may determine a preset quantization algorithm corresponding to the second model that meets a second preset condition as a target quantization algorithm corresponding to the ith operator. In this way, when the current classification model meets the first preset condition, the electronic device may determine the ith operator in the current operator set as a target operator, and determine a target quantization algorithm corresponding to the ith operator as a target quantization algorithm corresponding to the target operator.
Subsequently, when the target operator (i.e. the ith operator) needs to be quantized, the electronic equipment can conveniently quantize the target operator according to a target quantization algorithm corresponding to the target operator, so that the speed of quantizing the initial classification model is increased.
In a possible example, in combination with the example in S1002, when the current operator set includes the first operator (i.e., operator d) in the order from low to high of the influence level corresponding to each operator, and there is no target operator, if the current classification model obtained after quantization of each operator in the current operator set meets the first preset condition, the electronic device may determine the ith 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 operator d.
Updating the current operator set as follows: when the operator d and the second operator (i.e. the operator e) are used, 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 ith operator (i.e. the operator e) in the current operator set as a target operator, and determine a quantization algorithm corresponding to the current classification model as a target quantization algorithm corresponding to the operator e. Until a target operator comprising an operator d, an operator e and an operator b is obtained, and a target quantization algorithm corresponding to the operator d, a target quantization algorithm corresponding to the operator e and a target quantization algorithm corresponding to the operator b.
The technical scheme provided by the embodiment at least brings the following beneficial effects: as can be seen from S1401, the electronic device may establish a correspondence between the ith operator and the target quantization algorithm in the current operator set after determining, from a plurality of preset quantization algorithms, the target quantization algorithm that is most suitable for the ith operator in the current operator set based on the target operator for which the target quantization algorithm has been determined. In this way, after determining the ith operator in the current operator set as the target operator, the electronic device may conveniently quantize the ith operator in the current operator set.
In one example that may be implemented, in conjunction with fig. 11, in S1004 above, when 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, as shown in fig. 16, the disclosure provides an alternative implementation, which specifically includes: s1501.
S1501, the electronic device quantizes each target operator according to a target quantization algorithm corresponding to each target operator, and generates a target classification model.
Specifically, the electronic device obtains the target quantization algorithm corresponding to each target operator while obtaining the plurality of target operators. Therefore, the electronic device can quantize each target operator according to the target quantization algorithm corresponding to each target operator so as to obtain the target classification model.
In a possible example, in combination with the example in S1401, the plurality of target operators includes an operator d, an operator e, and an operator b. The electronic device may 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 may complete the quantification of the initial classification model to obtain the target classification model.
The technical scheme provided by the embodiment at least brings the following beneficial effects: as can be seen from the above S1501, a specific implementation manner of the electronic device to quantize each target operator in the initial classification model to obtain the target classification model is provided. After the plurality of target operators are obtained, as each target operator corresponds to a target quantization algorithm, the electronic equipment does not need to screen a plurality of preset quantization algorithms, and each target operator in the target operators can be quantized conveniently through the target quantization algorithm corresponding to each target operator so as to obtain a target classification model.
In one embodiment, when the electronic device determines a second model meeting a second preset condition from the plurality of second models as the current classification model, as shown in fig. 17, an alternative implementation provided in the disclosure includes: S1601-S1602.
And S1601, the electronic equipment classifies the information to be classified based on the second model to obtain the operation information of the second model.
The operation information comprises a classification result of the information to be classified, which is determined by the second model, and operation time consumption of the classification result, which is determined by the second model.
Specifically, after the electronic device obtains the second model, the electronic device may classify the information to be classified based on the second model, and monitor an operation process of the second model. Thus, the electronic equipment can obtain the classification result of the information to be classified determined by the second model. Meanwhile, the electronic device can monitor time information of starting operation and stopping operation of the second model to determine time consumption of operation from the second model to the classification result.
S1602, when the relative difference 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 smaller than or equal to a preset threshold value, and the running time consumption of the classification result determined by the second model is smaller than or equal to a preset time length threshold value, the second model is determined to be the current classification model.
It should be noted that, since a large number of parameters in the initial classification model are floating point type data. Therefore, the initial classification model has good precision in classifying results obtained by classifying the information to be classified. Based on this, in order to accurately determine the error of the second model, the electronic device may determine, as the model error of the second model, 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.
In a possible manner, the electronic device may determine, through the first formula, 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. The first formula is:
R=∑abs(r-Q)/∑(r)。
wherein, R is the relative difference (relative difference) 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. And r is a classification result of the information to be classified determined by the second model. Q is the classification result of the information to be classified determined by the initial classification model. Σabs is used to represent the absolute value of the bracketed value. Σ is used to sum all values in brackets.
The technical scheme provided by the embodiment at least brings the following beneficial effects: as can be seen from the above-mentioned S1601 to S902, a specific implementation manner of the electronic device to determine, as the current classification model, a second model that meets a second preset condition from the plurality of second models is provided. The electronic equipment can classify the information to be classified based on the second model to obtain operation information of the second model, and determine that the second model is the current classification model when the relative difference 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 smaller than or equal to a preset threshold value and the operation time consumption of the classification result determined by the second model is smaller than or equal to a preset duration threshold value. Therefore, the electronic device can more accurately determine the quantization effect of the second model and better evaluate the performance of the second model when the second model is actually deployed on a coprocessor such as a GPU.
It will be appreciated that, in actual implementation, the terminal/server according to the embodiments of the present disclosure may include one or more hardware structures and/or software modules for implementing the foregoing corresponding method for generating a picture classification model, where the executing hardware structures and/or software modules may form an electronic device. Those of skill in the art will readily appreciate that the algorithm steps of the examples described in connection with the embodiments disclosed herein may be implemented as hardware or a combination of hardware and computer software. Whether a function is implemented as hardware or computer software driven hardware depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present disclosure.
Based on such understanding, the embodiment of the disclosure also correspondingly provides a device for generating the picture classification model. Fig. 18 shows a schematic structural diagram of a picture classification model generating apparatus provided by an embodiment of the present disclosure. As shown in fig. 18, the picture classification model generation device may include: an acquisition unit 1701, a determination unit 1702, and a processing unit 1703;
an acquisition unit 1701 configured to acquire an initial classification model for determining a classification result of a picture to be classified; the initial classification model comprises m operators; any operator is used for carrying out classification processing associated with picture classification aiming at pictures to be classified; m is a positive integer;
a determining unit 1702 configured to determine, according to an operation order and a type of the classification processing associated with each operator, a degree of influence level of the classification processing associated with each operator on a classification result of the picture to be classified;
a processing unit 1703, configured to sequentially perform quantization judgment operations on the operators according to the order of the corresponding influence degree levels of the operators from low to high, so as to obtain at least one target operator; the quantization judgment operation is used for determining an operator of the classification model obtained after quantization meeting a first preset condition as a target operator;
The processing unit 1703 is further configured to quantize at least one target operator in the initial classification model, generating a target classification model for determining a classification result of the picture to be classified.
Optionally, the initial classification model includes n structural blocks; each structure block includes at least one operator; any structure block is used for carrying out classification processing associated with picture classification aiming at pictures to be classified; n is a positive integer less than m; the determining unit 1702 is specifically configured to: determining the operation sequence of classification processing associated with n structural blocks; determining 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; determining the operation sequence of 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 picture to be classified according to a second preset rule; and determining the influence degree grade corresponding to each operator according to the influence degree grade corresponding to the n structural blocks and the influence degree grade corresponding to at least one operator in each structural block.
Optionally, the first preset rule includes: when the first structural block and the second structural block in the n structural blocks are both the preset type structural blocks and the operation sequence of the first structural block is positioned before the operation sequence 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 the first structural block and the second structural block are not the preset type structural block and the operation sequence of the first structural block is positioned before the operation sequence of the second structural block, determining that the influence degree level of the first structural block is lower than that of the second structural block; the preset type structure block is a structure block comprising a preset type operator; the operator with the preset type is an operator with a normalization function; the first structural block is any one of n structural blocks; the second structural block is any one of the n structural blocks except the first structural block.
Optionally, the second preset rule includes: determining that the degree of influence level of the first operator is lower than that of the second operator 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 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; the first operator is any operator in the structural block; the second operator is any one of the structural blocks except the first operator.
Optionally, the processing unit 1703 is specifically configured to: quantizing each operator in the current operator set to obtain a current classification model; the current operator set includes: the corresponding influence degree level of each operator is from the ith operator and the target operator in the previous i-1 operators in the sequence from low to high; i is a positive integer less than or equal to m; the current classification model is a quantized model corresponding to the ith operator; when the current classification model accords with a first preset condition, determining an ith operator as a target operator, and updating the value of i; the first preset condition includes: the relative difference between the classification result of the picture to be classified determined by the current classification model and the classification result of the picture to be classified determined by the initial classification model is smaller than or equal to a preset threshold value, and the running time of the current classification model to the classification result is smaller than a current time threshold value; the current time length threshold value is used for determining the operation time consumption of the classification result for the classification model obtained after each target operator in the current operator set is quantized; updating the value of i when the current classification model does not accord with the first preset condition; and repeatedly quantizing each operator in the current operator set until i is greater than m, and obtaining at least one target operator.
Optionally, the processing unit 1703 is specifically configured to: quantizing each target operator according to a target quantization algorithm corresponding to each target operator in the current operator set to obtain a first model; based on the first model, respectively quantizing the ith operator according to a plurality of preset quantization algorithms to obtain a plurality of second models which are in one-to-one correspondence with the preset quantization algorithms; and determining a second model meeting a second preset condition from the plurality of second models as a current classification model.
Optionally, the determining unit 1702 is further configured to determine, as the target quantization algorithm corresponding to the ith operator, a preset quantization algorithm corresponding to the second model that meets the second preset condition.
Optionally, the processing unit 1703 is specifically configured to: and quantizing each target operator according to a target quantization algorithm corresponding to each target operator to generate a target classification model.
Optionally, the second preset condition includes: the relative difference 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 smaller than or equal to a preset threshold value, and the running time of the second model to the classification result is smaller than or equal to a preset time length threshold value; the processing unit 1703 is specifically configured to: classifying the pictures to be classified based on the second model to obtain operation information of the second model; the operation information comprises a classification result of the picture to be classified, which is determined by the second model, and operation time consumption of the classification result, which is determined by the second model; and when the relative difference between the classification result of the picture to be classified, which is determined by the second model, and the classification result of the picture to be classified, which is determined by the initial classification model, is smaller than or equal to a preset threshold value, and the running time consumption of the classification result, which is determined by the second model, is smaller than or equal to a preset time length threshold value, determining the second model as the current classification model.
Based on such understanding, the embodiment of the disclosure also correspondingly provides an information classification model generating device. Fig. 19 shows a schematic structural diagram of an information classification model generating apparatus provided by an embodiment of the present disclosure. As shown in fig. 19, the information classification model generation apparatus may include: an acquisition unit 1801, a determination unit 1802, and a processing unit 1803;
an acquisition unit 1801 configured to acquire an initial classification model for determining a classification result of information to be classified; the initial classification model comprises m operators; any operator is used for carrying out classification processing associated with information classification aiming at the information to be classified; m is a positive integer;
a determining unit 1802 configured to determine a degree of influence level of the classification processing associated with each operator on the classification result of the information to be classified, according to an operation order and a type of the classification processing associated with each operator;
a processing unit 1803, configured to sequentially perform quantization judgment operations on the operators according to the order from low to high of the impact level corresponding to the operators, so as to obtain at least one target operator; the quantization judgment operation is used for determining an operator of the classification model obtained after quantization meeting a first preset condition as a target operator;
The processing unit 1803 is further configured to quantize at least one target operator in the initial classification model, and generate a target classification model for determining a classification result of the information to be classified.
Optionally, the initial classification model includes n structural blocks; each structure block includes at least one operator; any structure block is used for carrying out classification processing associated with information classification on the information to be classified; n is a positive integer less than m; the determining unit 1802 is specifically configured to: determining the operation sequence of classification processing associated with n structural blocks; determining the influence degree level of the classification processing associated with the n structural blocks on the classification result of the information to be classified according to a first preset rule; determining the operation sequence of 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 information to be classified according to a second preset rule; and determining the influence degree grade corresponding to each operator according to the influence degree grade corresponding to the n structural blocks and the influence degree grade corresponding to at least one operator in each structural block.
Optionally, the first preset rule includes: when the first structural block and the second structural block in the n structural blocks are both the preset type structural blocks and the operation sequence of the first structural block is positioned before the operation sequence 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 the first structural block and the second structural block are not the preset type structural block and the operation sequence of the first structural block is positioned before the operation sequence of the second structural block, determining that the influence degree level of the first structural block is lower than that of the second structural block; the preset type structure block is a structure block comprising a preset type operator; the operator with the preset type is an operator with a normalization function; the first structural block is any one of n structural blocks; the second structural block is any one of the n structural blocks except the first structural block.
Optionally, the second preset rule includes: determining that the degree of influence level of the first operator is lower than that of the second operator 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 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; the first operator is any operator in the structural block; the second operator is any one of the structural blocks except the first operator.
Optionally, the processing unit 1803 is specifically configured to: quantizing each operator in the current operator set to obtain a current classification model; the current operator set includes: the corresponding influence degree level of each operator is from the ith operator and the target operator in the previous i-1 operators in the sequence from low to high; i is a positive integer less than or equal to m; the current classification model is a quantized model corresponding to the ith operator; when the current classification model accords with a first preset condition, determining an ith operator as a target operator, and updating the value of i; 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 smaller than or equal to a preset threshold value, and the running time of the current classification model to the classification result is smaller than a current time threshold value; the current time length threshold value is used for determining the operation time consumption of the classification result for the classification model obtained after each target operator in the current operator set is quantized; updating the value of i when the current classification model does not accord with the first preset condition; and repeatedly quantizing each operator in the current operator set until i is greater than m, and obtaining at least one target operator.
Optionally, the processing unit 1803 is specifically configured to: quantizing each target operator according to a target quantization algorithm corresponding to each target operator in the current operator set to obtain a first model; based on the first model, respectively quantizing the ith operator according to a plurality of preset quantization algorithms to obtain a plurality of second models which are in one-to-one correspondence with the preset quantization algorithms; and determining a second model meeting a second preset condition from the plurality of second models as a current classification model.
Optionally, the determining unit 1802 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 ith operator.
Optionally, the processing unit 1803 is specifically configured to: and quantizing each target operator according to a target quantization algorithm corresponding to each target operator to generate a target classification model.
Optionally, the second preset condition includes: the relative difference 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 smaller than or equal to a preset threshold value, and the running time of the second model to the classification result is smaller than or equal to a preset time length threshold value; the processing unit 1803 is specifically configured to: classifying the information to be classified based on the second model to obtain operation information of the second model; the operation information comprises a classification result of the information to be classified determined by the second model and operation time consumption from the second model to the classification result; and when the relative difference 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 smaller than or equal to a preset threshold value and the running time consumption of the classification result determined by the second model is smaller than or equal to a preset time length threshold value, determining the second model as the current classification model.
As described above, the embodiments of the present disclosure may divide functional modules for a server according to the above method examples. The integrated modules may be implemented in hardware or in software functional modules. In addition, it should be further noted that the division of the modules in the embodiments of the present disclosure is merely a logic function division, and other division manners may be implemented in practice. For example, each functional module may be divided corresponding to each function, or two or more functions may be integrated in one processing module.
The specific manner in which each module performs the operation and the beneficial effects thereof in the image classification model generating device and the information classification model generating device in the foregoing embodiments are described in detail in the foregoing method embodiments, and are not described herein again.
The embodiment of the disclosure also provides a terminal, which can be a user terminal such as a mobile phone, a computer and the like. Fig. 20 shows a schematic structural diagram of a terminal provided by an embodiment of the present disclosure. The terminal may be a picture classification model generation device and/or an information classification model generation device and may comprise at least one processor 61, a communication bus 62, a memory 63 and at least one communication interface 64.
The processor 61 may be a processor (central processing units, CPU), micro-processing unit, ASIC, or one or more integrated circuits for controlling the execution of the programs of the present disclosure.
Communication bus 62 may include a path to transfer information between the aforementioned components.
The communication interface 64 uses any transceiver-like means for communicating with other devices or communication networks, such as servers, ethernet, radio access network (radio access network, RAN), wireless local area network (wireless local area networks, WLAN), etc.
The memory 63 may be, but is not limited to, a read-only memory (ROM) or other type of static storage device that can store static information and instructions, a random access memory (random access memory, RAM) or other type of dynamic storage device that can store information and instructions, or an electrically erasable programmable read-only memory (electrically erasable programmable read-only memory, EEPROM), a compact disc (compact disc read-only memory) or other optical disk storage, optical disk storage (including compact disc, laser disc, optical disc, digital versatile disc, blu-ray disc, etc.), magnetic disk storage media or other magnetic storage devices, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer. The memory may be stand alone and be connected to the processing unit by a bus. The memory may also be integrated with the processing unit.
Wherein the memory 63 is used for storing application program codes for executing the disclosed scheme and is controlled to be executed by the processor 61. The processor 61 is operative to execute application code stored in the memory 63 to thereby implement the functions in the methods of the present disclosure.
In a particular implementation, as one embodiment, processor 61 may include one or more CPUs, such as CPU0 and CPU1 of FIG. 20.
In a specific implementation, as an embodiment, the terminal may include multiple processors, such as processor 61 and processor 65 in fig. 20. Each of these processors may be a single-core (single-CPU) processor or may be a multi-core (multi-CPU) processor. A processor herein may refer to one or more devices, circuits, and/or processing cores for processing data (e.g., computer program instructions).
In a specific implementation, the terminal may also include an input device 66 and an output device 67, as one embodiment. The input device 66 and the output device 67 communicate and may accept user input in a variety of ways. For example, the input device 66 may be a mouse, keyboard, touch screen device, or sensing device, among others. The output device 67 communicates with the processor 61, and information may be displayed in a variety of ways. For example, the output device 61 may be a liquid crystal display (liquid crystal display, LCD), a light emitting diode (light emitting diode, LED) display device, or the like.
It will be appreciated by those skilled in the art that the structure shown in fig. 20 is not limiting of the terminal and may include more or fewer components than shown, or may combine certain components, or may employ a different arrangement of components.
The embodiment of the disclosure also provides a server. Fig. 21 shows a schematic structural diagram of a server provided by an embodiment of the present disclosure. The server may be a picture classification model generation device and/or an information classification model generation device. The server may vary considerably in configuration or performance and may include one or more processors 71 and one or more memories 72. Wherein the memory 72 stores at least one instruction that is loaded and executed by the processor 71 to implement the picture classification model generation method provided by the above-described respective method embodiments and/or the information classification model generation method provided by the above-described illustrated embodiments. Of course, the server may also have a wired or wireless network interface, a keyboard, an input/output interface, and other components for implementing the functions of the device, which are not described herein.
The present disclosure also provides a computer-readable storage medium including instructions stored thereon, which when executed by a processor of a computer device, enable the computer to perform the method for generating a picture classification model provided by the above-described illustrated embodiment, and/or the method for generating an information classification model provided by the above-described illustrated embodiment. For example, the computer readable storage medium may be a memory 63 comprising instructions executable by the processor 61 of the terminal to perform the above-described method. For another example, the computer readable storage medium may be a memory 72 comprising instructions executable by the processor 71 of the server to perform the above-described method. Alternatively, the computer readable storage medium may be a non-transitory computer readable storage medium, for example, a ROM, RAM, CD-ROM, magnetic tape, floppy disk, optical data storage device, and the like.
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 method of generating a picture classification model as shown in any of the above figures 3-10, and/or the method of generating an information classification model as shown in any of the above figures 11-17.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This disclosure is intended to cover any adaptations, uses, or adaptations of the disclosure following the general principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It is to be understood that the present disclosure is not limited to the precise arrangements and instrumentalities shown in the drawings, and that various modifications and changes may be effected without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims (15)

1. The method for generating the picture classification model is characterized by comprising the following steps of:
acquiring an initial classification model for determining a classification result of a picture to be classified; the initial classification model comprises m operators; any operator is used for carrying out classification processing associated with picture classification on the pictures to be classified; m is a positive integer;
determining the 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 the type of the classification processing associated with each operator;
Sequentially executing quantization judgment operation on each operator according to the order of the corresponding influence degree level of each operator from low to high to obtain at least one target operator; the quantization judgment operation is used for determining the operator of the classification model obtained after quantization meeting a first preset condition as the target operator;
and quantizing the 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.
2. The picture classification model generation method according to claim 1, wherein the initial classification model includes n structural blocks; each of the building blocks comprises at least one of the operators; any one of the structure blocks is used for carrying out classification processing associated with picture classification on the pictures to be classified; n is a positive integer less than m; determining the degree of influence 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 the type of the classification processing associated with each operator, wherein the method comprises the following steps:
determining the operation sequence of 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 picture to be classified according to a first preset rule;
Determining the operation sequence of 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 picture to be classified according to a second preset rule;
and determining the influence degree grade corresponding to each operator according to the influence degree grade corresponding to the n structural blocks and the influence degree grade corresponding to at least one operator in each structural block.
3. The method for generating a picture classification model according to claim 2, wherein the first preset rule includes: determining that the degree of influence level of the first structure block is lower than that of the second structure block when a first structure block and a second structure block of the n structure blocks are both preset type structure blocks and the operation order of the first structure block is located before the operation order of the second structure block, or when the first structure block is the preset type structure block and the second structure block is not the preset type structure block, or when the first structure block and the second structure block are both not the preset type structure block and the operation order of the first structure block is located before the operation order 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 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.
4. A method of generating a picture classification model according to claim 3, wherein the second preset rule comprises: determining that the degree of influence level of the first operator is lower than that of the second operator when the operator following the first operator and the operator following the second operator in the structural block are both the preset type operator 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 the preset type operator and the operator following the second operator is not the preset type operator, or when the operator following the first operator and the operator following the second operator are both not the preset type operator and the operation sequence of the first operator is located before the operation sequence of the second operator; the first operator is any operator in the structural block; the second operator is any operator except the first operator in the structural block.
5. The method for generating a picture classification model according to claim 1, wherein the performing quantization judgment operation on each of the operators in order of low to high degree of influence levels corresponding to each of the operators 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 includes: the ith operator and the target operator in the previous 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 quantized model corresponding to the ith operator;
when the current classification model accords with the first preset condition, determining the ith operator as the target operator, and updating the value of i; the first preset condition includes: the relative difference between the classification result of the picture to be classified, which is determined by the current classification model, and the classification result of the picture to be classified, which is determined by the initial classification model, is smaller than or equal to a preset threshold value, and the running time of the current classification model, which is determined by the current classification model, to the classification result is smaller than a current time length threshold value; the current time length threshold value determines the operation time consumption of a classification result for the classification model obtained after each target operator in the current operator set is quantized;
updating the value of i when the current classification model does not accord with the first preset condition;
And repeatedly quantizing each operator in the current operator set until i is greater than m, and obtaining at least one target operator.
6. The method for generating a classification model of a picture according to claim 5, wherein said quantizing each operator in the current operator set to obtain the 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;
based on the first model, respectively quantizing the ith operator according to a plurality of preset quantization algorithms to obtain a plurality of second models which are in one-to-one correspondence with the plurality of preset quantization algorithms;
and determining a second model meeting a second preset condition from the plurality of second models as the current classification model.
7. The picture classification model generation method according to claim 6, further comprising:
and determining a preset quantization algorithm corresponding to the second model meeting a second preset condition as a target quantization algorithm corresponding to the ith operator.
8. The method according to claim 7, wherein said quantizing the at least one target operator in the initial classification model generates a target classification model for determining a classification result of the picture to be classified, comprising:
And quantizing each target operator according to a target quantization algorithm corresponding to each target operator to generate the target classification model.
9. The method for generating a picture classification model according to claim 6, wherein the second preset condition includes: the relative difference 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 smaller than or equal to the preset threshold value, and the running time of the second model to the classification result is smaller than or equal to the preset time length threshold value; the determining a second model meeting a second preset condition from the plurality of second models as the current classification model includes:
classifying the pictures to be classified based on the second model to obtain operation information of the second model; the operation information comprises a classification result of the picture to be classified, which is determined by the second model, and operation time consumption of the classification result, which is determined by the second model;
and when the relative difference between the classification result of the picture to be classified, which is determined by the second model, and the classification result of the picture to be classified, which is determined by the initial classification model, is smaller than or equal to the preset threshold value, and the running time of the second model, which is determined by the classification result, is smaller than or equal to the preset time threshold value, determining that the second model is the current classification model.
10. An information classification model generation method is characterized by comprising the following steps:
acquiring an initial classification model for determining a classification result of information to be classified; the initial classification model comprises m operators; any operator is used for carrying out classification processing associated with information classification aiming at the information to be classified; m is a positive integer;
determining 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 sequence and the type of the classification processing associated with each operator;
sequentially executing quantization judgment operation on each operator according to the order of the corresponding influence degree level of each operator from low to high to obtain at least one target operator; the quantization judgment operation is used for determining the operator of the classification model obtained after quantization meeting a first preset condition as the target operator;
and quantizing the 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.
11. The method for generating an information classification model according to claim 10, wherein the performing quantization judgment operation on each of the operators in order of low to high degree of influence levels corresponding to each of the operators 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 includes: the ith operator and the target operator in the previous 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 quantized model corresponding to the ith operator;
when the current classification model accords with the first preset condition, determining the ith operator as the target operator, and updating the value of i; 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 smaller than or equal to a preset threshold value, and the running time of the current classification model to the classification result is smaller than a current time length threshold value; the current time length threshold value determines the operation time consumption of a classification result for the classification model obtained after each target operator in the current operator set is quantized;
updating the value of i when the current classification model does not accord with the first preset condition;
And repeatedly quantizing each operator in the current operator set until i is greater than m, and obtaining at least one target operator.
12. A picture classification model generation apparatus, comprising: the device comprises an acquisition unit, a determination unit and a processing unit;
the acquisition unit is configured to acquire an initial classification model for determining a classification result of the picture to be classified; the initial classification model comprises m operators; any operator is used for carrying out classification processing associated with picture classification on the pictures to be classified; m is a positive integer;
the determining unit is configured to determine the influence degree level of the classifying processing associated with each operator on the classifying result of the picture to be classified according to the operation sequence and the type of the classifying processing associated with each operator;
the processing unit is configured to sequentially execute quantization judgment operation on each operator according to the order of the corresponding influence degree level of each operator from low to high to obtain at least one target operator; the quantization judgment operation is used for determining the operator of the classification model obtained after quantization meeting a first preset condition as the target operator;
The processing unit is further configured to quantize the at least one target operator in the initial classification model, and generate a target classification model for determining a classification result of the picture to be classified.
13. An information classification model generation device, characterized by comprising: the device comprises an acquisition unit, a determination unit and a processing unit;
the acquisition unit is configured to acquire an initial classification model for determining classification results of information to be classified; the initial classification model comprises m operators; any operator is used for carrying out classification processing associated with information classification aiming at the information to be classified; m is a positive integer;
the determining unit is configured to determine the influence degree level of the classifying processing associated with each operator on the classifying result of the information to be classified according to the operation sequence and the type of the classifying processing associated with each operator;
the processing unit is configured to sequentially execute quantization judgment operation on each operator according to the order of the corresponding influence degree level of each operator from low to high to obtain at least one target operator; the quantization judgment operation is used for determining the operator of the classification model obtained after quantization meeting a first preset condition as the target operator;
The processing unit is further configured to quantize the at least one target operator in the initial classification model, generating a target classification model for determining a classification result of the information to be classified.
14. An electronic device, the electronic device comprising:
a processor;
a memory for storing the processor-executable instructions;
wherein the processor is configured to execute the instructions to implement the picture classification model generation method of any of claims 1-9 or the information classification model generation method of any of claims 10-11.
15. A computer readable storage medium having instructions stored thereon, which, when executed by a processor of an electronic device, enable the electronic device to perform the picture classification model generation method of any of claims 1-9 or the information classification model generation method of any of claims 10-11.
CN202310063834.6A 2023-01-11 2023-01-11 Picture and information classification model generation method, device, equipment and storage medium Pending CN115994318A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310063834.6A CN115994318A (en) 2023-01-11 2023-01-11 Picture and information classification model generation method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310063834.6A CN115994318A (en) 2023-01-11 2023-01-11 Picture and information classification model generation method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115994318A true CN115994318A (en) 2023-04-21

Family

ID=85991740

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310063834.6A Pending CN115994318A (en) 2023-01-11 2023-01-11 Picture and information classification model generation method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115994318A (en)

Similar Documents

Publication Publication Date Title
EP4033453A1 (en) Training method and apparatus for target detection model, device and storage medium
CN110852438A (en) Model generation method and device
US11436050B2 (en) Method, apparatus and computer program product for resource scheduling
CN113095474A (en) Resource usage prediction for deep learning models
CN109190754A (en) Quantitative model generation method, device and electronic equipment
CN111143039B (en) Scheduling method and device of virtual machine and computer storage medium
US20220101199A1 (en) Point-of-interest recommendation
US20230206024A1 (en) Resource allocation method, resource allocation apparatus, device, medium and computer program produ
CN115205925A (en) Expression coefficient determining method and device, electronic equipment and storage medium
CN115063875A (en) Model training method, image processing method, device and electronic equipment
CN114118433A (en) Recommendation method and device for configuration parameters of equipment
CN112200296A (en) Network model quantification method and device, storage medium and electronic equipment
CN108268936B (en) Method and apparatus for storing convolutional neural networks
CN112084959A (en) Crowd image processing method and device
CN111133458A (en) Enhancing neural networks
CN114091589B (en) Model training method and device, electronic equipment and medium
CN113159188B (en) Model generation method, device, equipment and storage medium for image classification
US20220044109A1 (en) Quantization-aware training of quantized neural networks
CN112966592A (en) Hand key point detection method, device, equipment and medium
CN116915869A (en) Cloud edge cooperation-based time delay sensitive intelligent service quick response method
CN115238837B (en) Data processing method and device, electronic equipment and storage medium
CN115994318A (en) Picture and information classification model generation method, device, equipment and storage medium
US20220383121A1 (en) Dynamic activation sparsity in neural networks
CN115470900A (en) Pruning method, device and equipment of neural network model
CN115249058A (en) Quantification method and device of neural network model, terminal and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination