Face image information processing method and device

CN108256632BActive Publication Date: 2026-10-23BAIDU ONLINE NETWORK TECH (BEIJIBG) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN201810084096.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2018-01-29
Publication Date
2026-10-23
Estimated Expiration
2038-01-29

AI Technical Summary

Benefits of technology

[0025]本申请实施例提供的人脸图像信息处理方法和装置,通过获取目标卷积神经网络的目标卷积层的初始输入信息,从而可以对初始输入信息中的浮点值进行量化取整,以得到整数输入值。接着,可以将整数输入值输入目标卷积层,以与目标卷积层的权重进行卷积运算,生成输出信息。其中,目标卷积层的权重为整数。这样可以有助于提高信息处理的效率。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN108256632B_ABST
    Figure CN108256632B_ABST
Patent Text Reader

Abstract

Embodiments of the present application disclose a face image information processing method and device. A specific implementation of the method comprises: obtaining initial input information of a target convolution layer of a target convolutional neural network; quantizing and rounding the initial input information to obtain an integer input value; inputting the integer input value into the target convolution layer and performing convolution operation on the integer input value and weights of the target convolution layer to generate output information; wherein the weights of the target convolution layer are integers. The implementation helps to improve the speed of information processing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, specifically to the field of neural network technology, and in particular to a method and apparatus for processing facial image information. Background Technology

[0002] The concept of deep learning originates from research on artificial neural networks. Deep learning discovers distributed feature representations of data by combining low-level features to form more abstract high-level representations of attribute categories or features. Deep learning is a new field in machine learning research, motivated by the creation and simulation of neural networks that mimic the human brain's analytical learning processes. It imitates the mechanisms of the human brain to interpret data such as images, sounds, and text.

[0003] Similar to machine learning methods, deep machine learning methods also include supervised and unsupervised learning. The learning models built under different learning frameworks are quite different. For example, Convolutional Neural Networks (CNNs) are a type of deep supervised learning machine learning model; while Deep Belief Networks (DBNs) are a type of unsupervised learning machine learning model. Summary of the Invention

[0004] This application provides a method and apparatus for processing facial image information.

[0005] In a first aspect, embodiments of this application provide a face image information processing method, comprising: obtaining initial input information of the target convolutional layer of a target convolutional neural network; quantizing and rounding the initial input information to obtain an integer input value; inputting the integer input value into the target convolutional layer and performing a convolution operation with the weights of the target convolutional layer to generate output information; wherein the weights of the target convolutional layer are integers.

[0006] In some embodiments, the target convolutional neural network is obtained through the following training steps: obtaining the initial input values ​​and initial weights of the target convolutional layer of the convolutional neural network; determining whether the quantization method for the input values ​​and weights is multi-stage quantization according to a preset quantization ratio; in response to determining that the quantization method for the input values ​​and weights is multi-stage quantization, generating a first input value set and a first weight set according to the initial input values ​​and initial weights respectively; obtaining the quantization ratio of the current stage from the preset quantization ratio; quantizing and rounding each first input value in the first input value set and each first weight in the first weight set according to the quantization ratio of the current stage to generate a second input value set and a second weight set, wherein the second weight set includes the quantized and rounded first weights; performing the following determination steps: using the second weight set as the weights of the target convolutional layer, and determining whether the total quantization ratio of the current stage reaches a preset ratio value; in response to determining that the total quantization ratio of the current stage reaches the preset ratio value, generating the target convolutional neural network.

[0007] In some embodiments, the training step of the target convolutional neural network further includes: in response to determining that the total quantization ratio of the current stage has not reached a preset ratio value, training the convolutional neural network of the current stage according to the loss function to adjust the unquantized first weights in the second weight set until the value of the loss function tends to the target value; obtaining the quantization ratio of the next stage from the preset quantization ratio as the quantization ratio of the current stage; quantizing and rounding the unquantized first input value in the second input value set and the unquantized first weight in the second weight set according to the quantization ratio of the current stage, and continuing to execute the above determination step.

[0008] In some embodiments, according to the quantization ratio of the current stage, each first input value in the first input value set and each first weight in the first weight set are quantized and rounded, including: according to the quantization ratio of the current stage, a corresponding number of first input values ​​and first weights are selected from the first input value set and the first weight set for quantization and rounding, wherein the selection includes selecting from the larger end of the numerical value in descending order, or selecting from the smaller end of the quantization error in ascending order.

[0009] In some embodiments, the training steps of the target convolutional neural network further include: in response to determining that the quantization method for the input values ​​and weights is not multi-stage quantization, dividing the range of the initial input values ​​and the range of the initial weights into a preset number of sub-intervals according to the number of bits of the quantization encoding, wherein the preset number is positively correlated with the number of bits of the quantization encoding; generating a third input value set and a third weight set according to each initial input value and each initial weight located in the preset number of sub-intervals; quantizing and rounding each third input value in the third input value set and each third weight in the third weight set to generate a fourth input value set and a fourth weight set; performing convolution operation using the fourth input value set as input and the fourth weight set as weights of the target convolutional layer; and correcting the initial weights using a backpropagation algorithm until the convolutional neural network meets preset conditions to generate the target convolutional neural network.

[0010] In some embodiments, the range of initial input values ​​and the range of initial weights are divided into a preset number of sub-intervals based on the number of bits of the quantization encoding; a third set of input values ​​and a third set of weights are generated based on each initial input value and each initial weight located in the preset number of sub-intervals, including: scaling down the range of initial input values ​​and the range of initial weights to a preset range, wherein the boundary values ​​of the preset range are integers; uniformly dividing the preset range into a preset number of sub-intervals; using each input value within the preset range as a third input value to generate a third set of input values, and using each weight within the preset range as a third weight to generate a third set of weights.

[0011] In some embodiments, quantizing and rounding each third input value in the third input value set and each third weight in the third weight set to generate a fourth input value set and a fourth weight set includes: quantizing and rounding each third input value in the third input value set according to a preset quantization method, and using the quantized and rounded third input values ​​as fourth input values ​​to generate a fourth input value set; and rounding each third weight in the third weight set up or down according to the probability distribution of each third weight in the third weight set, and using the rounded third weights as fourth weights to generate a fourth weight set.

[0012] In some embodiments, the range of initial input values ​​and the range of initial weights are divided into a preset number of sub-intervals based on the number of bits of quantization encoding; a third input value set and a third weight set are generated based on each initial input value and each initial weight located in the preset number of sub-intervals, including: dividing the range of initial input values ​​and the range of initial weights into a preset number of sub-intervals with different interval lengths based on a preset first value; calculating the logarithm of each initial input value with the first value as the base, using the calculation result as the third input value to generate a third input value set; and determining the interval weight based on each initial weight located in each sub-interval, using it as the third weight to generate a third weight set.

[0013] In some embodiments, quantizing and rounding each third input value in the third input value set and each third weight in the third weight set to generate a fourth input value set and a fourth weight set includes: quantizing and rounding each third input value in the third input value set, and using each quantized and rounded third input value as an exponent to calculate the exponent of a first value as a fourth input value to generate a fourth input value set; sequentially establishing an index for each third weight according to the order of each sub-interval, generating a lookup table, and using the index corresponding to each third weight as a fourth weight to generate a fourth weight set, wherein the index is an integer, and the index and third weight in the lookup table are stored in key-value pair form.

[0014] Secondly, embodiments of this application provide a face image information processing apparatus, comprising: an acquisition unit configured to acquire initial input information of a target convolutional layer of a target convolutional neural network; a quantization unit configured to quantize and round the initial input information to obtain an integer input value; and a generation unit configured to input the integer input value into the target convolutional layer and perform a convolution operation with the weights of the target convolutional layer to generate output information; wherein the weights of the target convolutional layer are integers.

[0015] In some embodiments, the apparatus further includes a training unit, wherein the training unit includes: an acquisition subunit configured to acquire initial input values ​​and initial weights of a target convolutional layer of a convolutional neural network; a determination subunit configured to determine whether the quantization method for the input values ​​and weights is multi-stage quantization according to a preset quantization ratio; a first response subunit configured to, in response to determining that the quantization method for the input values ​​and weights is multi-stage quantization, generate a first input value set and a first weight set according to the initial input values ​​and initial weights; acquire the quantization ratio of the current stage from the preset quantization ratio; quantize and round each first input value in the first input value set and each first weight in the first weight set according to the quantization ratio of the current stage to generate a second input value set and a second weight set, wherein the second weight set includes the quantized and rounded first weights; and perform the following determination steps: using the second weight set as the weights of the target convolutional layer and determining whether the total quantization ratio of the current stage reaches a preset ratio value; and generating a target convolutional neural network in response to determining that the total quantization ratio of the current stage reaches the preset ratio value.

[0016] In some embodiments, the training unit is further configured to: in response to determining that the total quantization ratio of the current stage has not reached a preset ratio value, train the convolutional neural network of the current stage according to the loss function to adjust the unquantized first weights in the second weight set until the value of the loss function tends to the target value; obtain the quantization ratio of the next stage from the preset quantization ratio as the quantization ratio of the current stage; quantize and round the unquantized first input values ​​in the second input value set and the unquantized first weights in the second weight set according to the quantization ratio of the current stage, and continue to execute the above determination steps.

[0017] In some embodiments, the first response subunit is further configured to: select a corresponding number of first input values ​​and first weights from the first input value set and the first weight set respectively for quantization and rounding according to the quantization ratio of the current stage, wherein the selection includes selecting from the larger end of the numerical value in descending order, or selecting from the smaller end of the quantization error in ascending order.

[0018] In some embodiments, the training unit further includes a second response subunit configured to: in response to determining that the quantization method for the input values ​​and weights is not multi-stage quantization, divide the range of the initial input values ​​and the range of the initial weights into a preset number of sub-intervals based on the number of bits of the quantization encoding, wherein the preset number is positively correlated with the number of bits of the quantization encoding; generate a third set of input values ​​and a third set of weights based on each initial input value and each initial weight located in the preset number of sub-intervals; quantize and round each third input value in the third set of input values ​​and each third weight in the third set of weights to generate a fourth set of input values ​​and a fourth set of weights; perform convolution operation using the fourth set of input values ​​as input and the fourth set of weights as weights of the target convolutional layer; and correct the initial weights using a backpropagation algorithm until the convolutional neural network meets a preset condition to generate the target convolutional neural network.

[0019] In some embodiments, the second response subunit is further configured to: shrink both the range of the initial input value and the range of the initial weight to a preset range, wherein the boundary value of the preset range is an integer; uniformly divide the preset range into a preset number of sub-intervals; use each input value within the preset range as a third input value to generate a third input value set, and use each weight within the preset range as a third weight to generate a third weight set.

[0020] In some embodiments, the second response subunit is further configured to: quantize and round each third input value in the third input value set according to a preset quantization method, and use the quantized and rounded third input value as the fourth input value to generate a fourth input value set; and round up or down each third weight in the third weight set according to the distribution probability of each third weight in the third weight set, and use the rounded third weight as the fourth weight to generate a fourth weight set.

[0021] In some embodiments, the second response subunit is further configured to: divide the range of initial input values ​​and the range of initial weights into a preset number of sub-intervals with different interval lengths according to a preset first value; calculate the logarithm of each initial input value with the first value as the base, and use the calculation result as a third input value to generate a third input value set; determine the interval weight according to each initial weight located in each sub-interval, and use it as a third weight to generate a third weight set.

[0022] In some embodiments, the second response subunit is further configured to: quantize and round each third input value in the third input value set, and use each quantized and rounded third input value as an exponent to calculate the exponent of the first value as a fourth input value, thereby generating a fourth input value set; according to the order of each sub-interval, sequentially establish an index for each third weight, generate a lookup table, and use the index corresponding to each third weight as a fourth weight to generate a fourth weight set, wherein the index is an integer, and the index and the third weight in the lookup table are stored in key-value pair form.

[0023] Thirdly, embodiments of this application provide an electronic device, including: one or more processors; a storage device for storing one or more programs; and when the one or more programs are executed by the one or more processors, causing the one or more processors to implement the method described in any of the embodiments of the first aspect above.

[0024] Fourthly, embodiments of this application provide a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the method as described in any of the embodiments of the first aspect above.

[0025] The face image information processing method and apparatus provided in this application obtain the initial input information of the target convolutional layer of a target convolutional neural network, and then quantize and round the floating-point values ​​in the initial input information to obtain integer input values. Next, the integer input values ​​are input to the target convolutional layer for convolution with the weights of the target convolutional layer to generate output information. The weights of the target convolutional layer are integers. This helps improve the efficiency of information processing. Attached Figure Description

[0026] Other features, objects, and advantages of this application will become more apparent from the following detailed description of non-limiting embodiments with reference to the accompanying drawings: Figure 1 This is an exemplary system architecture diagram to which this application can be applied; Figure 2 This is a flowchart of an embodiment of the face image information processing method according to this application; Figure 3 This is a flowchart of one embodiment of the training steps of the convolutional neural network according to this application; Figure 4 This is a flowchart of yet another embodiment of the training steps of the convolutional neural network according to this application; Figure 5 This is a schematic diagram of the structure of an embodiment of the face image information processing apparatus according to this application; Figure 6This is a schematic diagram of the structure of a computer system suitable for implementing the electronic devices of the present application embodiments. Detailed Implementation

[0027] The present application will now be described in further detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and not intended to limit it. Furthermore, it should be noted that, for ease of description, only the parts relevant to the invention are shown in the accompanying drawings.

[0028] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. This application will now be described in detail with reference to the accompanying drawings and embodiments.

[0029] Figure 1 An exemplary system architecture 100 is shown that can be applied to the face image information processing method or face image information processing apparatus of this application.

[0030] like Figure 1 As shown, system architecture 100 may include terminals 101, 102, and 103, network 104, and server 105. Network 104 is used as a medium to provide a communication link between terminals 101, 102, and 103 and server 105. Network 104 may include various connection types, such as wired or wireless communication links or fiber optic cables, etc.

[0031] Users can use terminals 101, 102, and 103 to interact with server 105 via network 104 to receive or send messages, etc. Various client applications can be installed on terminals 101, 102, and 103, such as web browsers, search applications, shopping applications, and instant messaging tools.

[0032] Terminals 101, 102, and 103 can be various electronic devices with displays, including but not limited to smartphones, tablets, e-book readers, laptops, and desktop computers.

[0033] Server 105 can be a server providing various services, such as a backend server supporting various applications displayed on terminals 101, 102, and 103. The backend server can analyze and process the initial input information sent by terminals 101, 102, and 103 to obtain integer input values. These integer input values ​​can then be input into a target convolutional neural network stored thereon for further processing, and the processing results (e.g., generated output information) can be sent to terminals 101, 102, and 103. The weights of the target convolutional layer in the target convolutional neural network are integers.

[0034] It should be noted that the face image information processing method provided in this application embodiment is generally executed by server 105, and correspondingly, the face image information processing device is generally set in server 105.

[0035] It should be understood that Figure 1 The number of terminals, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminals, networks, and servers can be included.

[0036] Continue to refer to Figure 2 This illustrates a flow 200 of an embodiment of a face image information processing method according to this application. The face image information processing method may include the following steps: Step 201: Obtain the initial input information of the target convolutional layer of the target convolutional neural network.

[0037] In this embodiment, the face image information processing method runs on an electronic device (e.g., Figure 1 The server 105 shown can obtain the initial input information of the target convolutional layer of the target convolutional neural network through various methods. For example, it can obtain the initial input information from a terminal (e.g., [unclear]) with which it is communicated via a wired or wireless connection. Figure 1 The terminals 101, 102, and 103 shown (or database servers or cloud servers, etc.) are used to obtain the aforementioned initial input information.

[0038] In this embodiment, the target convolutional neural network can be a convolutional neural network with various functions or uses, such as a convolutional neural network that can be used for face detection or face recognition. The weights of the target convolutional layer in the target convolutional neural network can be integers. A convolutional neural network is generally a feedforward neural network, whose artificial neurons can respond to a portion of the surrounding units within their coverage area, exhibiting excellent performance in large-scale image processing. A convolutional neural network typically includes alternating convolutional layers, pooling layers, and fully connected layers. The target convolutional layer here can be any convolutional layer in the target convolutional neural network.

[0039] It should be noted that when the kernel of a convolutional layer is 1×1, it means that the output of that convolutional layer has the same size as the input. In this case, to avoid introducing errors by quantizing the weights of the convolutional layer to integers, the weights of the convolutional layer can be left unquantized. That is to say, the target convolutional layer may not include convolutional layers with 1×1 kernels.

[0040] Furthermore, the initial input information can be any input information to the target convolutional layer. For example, it could be input information describing a face image; or it could be the output information of the previous convolutional layer. The input values ​​in the initial input information can be integer values ​​or floating-point values.

[0041] It is understood that the storage location of the target convolutional neural network is not limited in this application. For example, it can be stored locally on an electronic device, or on a database server or cloud server. Furthermore, the target convolutional neural network in this embodiment can be obtained through various training methods, which can be found in [reference needed]. Figure 3 and Figure 4 The document shows two embodiments of the training steps for a convolutional neural network, which will not be described in detail here.

[0042] Step 202: Quantize and round the initial input information to obtain an integer input value.

[0043] In this embodiment, the electronic device can use various methods to quantize and round the initial input information obtained in step 201 to obtain an integer input value.

[0044] In some optional implementations of this embodiment, the electronic device first traverses the initial input information to determine the non-integer input values; then, the electronic device quantizes and rounds the determined non-integer input values ​​according to a preset quantization method. Here, the preset quantization method can be set according to actual conditions, such as using a rounding method.

[0045] Alternatively, it can also be used Figure 4 The method for quantizing and rounding the initial input value in the embodiment is used to quantize and round the initial input information, which will not be described in detail here.

[0046] Step 203: Input the integer input value into the target convolutional layer and perform a convolution operation with the weights of the target convolutional layer to generate output information.

[0047] In this embodiment, the electronic device can input the integer input value obtained in step 202 into the target convolutional layer of the target convolutional neural network, so as to perform convolution operation between the integer input value and the integer weights of the target convolutional layer, thereby generating the output information of the target convolutional neural network.

[0048] The face image information processing method provided in this embodiment obtains the initial input information of the target convolutional layer of the target convolutional neural network, and then quantizes and rounds the floating-point values ​​in the initial input information to obtain integer input values. Next, the integer input values ​​are input to the target convolutional layer for convolution with the weights of the target convolutional layer to generate output information. The weights of the target convolutional layer are integers. This allows for integer-to-integer operations, which helps improve the efficiency of information processing.

[0049] See further Figure 3 The diagram illustrates a flow 300 of one embodiment of the training steps for a convolutional neural network according to this application. This training step may include the following steps: Step 301: Obtain the initial input values ​​and initial weights of the target convolutional layer of the convolutional neural network.

[0050] In this embodiment, the face image information processing method runs on an electronic device (e.g., Figure 1 The server 105 shown can also obtain the initial input values ​​and initial weights of the target convolutional layer of the convolutional neural network through various methods. For example, the electronic device can obtain them locally, or through a wired or wireless connection from a terminal (e.g., Figure 1 The information can be obtained from terminals 101, 102, 103, cloud servers, etc.

[0051] Step 302: Determine whether the quantization method for the input value and weight is multi-stage quantization based on the preset quantization ratio.

[0052] In this embodiment, the electronic device can determine whether the quantization method for the input value and weights is multi-stage quantization based on a preset quantization ratio. For example, if there are at least two ratio coefficients in the preset quantization ratio (such as 50%, 70%, and 100%, or 50%, 20%, and 30%), the electronic device can determine that the quantization method is multi-stage quantization. That is, the first stage quantizes to 50% (i.e., quantizes 50%); the second stage quantizes to 70% (i.e., quantizes an additional 20% based on the first stage); and the third stage quantizes to 100% (i.e., quantizes an additional 30% based on the second stage).

[0053] For example, an electronic device can determine whether the initial value (the first value) of the preset quantization ratio is a pre-defined ratio value (such as 100% or 0). If it is a pre-defined ratio value, the electronic device can determine that the quantization method is not multi-stage quantization; if it is not a pre-defined ratio value, the electronic device can determine that the quantization method is multi-stage quantization. It is understandable that in multi-stage quantization, the initial value of the preset quantization ratio is usually between 0 and 100%.

[0054] It should be noted that the method for identifying the initial value of the preset quantization ratio is not limited in this application. For example, an identifier can be added to the initial value, and the initial value can be determined by the identifier; another example is to add a serial number to each ratio coefficient, and the initial value can be determined by the serial number.

[0055] In this embodiment, if the electronic device determines that the quantization method is multi-stage quantization, it can continue to execute steps 303-310; if the electronic device determines that the quantization method is not multi-stage quantization, it can execute... Figure 4 The training steps in this embodiment. The preset quantization ratio here can be pre-stored in an electronic device, obtained from a cloud server or other device, or sent by the user through a terminal.

[0056] Step 303: In response to determining that the quantization method for the input values ​​and weights is multi-stage quantization, a first set of input values ​​and a first set of weights are generated based on the initial input values ​​and initial weights, respectively.

[0057] In this embodiment, after determining that the quantization method is multi-stage quantization, the electronic device can generate a first set of input values ​​and a first set of weights based on the initial input values ​​and initial weights obtained in step 301.

[0058] In some optional implementations of this embodiment, the electronic device can use each initial input value as a first input value to generate a first set of input values. Simultaneously, it can use each initial weight as a first weight to generate a first set of weights.

[0059] Optionally, the electronic device can further divide the range of initial weights into a certain number of sub-intervals; then, based on the initial weights in each sub-interval, the interval weights can be determined as the first weights, thereby generating a first weight set. The division method can include at least one of random, equally spaced, or unequally spaced divisions. The certain number can be set according to the actual situation.

[0060] As an example, the method for generating the first input value set and the first weight set in this embodiment can also be found in [other examples]. Figure 4 The relevant descriptions of generating the third input value set and the third weight set in the embodiments will not be repeated here.

[0061] Step 304: Obtain the current quantization ratio from the preset quantization ratio.

[0062] In this embodiment, the electronic device can obtain the current quantization ratio from a preset quantization ratio. For example, if there are multiple scale coefficients in the preset quantization ratio, the electronic device can select the corresponding scale coefficient according to the current quantization progress to use as the quantization ratio for the current stage. If there is only one scale coefficient in the preset quantization ratio, this scale coefficient will be updated according to the quantization progress, and the electronic device can use it as the quantization ratio for the current stage.

[0063] Step 305: Based on the quantization ratio of the current stage, quantize and round each first input value in the first input value set and each first weight in the first weight set to generate a second input value set and a second weight set.

[0064] In this embodiment, the electronic device can select a corresponding number of first input values ​​and first weights from the first input value set and the first weight set respectively, according to the quantization ratio of the current stage obtained in step 304, and perform quantization and rounding. This generates a second input value set and a second weight set respectively. Then, the determination steps 306-307 are executed. The selection can be random; it can be based on numerical values ​​from largest to smallest, starting from the larger end; or it can be based on quantization error from smallest to largest, starting from the smaller end.

[0065] In this embodiment, the second input value set may include quantized and rounded first input values. The second weight set may include quantized and rounded first weights. It should be noted that before all the first input values ​​in the first input value set are quantized, the second input value set may also include unquantized first input values. Furthermore, before all the first weights in the first weight set are quantized, the second weight set may also include unquantized first weights.

[0066] Step 306: Use the second set of weights as the weights of the target convolutional layer, and determine whether the total quantization ratio of the current stage has reached the preset ratio value.

[0067] In this embodiment, the electronic device can perform the following determination steps: Each weight in the second weight set generated in step 305 can be used as the weight of the target convolutional layer of the convolutional neural network. It can also determine whether the total quantization ratio of the current stage reaches a preset ratio value (e.g., 100%). If the total quantization ratio of the current stage reaches the preset ratio value, step 307 can be continued; if the total quantization ratio of the current stage does not reach the preset ratio value, step 308 can be executed. It can be understood that the total quantization ratio of the current stage can refer to the proportion of the first weights that have been quantized up to the current stage in the second weight set.

[0068] Step 307: In response to determining that the total quantization ratio of the current stage has reached a preset ratio value, generate the target convolutional neural network.

[0069] In this embodiment, if it is determined in step 306 that the total quantization ratio of the current stage reaches a preset ratio value, it indicates that the quantization process has been completed. Then, the electronic device can use the convolutional neural network whose weights in the target convolutional layer are already set with the second weight set as the target convolutional neural network. It is understood that during the generation of the target convolutional neural network, the aforementioned preset ratio value can typically be a constant value.

[0070] Step 308: In response to the determination that the total quantization ratio of the current stage has not reached the preset ratio value, the convolutional neural network of the current stage is trained according to the loss function to adjust the first weights in the second weight set that are not quantized and rounded up, until the value of the loss function tends to the target value.

[0071] In this embodiment, if it is determined in step 306 that the total quantization ratio of the current stage has not reached the preset ratio value, it indicates that the quantization process is not yet complete. The electronic device can then train the convolutional neural network of the current stage according to the loss function to adjust the unquantized, rounded first weights in the second weight set until the value of the loss function approaches the target value. The target value can be set according to the actual situation. That is, in the multi-stage quantization process, the first weight can remain unchanged after being quantized once.

[0072] It should be noted that, in addition to using a loss function, other training methods can also be used to stabilize or converge the convolutional neural network at the current stage (i.e., at the current quantization ratio).

[0073] Step 309: Obtain the quantization ratio for the next stage from the preset quantization ratio as the quantization ratio for the current stage.

[0074] In this embodiment, after the convolutional neural network training in the current stage converges in step 308, the electronic device can obtain the quantization ratio of the next stage from the preset quantization ratio as the quantization ratio of the current stage, so as to perform the quantization process of the next stage.

[0075] Step 310: Based on the quantization ratio of the current stage, quantize and round the first input value that has not been quantized and rounded in the second input value set and the first weight that has not been quantized and rounded in the second weight set, and continue to execute the above determination steps.

[0076] In this embodiment, the electronic device can select a corresponding number of first input values ​​from the unquantized first input values ​​in the second input value set for quantization and rounding, based on the quantization ratio of the current stage in step 309, and update the second input value set. Simultaneously, it selects a corresponding number of first weights from the unquantized first weights in the second weight set for quantization and rounding, and updates the second weight set. The selection method here can be the same as the selection method described above. Afterwards, the above determination steps can continue to be executed.

[0077] Understandably, to improve the efficiency of generating the target convolutional neural network, this embodiment can perform multi-stage quantization only on the weights of the target convolutional layer, while the initial input values ​​of the target convolutional layer can be fully quantized and rounded to generate the second set of input values. At this point, the second set of input values ​​does not contain any unquantized and rounded first input values. Thus, in subsequent quantization stages, it is unnecessary to process and update the second set of input values, thereby simplifying the process. Simultaneously, since the input values ​​of the target convolutional layer (i.e., the second set of input values) remain unchanged in each quantization stage, it helps to ensure the accuracy of the weights of the target convolutional layer in the generated target convolutional neural network.

[0078] The training steps of the convolutional neural network in this embodiment can achieve multi-stage quantization. This allows for adjustment of the processing precision of the convolutional neural network for different quantization stages (quantization ratios), thereby improving training flexibility. Furthermore, the multi-stage quantization process facilitates problem identification and resolution.

[0079] See also Figure 4 This illustrates a flow 400 of another embodiment of the training steps for a convolutional neural network according to this application. The training steps may include the following steps: Step 401: In response to determining that the quantization method for the input value and weight is not multi-stage quantization, the range of the initial input value and the range of the initial weight are divided into a preset number of sub-intervals according to the number of bits of the quantization code.

[0080] In this embodiment, the face image information processing method runs on an electronic device (e.g., Figure 1 Server 105 shown), if in Figure 3 In step 302 of the embodiment, if it is determined that the quantization method is not multi-stage quantization, then the range of the initial input values ​​and the range of the initial weights obtained in step 301 can be divided into a preset number of sub-intervals based on the number of bits in the quantization code. Here, the number of bits in the quantization code can be the number of bits in the code used by the electronic device to record and transmit information, such as the number of bits in binary code, the number of bits in decimal code, etc. The preset number can be positively correlated with the number of bits in the quantization code.

[0081] In some optional implementations of this embodiment, the electronic device can acquire data using a uniform quantization method. That is, the electronic device can first scale down the range of both the initial input values ​​and the initial weights to a preset range. The boundary values ​​of the preset range are integers. Then, the preset range can be uniformly divided into a preset number of sub-intervals.

[0082] For example, the quantization encoding can have 8 bits, meaning the binary encoding has 8 bits. If the initial weight range is [a, b], this range can first be normalized to [0, 1]; then scaled down to [0, 2]. 8 Within the range of ]; then [0,2 8 The weight range of [0,1] can be evenly divided into 256 sub-intervals, each with a length of 1. Alternatively, the normalized weight range of [0,1] can first be evenly divided into 256 sub-intervals, each with a length of 1 / 256; then it can be scaled down to [0,2]. 8 Within the range of ], the boundary values ​​of each sub-interval are integers, such as [0,1], [1,2], [2,3], etc.

[0083] Optionally, the electronic device can also employ a logarithmic quantization method. That is, the electronic device can divide the range of the initial input value and the range of the initial weights into a preset number of sub-intervals of different lengths based on a preset first value. The first value can be any positive integer other than 1. For example, the number of bits in the quantization encoding can also be 8, and the range of the initial weights is [a, b]. If the first value is r, then the range can be divided into intervals with lengths of (ba) / r and (ba) / r respectively. 2 、(ba) / r 3 ···(ba) / r 256 256 sub-intervals.

[0084] Step 402: Generate a third set of input values ​​and a third set of weights based on each initial input value and each initial weight located in a preset number of sub-intervals.

[0085] In this embodiment, the electronic device can generate a third input value and a third weight based on the input values ​​and weights of the preset number of sub-intervals divided in step 401.

[0086] In some optional implementations of this embodiment, for the uniform quantization method, the electronic device can quantize within a preset range (e.g., [0, 2...). 8 The third input value set is generated by taking each input value within the sub-intervals [0,1] to [255,256]. Furthermore, a third weight set can be generated by taking each weight within a preset range as the third weight.

[0087] Furthermore, as an example, the electronic device can also determine the interval weights based on the weights located in each sub-interval, thus generating a third set of weights. For instance, the statistical average or median of the weights located in each sub-interval can be used to determine the interval weights.

[0088] Alternatively, for the logarithmic quantification method, the electronic device can calculate the logarithm of each initial input value (e.g., x) with a first value (e.g., r) as the base, and then convert the calculation result (e.g., log...) into the logarithm of each initial input value (e.g., x). r x The electronic device uses the initial weights located in each sub-interval as the third input value to generate a third set of input values. Simultaneously, based on the initial weights located in each sub-interval, the electronic device can determine the interval weights as the third weights, thereby generating a third set of weights. As an example, the electronic device can determine the interval weights as the statistical average or median of the initial weights located in each sub-interval.

[0089] Step 403: Quantize and round each third input value in the third input value set and each third weight in the third weight set to generate a fourth input value set and a fourth weight set.

[0090] In this embodiment, the electronic device can quantize and round each third input value in the third input value set to generate a fourth input value set. It can also quantize and round each third weight in the third weight set to generate a fourth weight set. The quantization and rounding method is not limited in this application.

[0091] In some optional implementations of this embodiment, for the third input value set obtained by the uniform quantization method in step 402, the electronic device can quantize and round each third input value in the third input value set according to a preset quantization method. The quantized and rounded third input values ​​can then be used as fourth input values ​​to generate a fourth input value set. The preset quantization method can be set according to actual conditions, such as using a rounding method.

[0092] Simultaneously, for the third weight set obtained in step 402 using the uniform quantization method, the electronic device can randomize each third weight (rounding up or down) according to the probability distribution of each third weight in the third weight set. The rounded third weights can then be used as fourth weights, thereby generating a fourth weight set. For example, for each third weight within the sub-interval [0,1], if at least half of the third weights are distributed between [0.5,1], then each third weight within that sub-interval can be rounded up, i.e., all quantized weights are rounded to 1. This helps reduce quantization error.

[0093] It should be noted that there are many ways to perform randomization rounding, and this application is not limited to any one of them. For example, a preset probability threshold (such as 0.7) can be used. Thus, for each third weight within the [0,1] sub-interval, if the third weight is greater than or equal to 0.5, the electronic device can perform rounding up with a probability equal to the preset probability threshold. That is, for third weights greater than or equal to 0.5, the probability of rounding up is the preset probability threshold. If the third weight is less than 0.5, the electronic device can perform rounding down with a probability equal to the preset probability threshold. That is, for third weights less than 0.5, the probability of rounding down is the preset probability threshold. This also helps to reduce quantization errors.

[0094] Understandably, using uniform quantization can make the quantized weight distribution more uniform. Simultaneously, randomized rounding can compensate for the reduction in the overall parameter distribution space caused by precision loss, thereby improving the parameter distribution space. Furthermore, the electronic device can also shrink the generated fourth set of input values ​​and fourth set of weights from a preset range back to their original range (i.e., the range of the initial input values ​​and the range of the initial weights).

[0095] Optionally, for the set of third input values ​​obtained by the quantization method in step 402, the electronic device can quantize and round each of the third input values ​​in the set of third input values, i.e., round(log r x Furthermore, the exponent of the first value can be calculated using each of the quantized and rounded third input values ​​as an exponent, i.e., r. y (y = round(log) r x This is used as the fourth input value to generate a fourth input value set. The method of quantization and rounding is not limited in this application; it can be the aforementioned preset quantization method.

[0096] Simultaneously, for the third weight set obtained through the quantization method in step 402, the electronic device can sequentially establish an index for each third weight according to the order of each sub-interval, generating a lookup table. The index corresponding to each third weight can then be used as the fourth weight, generating a fourth weight set. Here, the index is an integer, and the index and third weight in the lookup table can be stored as key-value pairs. For example, based on the numerical value, since [a,(ba) / r] is the first sub-interval, the index corresponding to the third weight located in this sub-interval can be 1. The indexes corresponding to the third weights located in other sub-intervals can be 2, 3, 4, and so on. In other words, using integer indices to replace weights reduces the storage space required by the convolutional neural network. It also avoids actual quantization and rounding of the weights, simplifying the processing and improving computational efficiency. Furthermore, it avoids errors introduced by quantization and rounding.

[0097] Understandably, in some application scenarios, input values ​​can also be stored in the aforementioned lookup table. That is, the lookup table can cover the weights and range of input values ​​for the target convolutional layer. Specifically, the electronic device can sequentially establish input value indices for each third input value according to the order of each sub-interval. The input value indices and the third input values ​​are then stored as key-value pairs in the aforementioned lookup table. In this case, the input value indices can also be used as the fourth input values ​​to generate a fourth set of input values. Here, the input value indices are integers.

[0098] It should be noted that if the third input value in the third input value set is log... r x The electronic device can then store the input value sequence number and the exponent of the first value in the aforementioned lookup table as key-value pairs. Here, the exponent of the first value can be r as described above. y (y = round(log) r x Here, the input value sequence number and the third input value can be in a one-to-one correspondence or a one-to-many relationship, such that the same input value sequence number can correspond to each of the third input values ​​located in the same sub-interval.

[0099] Step 404: Take the fourth set of input values ​​as input and the fourth set of weights as the weights of the target convolutional layer, and perform convolution operation.

[0100] In this embodiment, the electronic device can use the fourth weight set obtained in step 403 as the weight of the target convolutional layer, and can input the fourth input value set obtained in step 403 into the target convolutional layer, so that it can perform convolution operation with the weight of the target convolutional layer.

[0101] It should be noted that, for the logarithmic method, the electronic device can find the corresponding third weight in the generated lookup table based on each fourth weight (i.e., its index) in the fourth weight set, thereby performing the convolution operation. Similarly, if the fourth input value in the fourth input value set is also an index (i.e., the input value index), the electronic device can find the corresponding input value, i.e., the third input value or the exponent of the first value, in the aforementioned lookup table based on each fourth input value in the fourth input value set.

[0102] Step 405: Use the backpropagation algorithm to correct the initial weights until the convolutional neural network meets the preset conditions and generate the target convolutional neural network.

[0103] In this embodiment, since convolutional neural networks typically require multiple training and adjustments to achieve the target requirements, electronic devices can utilize the backpropagation algorithm to... Figure 3The initial weights obtained in step 301 of the embodiment are corrected. With the corrected initial weights, the electronic device can continue execution from step 401 to update the fourth weight set until the convolutional neural network meets the preset conditions. At this point, the electronic device can use the convolutional neural network with the latest fourth weight set as the target convolutional neural network.

[0104] It should be noted that for logarithmic quantization methods, the fourth weight (i.e., its index) in the fourth weight set can remain unchanged. Instead, the third weight corresponding to each index in the lookup table can be updated according to the order of the sub-intervals. The above preset conditions can also be set according to the actual situation, such as ensuring that the error between the output of the quantized target convolutional layer and the original (unquantized) output is within a certain error range.

[0105] In this embodiment, the training steps of the convolutional neural network can employ methods such as uniform quantization and logarithmic quantization for non-multi-stage quantization, which helps improve training efficiency. Furthermore, this approach enriches the methods for generating the target convolutional neural network, increasing the flexibility of the generation process and expanding its applicability.

[0106] Understandably, the target convolutional neural network obtained through the above method can convert floating-point operations into fixed-point operations, thus reducing memory usage and improving processing speed. Experiments show that for general-purpose CPUs (Central Processing Units), the processing speed can be roughly doubled. For FPGAs (Field-Programmable Gate Arrays), the processing speed is essentially on par with that of graphics processing units (GPUs). Furthermore, it can reduce power consumption.

[0107] Furthermore, to ensure a more uniform distribution of the quantized weights, in the training steps of the above embodiments, the electronic device can first statistically analyze the distribution information of the weights before quantizing them, thereby eliminating outliers or scaling the weight values ​​of outliers. Outliers here can be weights arranged in descending order at a certain proportion (e.g., the top 5%) of the largest weights. This process can be included in each training iteration or performed after a certain number of iterations.

[0108] Please see Figure 5 As an implementation of the methods shown in the above figures, this application provides an embodiment of a face image information processing apparatus. This apparatus embodiment is similar to... Figure 2Corresponding to the method embodiments shown, this device can be specifically applied to various electronic devices.

[0109] like Figure 5 As shown, the face image information processing device 500 of this embodiment may include: an acquisition unit 501, configured to acquire initial input information of the target convolutional layer of the target convolutional neural network; a quantization unit 502, configured to quantize and round the initial input information to obtain an integer input value; and a generation unit 503, configured to input the integer input value into the target convolutional layer and perform a convolution operation with the weights of the target convolutional layer to generate output information; wherein the weights of the target convolutional layer are integers.

[0110] In this embodiment, the specific implementation methods of the acquisition unit 501, the quantization unit 502, and the generation unit 503, as well as their beneficial effects, can be found in the respective references. Figure 2 The relevant descriptions of steps 201, 202 and 203 in the illustrated embodiment will not be repeated here.

[0111] In some optional implementations of this embodiment, the device 500 may further include a training unit (not shown in the figure), wherein the training unit may include: an acquisition subunit configured to acquire the initial input values ​​and initial weights of the target convolutional layer of the convolutional neural network; a determination subunit configured to determine whether the quantization method of the input values ​​and weights is multi-stage quantization according to a preset quantization ratio; a first response subunit configured to, in response to determining that the quantization method of the input values ​​and weights is multi-stage quantization, generate a first input value set and a first weight set according to the initial input values ​​and initial weights respectively; acquire the quantization ratio of the current stage from the preset quantization ratio; quantize and round each first input value in the first input value set and each first weight in the first weight set according to the quantization ratio of the current stage to generate a second input value set and a second weight set, wherein the second weight set includes the quantized and rounded first weights; and perform the following determination steps: using the second weight set as the weights of the target convolutional layer and determining whether the total quantization ratio of the current stage reaches a preset ratio value; and generating the target convolutional neural network in response to determining that the total quantization ratio of the current stage reaches the preset ratio value.

[0112] Optionally, the training unit is further configured to: in response to determining that the total quantization ratio of the current stage has not reached a preset ratio value, train the convolutional neural network of the current stage according to the loss function to adjust the unquantized first weights in the second weight set until the value of the loss function approaches the target value; obtain the quantization ratio of the next stage from the preset quantization ratio as the quantization ratio of the current stage; quantize and round the unquantized first input values ​​in the second input value set and the unquantized first weights in the second weight set according to the quantization ratio of the current stage, and continue to execute the above determination steps.

[0113] Furthermore, the first response subunit can be further configured to: select a corresponding number of first input values ​​and first weights from the first input value set and the first weight set respectively for quantization and rounding according to the quantization ratio of the current stage, wherein the selection includes selecting from the larger end of the numerical value in descending order, or selecting from the smaller end of the quantization error in ascending order.

[0114] In some embodiments, the training unit may further include a second response subunit configured to: in response to determining that the quantization method for the input values ​​and weights is not multi-stage quantization, divide the range of the initial input values ​​and the range of the initial weights into a preset number of sub-intervals according to the number of bits of the quantization encoding, wherein the preset number is positively correlated with the number of bits of the quantization encoding; generate a third set of input values ​​and a third set of weights according to each initial input value and each initial weight located in the preset number of sub-intervals; quantize and round each third input value in the third set of input values ​​and each third weight in the third set of weights to generate a fourth set of input values ​​and a fourth set of weights; perform convolution operation using the fourth set of input values ​​as input and the fourth set of weights as weights of the target convolutional layer; and correct the initial weights using a backpropagation algorithm until the convolutional neural network meets a preset condition to generate the target convolutional neural network.

[0115] Optionally, the second response subunit may be further configured to: shrink the range of the initial input value and the range of the initial weight to a preset range, wherein the boundary value of the preset range is an integer; evenly divide the preset range into a preset number of sub-intervals; use each input value in the preset range as a third input value to generate a third input value set, and use each weight in the preset range as a third weight to generate a third weight set.

[0116] As an example, the second response subunit can be further configured to: quantize and round each third input value in the third input value set according to a preset quantization method, and use the quantized and rounded third input value as the fourth input value to generate a fourth input value set; and round up or down each third weight in the third weight set according to the probability distribution of each third weight in the third weight set, and use the rounded third weight as the fourth weight to generate a fourth weight set.

[0117] In addition, the second response subunit can be further configured to: divide the range of initial input values ​​and the range of initial weights into a preset number of sub-intervals with different interval lengths according to a preset first value; calculate the logarithm of each initial input value with the first value as the base, use the calculation result as the third input value, and generate a third input value set; determine the interval weight according to each initial weight located in each sub-interval, use it as the third weight, and generate a third weight set.

[0118] In some application scenarios, the second response subunit can be further configured to: quantize and round each third input value in the third input value set, and use each quantized and rounded third input value as an exponent to calculate the exponent of the first value as the fourth input value, thereby generating a fourth input value set; according to the order of each sub-interval, sequentially establish an index for each third weight, generate a lookup table, and use the index corresponding to each third weight as the fourth weight to generate a fourth weight set, wherein the index is an integer, and the index and the third weight in the lookup table are stored in key-value pair form.

[0119] The following is for reference. Figure 6 It shows a schematic diagram of the structure of a computer system 600 suitable for implementing electronic devices according to embodiments of the present application. Figure 6 The electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.

[0120] like Figure 6 As shown, the computer system 600 includes a central processing unit (CPU) 601, which can perform various appropriate actions and processes based on programs stored in read-only memory (ROM) 602 or programs loaded from storage section 608 into random access memory (RAM) 603. The RAM 603 also stores various programs and data required for the operation of the system 600. The CPU 601, ROM 602, and RAM 603 are interconnected via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0121] The following components are connected to I / O interface 605: an input section 606 including a touchscreen, keyboard, mouse, etc.; an output section 607 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN card, modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to I / O interface 605 as needed. A removable medium 611, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on drive 610 as needed so that computer programs read from it can be installed into storage section 608 as needed.

[0122] Specifically, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 609, and / or installed from removable medium 611. When the computer program is executed by central processing unit (CPU) 601, it performs the functions defined in the methods of this application. It should be noted that the computer-readable medium of this application can be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. The computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this application, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in connection with an instruction execution system, apparatus, or device. In this application, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on a computer-readable medium can be transmitted using any suitable medium, including but not limited to: wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.

[0123] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0124] The units described in the embodiments of this application can be implemented in software or hardware. The described units can also be located in a processor; for example, a processor can be described as including an acquisition unit, a quantization unit, and a generation unit. The names of these units do not necessarily limit the specific unit; for example, an acquisition unit can also be described as "a unit that acquires the initial input information of the target convolutional layer of a target convolutional neural network."

[0125] In another aspect, this application also provides a computer-readable medium, which may be included in the electronic device described in the above embodiments; or it may exist independently and not assembled into the electronic device. The computer-readable medium carries one or more programs, which, when executed by the electronic device, cause the electronic device to: acquire initial input information of the target convolutional layer of the target convolutional neural network; quantize and round the initial input information to obtain an integer input value; input the integer input value into the target convolutional layer and perform a convolution operation with the weights of the target convolutional layer to generate output information; wherein the weights of the target convolutional layer are integers.

[0126] The above description is merely a preferred embodiment of this application and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of the invention involved in this application is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described inventive concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features with similar functions disclosed in this application.

Claims

1. A method for processing facial image information, comprising: Obtain initial input information of the face image of the target convolutional layer of the target convolutional neural network, wherein the target convolutional neural network is a convolutional neural network used for face detection or face recognition, and the initial input information is input information describing the face image; The initial input information is quantized and rounded to obtain an integer input value; The integer input value is input into the target convolutional layer and convolved with the weights of the target convolutional layer to generate output information, wherein the output information is the output information describing the face image after the operation. The weights of the target convolutional layer are integers. The target convolutional neural network is obtained through the following training steps: The process involves: obtaining the initial input values ​​and initial weights of the target convolutional layer of a convolutional neural network; determining whether the quantization method for the input values ​​and weights is multi-stage quantization based on a preset quantization ratio; in response to determining that the quantization method for the input values ​​and weights is multi-stage quantization, generating a first input value set and a first weight set based on the initial input values ​​and the initial weights; obtaining the quantization ratio for the current stage from the preset quantization ratio; and quantizing and rounding each first input value in the first input value set and each first weight in the first weight set according to the quantization ratio for the current stage to generate a second input value set and a second weight set, wherein the second weight set includes the quantized and rounded first weights. In response to the determination that the total quantization ratio of the current stage has not reached the preset ratio value, the convolutional neural network of the current stage is trained according to the loss function to adjust the unquantized first weight in the second weight set until the value of the loss function approaches the target value; the quantization ratio of the next stage is obtained from the preset quantization ratio as the quantization ratio of the current stage; according to the quantization ratio of the current stage, the unquantized first input value in the second input value set and the unquantized first weight in the second weight set are quantized and rounded respectively, and this process is repeated until the total quantization ratio reaches the preset ratio value, generating the target convolutional neural network. In the multi-stage quantization, after the quantization and rounding of the current stage is completed, the quantized and rounded first weight remains unchanged in the training of subsequent stages. In response to the determination that the quantization method for the input values ​​and weights is not multi-stage quantization, the range of the initial input values ​​and the range of the initial weights are divided into a preset number of sub-intervals based on the number of bits in the quantization encoding, wherein the preset number is positively correlated with the number of bits in the quantization encoding; a third set of input values ​​and a third set of weights are generated based on each initial input value and each initial weight located in the preset number of sub-intervals; each third input value in the third set of input values ​​and each third weight in the third set of weights are quantized and rounded to generate a fourth set of input values ​​and a fourth set of weights; the fourth set of input values ​​is used as input, and the fourth set of weights is used as the weights of the target convolutional layer for convolution operation; the initial weights are corrected using the backpropagation algorithm until the convolutional neural network meets preset conditions, thereby generating the target convolutional neural network.

2. The method according to claim 1, wherein, The step of quantizing and rounding each first input value in the first input value set and each first weight in the first weight set according to the quantization ratio of the current stage includes: Based on the current quantization ratio, a corresponding number of first input values ​​and first weights are selected from the first input value set and the first weight set for quantization and rounding. The selection includes selecting from the larger end of the numerical value in descending order, or selecting from the smaller end of the quantization error in ascending order.

3. The method according to claim 1, wherein, The range of the initial input value and the range of the initial weight are divided into a preset number of sub-intervals based on the number of bits of the quantization encoding. Based on the initial input values ​​and initial weights located in a preset number of sub-intervals, a third set of input values ​​and a third set of weights are generated, including: The range of the initial input value and the range of the initial weight are both scaled down to a preset range, wherein the boundary values ​​of the preset range are integers; Divide the preset range evenly into a preset number of sub-intervals; Each input value within a preset range is used as a third input value to generate a third input value set, and each weight within a preset range is used as a third weight to generate a third weight set.

4. The method according to claim 3, wherein, The step of quantizing and rounding each third input value in the third input value set and each third weight in the third weight set to generate a fourth input value set and a fourth weight set includes: According to a preset quantization method, each third input value in the third input value set is quantized and rounded, and the quantized and rounded third input value is used as the fourth input value to generate a fourth input value set. Based on the probability distribution of each third weight in the third weight set, each third weight in the third weight set is rounded up or down, and the rounded third weight is used as the fourth weight to generate the fourth weight set.

5. The method according to claim 1, wherein, The range of the initial input value and the range of the initial weight are divided into a preset number of sub-intervals based on the number of bits of the quantization encoding. Based on the initial input values ​​and initial weights located in a preset number of sub-intervals, a third set of input values ​​and a third set of weights are generated, including: Based on a preset first value, the range of the initial input value and the range of the initial weight are divided into a preset number of sub-intervals with different interval lengths; Using the first value as the base, calculate the logarithm of each initial input value, and use the calculation result as the third input value to generate a third input value set; Based on the initial weights located in each sub-interval, the interval weights are determined and used as the third weights to generate the third weight set.

6. The method according to claim 5, wherein, The step of quantizing and rounding each third input value in the third input value set and each third weight in the third weight set to generate a fourth input value set and a fourth weight set includes: The third input value in the third input value set is quantized and rounded, and the first value is calculated to the power of the first value as the fourth input value, using the quantized and rounded third input value as the exponent. Based on the order of each sub-interval, a sequence number is created for each third weight, a lookup table is generated, and the sequence number corresponding to each third weight is used as the fourth weight to generate a set of fourth weights. The sequence number is an integer, and the sequence number and the third weight in the lookup table are stored in key-value pairs.

7. A facial image information processing device, comprising: The acquisition unit is configured to acquire initial input information of a face image of a target convolutional layer of a target convolutional neural network, wherein the target convolutional neural network is a convolutional neural network for face detection or face recognition, and the initial input information is input information describing the face image. A quantization unit is configured to quantize and round the initial input information to obtain an integer input value. The generation unit is configured to input the integer input value into the target convolutional layer and perform a convolution operation with the weights of the target convolutional layer to generate output information, wherein the output information is the processed output information describing the face image; The weights of the target convolutional layer are integers. The device further includes: a training unit, the training unit comprising: Obtain the sub-unit and configure it to obtain the initial input values ​​and initial weights of the target convolutional layer of the convolutional neural network; Determine the sub-unit and configure it to determine whether the quantization method for the input value and weights is multi-stage quantization based on the preset quantization ratio; The first response unit is configured to respond to determining that the quantization method for the input values ​​and weights is multi-stage quantization, and to generate a first set of input values ​​and a first set of weights based on the initial input values ​​and the initial weights, respectively; and to obtain the quantization ratio for the current stage from the preset quantization ratio. The quantization and rounding unit is configured to quantize and round each first input value in the first input value set and each first weight in the first weight set according to the quantization ratio of the current stage, so as to generate a second input value set and a second weight set, wherein the second weight set includes the quantized and rounded first weights; The second response unit is configured to, in response to determining that the total quantization ratio of the current stage has not reached a preset ratio value, train the convolutional neural network of the current stage according to the loss function to adjust the unquantized first weights in the second weight set until the value of the loss function approaches the target value; obtain the quantization ratio of the next stage from the preset quantization ratio as the quantization ratio of the current stage; quantize and round the unquantized first input value in the second input value set and the unquantized first weight in the second weight set according to the quantization ratio of the current stage, repeating this process until the total quantization ratio reaches the preset ratio value, and generate the target convolutional neural network. In the multi-stage quantization, after the quantization and rounding of the current stage is completed, the quantized and rounded first weights remain unchanged in the training of subsequent stages. The training unit further includes a response subunit, configured for: In response to the determination that the quantization method for the input values ​​and weights is not multi-stage quantization, the range of the initial input values ​​and the range of the initial weights are divided into a preset number of sub-intervals based on the number of bits in the quantization encoding, wherein the preset number is positively correlated with the number of bits in the quantization encoding; a third set of input values ​​and a third set of weights are generated based on each initial input value and each initial weight located in the preset number of sub-intervals; each third input value in the third set of input values ​​and each third weight in the third set of weights are quantized and rounded to generate a fourth set of input values ​​and a fourth set of weights; the fourth set of input values ​​is used as input, and the fourth set of weights is used as the weights of the target convolutional layer for convolution operation; the initial weights are corrected using the backpropagation algorithm until the convolutional neural network meets preset conditions, thereby generating the target convolutional neural network.

8. The apparatus according to claim 7, wherein, The quantization and rounding unit is further configured to: Based on the current quantization ratio, a corresponding number of first input values ​​and first weights are selected from the first input value set and the first weight set for quantization and rounding. The selection includes selecting from the larger end of the numerical value in descending order, or selecting from the smaller end of the quantization error in ascending order.

9. The apparatus according to claim 7, wherein, The response subunit is further configured to: The range of the initial input value and the range of the initial weight are both scaled down to a preset range, wherein the boundary values ​​of the preset range are integers; Divide the preset range evenly into a preset number of sub-intervals; Each input value within a preset range is used as a third input value to generate a third input value set, and each weight within a preset range is used as a third weight to generate a third weight set.

10. The apparatus according to claim 9, wherein, The response subunit is further configured to: According to a preset quantization method, each third input value in the third input value set is quantized and rounded, and the quantized and rounded third input value is used as the fourth input value to generate a fourth input value set. Based on the probability distribution of each third weight in the third weight set, each third weight in the third weight set is rounded up or down, and the rounded third weight is used as the fourth weight to generate the fourth weight set.

11. The apparatus according to claim 7, wherein, The response subunit is further configured to: Based on a preset first value, the range of the initial input value and the range of the initial weight are divided into a preset number of sub-intervals with different interval lengths; Using the first value as the base, calculate the logarithm of each initial input value, and use the calculation result as the third input value to generate a third input value set; Based on the initial weights located in each sub-interval, the interval weights are determined and used as the third weights to generate the third weight set.

12. The apparatus according to claim 11, wherein, The response subunit is further configured to: The third input value in the third input value set is quantized and rounded, and the first value is calculated to the power of the first value as the fourth input value, using the quantized and rounded third input value as the exponent. Based on the order of each sub-interval, a sequence number is created for each third weight, a lookup table is generated, and the sequence number corresponding to each third weight is used as the fourth weight to generate a set of fourth weights. The sequence number is an integer, and the sequence number and the third weight in the lookup table are stored in key-value pairs.

13. An electronic device, comprising: One or more processors; Storage device for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the method as described in any one of claims 1-6.

14. A computer-readable storage medium having a computer program stored thereon, wherein, When the computer program is executed by a processor, it implements the method as described in any one of claims 1-6.