Data normalization method and device, electronic equipment and storage medium
By training the neural network to determine the standard deviation parameter and determining the mean parameter in real time, the problem of the lack of IN quantization schemes is solved, and the inference speed and computational efficiency of the neural network are improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
- Filing Date
- 2022-03-25
- Publication Date
- 2026-07-21
AI Technical Summary
In existing neural networks, the instance normalization (IN) method lacks a quantization scheme, which requires the calculation of the mean and standard deviation parameters in real time during each inference, affecting the inference speed.
By training the target neural network, the standard deviation parameter of the normalization layer is determined, and the mean parameter is determined in real time. Quantization-aware training is used to integrate the standard deviation parameter into the neural network, reducing complex calculations.
It improves the inference speed of neural networks, maintains the characteristic data features of normalized results, and reduces the amount of computation.
Smart Images

Figure CN116861998B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of deep learning technology, and in particular to a data normalization method, apparatus, electronic device, and storage medium. Background Technology
[0002] Normalization is a very common and important technique in neural networks. Currently, common normalization methods include batch normalization (BN) and instance normalization (IN), with different normalization methods typically used based on the functionality of the neural network.
[0003] In existing technologies, after quantize-aware training or post-training quantization, the parameters of Batch Normalization (BN) can be integrated into the convolutional kernels and biases of the neural network. This eliminates the need to determine the mean and standard deviation parameters of BN based on the input data during inference. The mean and standard deviation parameters of Inference (IN) would otherwise need to be calculated in real-time based on the different data for each inference iteration.
[0004] However, existing neural network frameworks only support quantization fusion of Batch Normalization (BN). There is no corresponding quantization scheme to support Inference (IN), which is commonly used in some tasks. This means that neural networks with IN can only calculate parameters such as the mean and standard deviation in real time based on the data of each inference, which seriously affects the inference speed of the neural network. Summary of the Invention
[0005] This application provides a data normalization method, apparatus, electronic device, and storage medium, which can improve the inference speed of neural network models. The technical solution is as follows:
[0006] On the one hand, a data normalization method is provided, the method comprising:
[0007] By training the target neural network, the standard deviation parameter of the normalized layer of the target neural network is determined;
[0008] In response to receiving feature data to be processed, the mean value parameter of the normalization layer of the target neural network is determined based on the feature data;
[0009] Based on the standard deviation parameter and the mean parameter, the feature data is normalized through the normalization layer of the target neural network.
[0010] On the other hand, a data normalization apparatus is provided, the apparatus comprising:
[0011] The first determining module is used to determine the standard deviation parameter of the normalized layer of the target neural network by training the target neural network;
[0012] The second determining module is used to determine the average value parameter of the normalization layer of the target neural network based on the received feature data.
[0013] The normalization module is used to normalize the feature data through the normalization layer of the target neural network based on the standard deviation parameter and the mean parameter.
[0014] On the other hand, an electronic device is provided, the electronic device including a processor and a memory; the memory stores at least one piece of program code, the at least one piece of program code being executed by the processor to implement the data normalization method as described above.
[0015] On the other hand, a computer-readable storage medium is provided that stores at least one piece of program code, the at least one piece of program code being executed by a processor to implement the data normalization method as described above.
[0016] On the other hand, a computer program product is provided, the computer program product storing at least one piece of program code, the at least one piece of program code being executed by a processor to implement the data normalization method as described above.
[0017] In this embodiment of the application, a fixed standard deviation parameter is obtained through neural network training, and the average value parameter of the feature data is determined in real time through the input feature data. In this way, when performing normalization processing, the method of determining the average value parameter in real time can further maintain the characteristics of the feature data. At the same time, the computationally complex standard deviation parameter in the neural network is fixed, thereby reducing the amount of computation in the normalization process and improving the inference speed of the neural network. Attached Figure Description
[0018] Figure 1 A schematic diagram illustrating the implementation environment involved in the data normalization method provided by an exemplary embodiment of this application is shown;
[0019] Figure 2 A flowchart illustrating a data normalization method in an exemplary embodiment of this application is shown;
[0020] Figure 3 A schematic diagram illustrating the data reading range of an exemplary embodiment of this application is shown;
[0021] Figure 4 A flowchart illustrating a data normalization method in an exemplary embodiment of this application is shown;
[0022] Figure 5 A schematic diagram illustrating the data reading range of an exemplary embodiment of this application is shown;
[0023] Figure 6 A flowchart illustrating a data normalization method in an exemplary embodiment of this application is shown;
[0024] Figure 7 A structural block diagram of a data normalization apparatus illustrated in an exemplary embodiment of this application is shown;
[0025] Figure 8 This application shows a structural block diagram of a terminal illustrated in an exemplary embodiment;
[0026] Figure 9 A structural block diagram of a server illustrated in an exemplary embodiment of this application is shown. Detailed Implementation
[0027] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0028] In this article, "multiple" refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. The character " / " generally indicates that the preceding and following related objects have an "or" relationship.
[0029] It should be noted that all information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.), and signals involved in this application have been authorized by the user or fully authorized by all parties, and the collection, use, and processing of related data must comply with the relevant laws, regulations, and standards of the relevant countries and regions. For example, the sample data and feature data involved in this application were obtained with full authorization.
[0030] Figure 1 This is a schematic diagram illustrating the implementation environment of a data normalization method provided in an embodiment of this application. See also... Figure 1 The implementation environment includes: electronic devices, which can be provided as terminal 101 or as server 102, without specific limitations.
[0031] If the electronic device is provided as terminal 101, then terminal 101 trains the neural network, and the trained neural network can be deployed and run on terminal 101. This neural network can be a face recognition model; after training, terminal 101 performs face recognition using this model. Alternatively, the neural network can be an image semantic segmentation model; after training, terminal 101 uses this model to divide the image into regions. In this embodiment, the neural network is not specifically limited.
[0032] If the electronic device is provided as server 102, then server 102 trains the neural network. The trained neural network can be deployed and run on terminal 101. Accordingly, the implementation environment also includes terminal 101, which is connected to server 102 via a wireless or wired network. Terminal 101 uses the trained neural network to perform tasks such as face recognition and image region segmentation.
[0033] Terminal 101 is at least one of a mobile phone, tablet computer, and PC (Personal Computer) device. Server 102 can be at least one of a single server, a server cluster consisting of multiple servers, a cloud server, a cloud computing platform, and a virtualization center.
[0034] Figure 2 This is a flowchart of a data normalization method provided in an embodiment of this application. See also... Figure 2 The method includes:
[0035] Step S201: The electronic device determines the standard deviation parameter of the normalized layer of the target neural network by training the target neural network.
[0036] The target neural network includes various network layers, such as convolutional layers, fully connected layers, activation layers, and normalization layers. The normalization layer includes various parameters, such as standard deviation, mean, rescaling, and translation parameters. Among these, the rescaling and translation parameters are trainable.
[0037] In this embodiment, the standard deviation parameter of the normalized layer in the target neural network is set to a standard deviation parameter that can be obtained through training. In some embodiments, the electronic device uses a standard deviation parameter determination method corresponding to Batch Normalization (BN) to determine the standard deviation parameter of the normalized layer in the target neural network. The average value parameter is set to the average value parameter obtained in real time through feature data. In some embodiments, the electronic device uses an average value parameter determination method corresponding to Instance Normalization (IN) to determine the average value parameter of the normalized layer in the target neural network.
[0038] Step S202: In response to receiving the feature data to be processed, the electronic device determines the average value parameter of the normalization layer of the target neural network based on the feature data.
[0039] In this embodiment, the average value parameter is set to an average value parameter obtained in real time through feature data. In some embodiments, the electronic device uses an average value parameter determination method corresponding to Instance Normalization (IN) to determine the average value parameter of the normalization layer in the target neural network.
[0040] In some embodiments, the feature data X has dimensions [N, H, W, C], where N, H, W, and C represent the number (Batch), height (Height), width (Width), and channel (Channel) of the feature data X, respectively. See also Figure 3 This illustrates a statistical data range for feature data when a normalization layer determines the mean and standard deviation parameters for each set of feature data using the IN method. In this embodiment, the mean parameter of the normalization layer needs to be calculated in real time based on the different feature data at each inference. In some embodiments, the electronic device determines this mean parameter over a data range of H×W, which can be applied to a single instance. Accordingly, the electronic device determines this mean parameter using the following formula.
[0041] Formula 1:
[0042] Where, μ nc (x) represents the average value parameter of the feature data, where H and Q represent the height and width of the feature data x, respectively, and x is the input feature data.
[0043] It should be noted that the electronic device can also use the average value parameter determination method corresponding to Group Normalization (GN) or Layer Normalization (LN) to determine the average value parameter of each group of feature data in the embodiments of this application. In this way, when performing normalization, since the method of calculating the average value parameter in real time is adopted, the normalization characteristics of IN, GN or LN can be maintained during normalization, and the calculation speed of normalization can also be improved.
[0044] Step S203: The electronic device normalizes the feature data based on the standard deviation parameter and the mean parameter through the normalization layer of the target neural network.
[0045] In this embodiment, the electronic device normalizes the feature data based on the standard deviation parameter and the average value parameter, combined with parameters such as rescaling parameter and retranslation parameter, to obtain normalized feature data for subsequent operations.
[0046] In this embodiment of the application, a fixed standard deviation parameter is obtained through neural network training, and the average value parameter of the feature data is determined in real time through the input feature data. In this way, when performing normalization processing, the method of determining the average value parameter in real time can further maintain the characteristics of the feature data. At the same time, the computationally complex standard deviation parameter in the neural network is fixed, thereby reducing the amount of computation in the normalization process and improving the inference speed of the neural network.
[0047] Figure 4 This is a flowchart of a data normalization method provided in an embodiment of this application. See also... Figure 4 The method includes:
[0048] Step S401: The electronic device reads a set of sample data within the data range corresponding to the batch normalization method based on the batch normalization method.
[0049] In some embodiments, the sample data and the feature data have the same dimensions, [N, H, W, C], where N, H, W, and C represent the number of sample data (Batch), data height (Height), data width (Width), and channel (Channel), respectively. See also Figure 5 This paper illustrates a normalization layer that uses batch normalization (BN) to determine the statistical data range of feature data corresponding to individual mean and standard deviation parameters. In this embodiment, during the training of the target neural network, the electronic device uses BN to determine the statistical data range of sample data corresponding to individual mean and standard deviation parameters, thereby determining the standard deviation parameter for each group of sample data. Accordingly, the electronic device determines the standard deviation parameter for each group of sample data within a data range of N×H×W. This solves the problem of internal covariate shift. Since it mainly operates on the batch dimension, normalizing the feature data within the N×H×W range accelerates the convergence speed of the neural network.
[0050] Step S402: The electronic device trains the target neural network using multiple sets of sample data to obtain the standard deviation parameter.
[0051] In some embodiments, the standard deviation parameter of each group of sample data is determined by the following formula 2.
[0052] Formula 2:
[0053] Where, σc (x) represents the standard deviation parameter of channel c, where c represents the channel index, x is the input feature data, ∈ represents a single value to prevent division by zero, N, H, and W represent the number of feature data (Batch), data height (Height), and data width (Width) of x, respectively, and μ c (x) represents the average value parameter of the feature data corresponding to BN.
[0054] In this embodiment, the electronic device determines the standard deviation parameter corresponding to the feature data of each channel through sample data, and determines the standard deviation parameter after training based on the standard deviation parameter of each feature data. In some embodiments, the electronic device determines the standard deviation parameter by performing a weighted summation of each standard deviation parameter obtained during training using a moving average method. Accordingly, the electronic device determines the standard deviation parameter of each group of sample data; and performs a moving average of multiple standard deviation parameters to obtain the standard deviation parameter. This moving average process can be implemented as shown in Formula 3.
[0055] Formula 3: σ mov =momentum*σ mov +(1-momentum)*σ cw
[0056] Where, σ mov σ represents the current standard deviation parameter, and momentum represents the weight of the current standard deviation parameter. The magnitude of momentum can be set as needed, and is not specifically limited in this embodiment. For example, momentum can be 0.99, 0.98, etc. cw The standard deviation parameter was determined for this calculation.
[0057] In this embodiment, the electronic device determines a standard deviation parameter for each set of sample data. It then performs a weighted summation of the standard deviation parameter with the corresponding weight, continuing this process until the last set of sample data is used to determine the standard deviation parameter. Finally, this weighted summation is performed to obtain the final standard deviation parameter. In this way, during neural network training, the electronic device uses a moving average to weightedly sum the standard deviation parameters of multiple sets of sample data to obtain the final standard deviation parameter. This ensures that the standard deviation parameter remains a fixed value in subsequent processing, eliminating the need for complex calculations to obtain it and thus improving the computational speed of the neural network.
[0058] In some embodiments, the average of the standard deviation parameters corresponding to the sample data of the electronic device is used as the standard deviation parameter. In some embodiments, the electronic device performs a moving average on the standard deviation parameters obtained during training to obtain the standard deviation parameter. In some embodiments, the electronic device uses the average of the standard deviation parameters within a target range of values corresponding to the sample data as the standard deviation parameter. The target range of values can be set as needed, and is not specifically limited in this embodiment. For example, the electronic device determines the range of values for the standard deviation parameter based on the distribution of the standard deviation parameters during training.
[0059] It should be noted that, in order to ensure that the sample data are from the same range, the mean parameter used when calculating the standard deviation parameter is the mean parameter determined based on BN, i.e., μ. c (x) represents the average value parameter of the feature data corresponding to BN. In some embodiments, this average value parameter is determined by the method for determining the average value parameter corresponding to BN, and accordingly, the electronic device determines the average value parameter by the following formula four.
[0060] Formula 4:
[0061] Where, μ c (x) represents the average value parameter of the feature data corresponding to BN, where N, H, and W represent the number of feature data (Batch), data height (Height), and data width (Width), respectively, and x is the input feature data.
[0062] Step S403: In response to receiving the feature data to be processed, the electronic device determines the average value parameter of the normalization layer of the target neural network based on the feature data.
[0063] This step is based on the same principle as step S202, and will not be repeated here.
[0064] Step S404: The electronic device normalizes the feature data based on the standard deviation parameter and the mean parameter through the normalization layer of the target neural network.
[0065] This step is based on the same principle as step S203, and will not be repeated here.
[0066] In this embodiment of the application, a fixed standard deviation parameter is obtained through neural network training, and the average value parameter of the feature data is determined in real time through the input feature data. In this way, when performing normalization processing, the method of determining the average value parameter in real time can further maintain the characteristics of the feature data. At the same time, the computationally complex standard deviation parameter in the neural network is fixed, thereby reducing the amount of computation in the normalization process and improving the inference speed of the neural network.
[0067] It's important to note that neural networks are trained using floating-point operations; therefore, the resulting model parameters are also floating-point data. Floating-point neural networks typically involve high computational complexity. To reduce this complexity, quantization is usually performed on the neural network. Please refer to [reference needed]. Figure 6 , Figure 6 This is a flowchart of a data normalization method provided in an embodiment of this application. See also... Figure 6 The method includes:
[0068] Step S601: The electronic device trains the target neural network to determine the standard deviation parameter of the normalized layer of the target neural network. The standard deviation parameter is a fixed value obtained based on the training.
[0069] This step is based on the same principle as step S201, and will not be repeated here.
[0070] Step S602: In response to receiving the feature data to be processed, the electronic device determines the average value parameter of the normalization layer of the target neural network based on the feature data.
[0071] This step is based on the same principle as step S202, and will not be repeated here.
[0072] Step S603: The electronic device quantizes the standard deviation parameter and the average value parameter to obtain the average value parameter and the standard deviation parameter of the fixed point type.
[0073] In this step, the electronic device quantizes both the standard deviation parameter and the mean parameter. The standard deviation parameter is a fixed value; the electronic device uses overquantization to fuse this standard deviation parameter into the target neural network parameters. Correspondingly, the electronic device quantizes the standard deviation parameter to obtain a fixed-point standard deviation parameter. The electronic device fuses the standard deviation parameter into the neural network using either quantize-aware training or post-training quantization. The electronic device also determines the conversion of the fixed-point input data X into floating-point input data during the normalization process. The first quantization parameter, and the conversion of floating-point output data O to fixed-point output data. The second quantization parameter is used to determine the quantization mapping relationship between the fixed-point type input and the vertex type output based on the first and second quantization parameters. Based on this quantization mapping relationship, the standard deviation parameter of the fixed-point type is determined. Accordingly, this process is implemented through the following steps (1)-(3), including:
[0074] (1) The electronic device determines a first quantization parameter and a second quantization parameter through quantization perception training. The first quantization parameter is used by the normalization layer of the target neural network to quantize floating-point input data into fixed-point input data, and the second quantization parameter is used by the normalization layer of the target neural network to quantize floating-point output data into fixed-point output data.
[0075] Specifically, the electronic device can determine a first quantization parameter and a second quantization parameter from sample data. Accordingly, based on the standard deviation parameter and the average value parameter, the electronic device normalizes the fixed-point type sample input data to obtain floating-point type output data; based on the standard deviation parameter and the average value parameter, it determines the floating-point type input data corresponding to the floating-point type output data; based on the floating-point type input data and the fixed-point type sample input data, it determines the first quantization parameter; and based on the fixed-point type sample output data corresponding to the fixed-point type sample input data and the floating-point type output data, it determines the second quantization parameter.
[0076] (2) The electronic device determines the quantization mapping relationship based on the first quantization parameter and the second quantization parameter.
[0077] In this step, the electronic device determines the quantization mapping relationship between fixed-point type input data and fixed-point type output data based on the first quantization parameter and the second quantization parameter.
[0078] (3) The electronic device quantizes the standard deviation parameter based on the quantization mapping relationship to obtain the standard deviation parameter of the fixed point type.
[0079] By quantifying the standard deviation and mean parameters, the computational cost of the neural network is further reduced, thereby improving the inference speed of the neural network.
[0080] Step S604: The electronic device normalizes the feature data based on the mean parameter and standard deviation parameter of the fixed point type through the normalization layer of the target neural network.
[0081] During fixed-point inference, the electronic device normalizes the feature data using quantized parameters. See Formula 5.
[0082] Formula 5:
[0083] Among them, Q o The output features are quantized, X is the input feature data, and round(·) represents the rounding function, such as the rounding function or the round-up function. μ X Int represents the average parameter determined based on feature data. A IntB Both Int and Z are integers used to represent the mapping relationship between floating-point data and fixed-point data. B For powers of 2, divide by Int B The computation can be achieved through bit shifting, which is conveniently implemented in the NPU, thereby improving the computing speed of the Neural-network Processing Unit (NPU) and further improving the inference speed of the neural network.
[0084] In this embodiment, since the standard deviation parameter of the normalization layer is determined during the training process, and thus the standard deviation parameter is a fixed value, the complex calculation related to the standard deviation parameter is avoided when normalizing the feature data through the normalization layer. This allows the neural network to be quantized, further reducing the computational load of the target neural network and improving its computational speed.
[0085] In this embodiment of the application, a fixed standard deviation parameter is obtained through neural network training, and the average value parameter of the feature data is determined in real time through the input feature data. In this way, when performing normalization processing, the method of determining the average value parameter in real time can further maintain the characteristics of the feature data. At the same time, the computationally complex standard deviation parameter in the neural network is fixed, thereby reducing the amount of computation in the normalization process and improving the inference speed of the neural network.
[0086] Please refer to Figure 7 This illustration shows a structural block diagram of a data normalization apparatus according to an embodiment of this application. The data normalization apparatus can be implemented as all or part of a processor through software, hardware, or a combination of both. The apparatus includes:
[0087] The first determining module 701 is used to determine the standard deviation parameter of the normalized layer of the target neural network by training the target neural network.
[0088] The second determining module 702 is used to determine the average value parameter of the normalization layer of the target neural network based on the received feature data.
[0089] The normalization module 703 is used to normalize the feature data through the normalization layer of the target neural network based on the standard deviation parameter and the mean parameter.
[0090] In some embodiments, the normalization module 703 includes:
[0091] A quantization unit is used to quantize the standard deviation parameter and the mean parameter to obtain a fixed-point type mean parameter and a fixed-point type standard deviation parameter;
[0092] The normalization unit is used to normalize the feature data through the normalization layer of the target neural network based on the mean parameter and the standard deviation parameter of the fixed-point type.
[0093] In some embodiments, the quantization unit is used to perform quantization-aware training on the standard deviation parameter to obtain the standard deviation parameter of the fixed-point type; and to perform rounding processing on the mean parameter to obtain the mean parameter of the fixed-point type.
[0094] In some embodiments, the quantization unit is configured to determine a first quantization parameter and a second quantization parameter through quantization-aware training. The first quantization parameter is used by the normalization layer of the target neural network to quantize floating-point input data into fixed-point input data, and the second quantization parameter is used by the normalization layer of the target neural network to quantize floating-point output data into fixed-point output data. Based on the first quantization parameter and the second quantization parameter, the quantization mapping relationship is determined. Based on the quantization mapping relationship, the standard deviation parameter is quantized to obtain the fixed-point standard deviation parameter.
[0095] In some embodiments, the quantization unit is configured to: normalize fixed-point type sample input data based on the standard deviation parameter and the average value parameter to obtain floating-point type output data; determine floating-point type input data corresponding to the floating-point type output data based on the standard deviation parameter and the average value parameter; determine a first quantization parameter based on the floating-point type input data and the fixed-point type sample input data; and determine a second quantization parameter based on the fixed-point type sample output data corresponding to the fixed-point type sample input data and the floating-point type output data.
[0096] In some embodiments, the first determining module 701 includes:
[0097] The reading unit is used to read a set of sample data within the data range corresponding to the batch normalization method based on the batch normalization method;
[0098] The training unit is used to train the target neural network using multiple sets of sample data to obtain the standard deviation parameter.
[0099] In some embodiments, the training unit is used to determine the standard deviation parameter of each group of sample data; and to perform a moving average of multiple standard deviation parameters to obtain the standard deviation parameter of the normalization layer.
[0100] In this embodiment of the application, a fixed standard deviation parameter is obtained through neural network training, and the average value parameter of the feature data is determined in real time through the input feature data. In this way, when performing normalization processing, the method of determining the average value parameter in real time can further maintain the characteristics of the feature data. At the same time, the computationally complex standard deviation parameter in the neural network is fixed, thereby reducing the amount of computation in the normalization process and improving the inference speed of the neural network.
[0101] In this embodiment, the electronic device is provided as a terminal or a server. Please refer to... Figure 8 This diagram illustrates a structural block diagram of a terminal 800 provided in an exemplary embodiment of this application. The terminal 800 may be a smartphone, tablet computer, laptop computer, or wearable device, etc. The terminal 800 in this application may include one or more components such as a processor 810 and a memory 820.
[0102] The processor 810 may include one or more processing cores. The processor 810 connects to various parts within the terminal 800 using various interfaces and lines, and performs various functions and processes data of the terminal 800 by running or executing at least one instruction stored in the memory 820 and calling data stored in the memory 820. Optionally, the processor 810 may be implemented using at least one hardware form of Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), or Programmable Logic Array (PLA). The processor 810 may integrate one or a combination of several of the following: Central Processing Unit (CPU), Graphics Processing Unit (GPU), Neural-network Processing Unit (NPU), and modem. Specifically, the CPU primarily handles the operating system, user interface, and applications; the GPU is responsible for rendering and drawing the content required for display on the screen; the NPU is used to implement Artificial Intelligence (AI) functions; and the modem is used for wireless communication. It is understandable that the aforementioned modem may not be integrated into the processor 810, but may be implemented using a separate chip.
[0103] The memory 820 may include random access memory (RAM) or read-only memory (ROM). Optionally, the memory 820 may include a non-transitory computer-readable storage medium. The memory 820 may be used to store at least one instruction. The memory 820 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as touch function, sound playback function, image playback function, etc.), instructions for implementing the various embodiments described below, etc.; the data storage area may store data created according to the use of the terminal 800 (such as audio data, phone book, etc.).
[0104] In some embodiments, the terminal 800 further includes a display screen, which is a display component for displaying a user interface. Optionally, the display screen is a touch-enabled display screen, through which users can use fingers, styluses, or any suitable object to perform touch operations on the display screen. The display screen is typically located on the front panel of the terminal 800. The display screen can be designed as a full-screen, curved screen, irregularly shaped screen, dual-sided screen, or foldable screen. The display screen can also be designed as a combination of a full-screen and a curved screen, or a combination of an irregularly shaped screen and a curved screen, etc., which are not limited in this embodiment.
[0105] In addition, those skilled in the art will understand that the structure of the terminal 800 shown in the above figures does not constitute a limitation on the terminal 800. The terminal 800 may include more or fewer components than shown, or combine certain components, or have different component arrangements. For example, the terminal 800 may also include a microphone, speaker, radio frequency circuit, input unit, sensor, audio circuit, Wireless Fidelity (Wi-Fi) module, power supply, Bluetooth module, etc., which will not be described in detail here.
[0106] This service manager can be used as a server; please refer to it. Figure 9This diagram illustrates a structural block diagram of a server 900 provided in an exemplary embodiment of this application. The server 900 can vary considerably depending on its configuration or performance, and may include one or more Central Processing Units (CPUs) 910 and one or more memories 920. The memories 920 store at least one instruction, which is loaded and executed by the processor 910 to implement the service invocation methods provided in the various method embodiments described above. Of course, the server 900 may also have wired or wireless network interfaces, a keyboard, and input / output interfaces for input / output. The server 900 may also include other components for implementing device functions, which will not be elaborated upon here.
[0107] This application also provides a computer-readable medium storing at least one instruction that is loaded and executed by the processor to implement the data normalization method shown in the above embodiments.
[0108] This application also provides a computer program product that stores at least one instruction, which is loaded and executed by the processor to implement the data normalization method shown in the above embodiments.
[0109] Those skilled in the art will recognize that the functions described in the embodiments of this application in one or more of the above examples can be implemented using hardware, software, firmware, or any combination thereof. When implemented using software, these functions can be stored in a computer-readable medium or transmitted as one or more instructions or code on a computer-readable medium. Computer-readable media include computer storage media and communication media, wherein communication media include any medium that facilitates the transfer of a computer program from one place to another. Storage media can be any available medium that can be accessed by a general-purpose or special-purpose computer.
[0110] The above description is merely an optional embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A data normalization method, characterized in that, The method includes: Based on the batch normalization method, a set of sample data within the data range corresponding to the batch normalization method is read; Determine the standard deviation parameter for each group of sample data; The standard deviation parameters of the normalized layer of the target neural network are obtained by performing a moving average on multiple standard deviation parameters, wherein the target neural network is a face recognition model or an image semantic segmentation model; In response to receiving feature data to be processed, the mean value parameter of the normalization layer of the target neural network is determined based on the feature data; Based on the standard deviation parameter and the mean parameter, the feature data is normalized through the normalization layer of the target neural network.
2. The method according to claim 1, characterized in that, The normalization process of the feature data based on the standard deviation parameter and the mean parameter, through the normalization layer of the target neural network, includes: The standard deviation parameter and the mean parameter are quantized to obtain the mean parameter and standard deviation parameter of the fixed point type. Based on the mean parameter and standard deviation parameter of the fixed-point type, the feature data is normalized through the normalization layer of the target neural network.
3. The method according to claim 2, characterized in that, The quantization of the standard deviation parameter and the mean parameter to obtain the fixed-point type mean parameter and the fixed-point type standard deviation parameter includes: The standard deviation parameter is subjected to quantization perception training to obtain the standard deviation parameter of the fixed point type; The average value parameter is rounded down to obtain the average value parameter of the fixed-point type.
4. The method according to claim 3, characterized in that, The step of performing quantization-aware training on the standard deviation parameter to obtain the fixed-point type standard deviation parameter includes: Through quantization perception training, a first quantization parameter and a second quantization parameter are determined respectively. The first quantization parameter is used by the normalization layer of the target neural network to quantize floating-point input data into fixed-point input data, and the second quantization parameter is used by the normalization layer of the target neural network to quantize floating-point output data into fixed-point output data. Based on the first quantization parameter and the second quantization parameter, the quantization mapping relationship is determined; Based on the quantization mapping relationship, the standard deviation parameter is quantized to obtain the standard deviation parameter of the fixed-point type.
5. The method according to claim 4, characterized in that, The step of determining the first quantization parameter and the second quantization parameter through quantization perception training includes: Based on the standard deviation parameter and the mean parameter, the fixed-point type sample input data is normalized to obtain floating-point type output data; Based on the standard deviation parameter and the average value parameter, determine the floating-point type input data corresponding to the floating-point type output data; Based on the floating-point type input data and the fixed-point type sample input data, determine the first quantization parameter; The second quantization parameter is determined based on the fixed-point type sample output data corresponding to the fixed-point type sample input data and the floating-point type output data.
6. A data normalization device, characterized in that, The device includes: The first determining module is used to read a set of sample data within the data range corresponding to the batch normalization method based on the batch normalization method; determine the standard deviation parameter of each set of sample data; and perform a moving average on multiple standard deviation parameters to obtain the standard deviation parameter of the normalization layer of the target neural network, wherein the target neural network is a face recognition model or an image semantic segmentation model. The second determining module is used to determine the average value parameter of the normalization layer of the target neural network based on the received feature data. The normalization module is used to normalize the feature data through the normalization layer of the target neural network based on the standard deviation parameter and the mean parameter.
7. The apparatus according to claim 6, characterized in that, The normalization module includes: A quantization unit is used to quantize the standard deviation parameter and the mean parameter to obtain a fixed-point type mean parameter and a fixed-point type standard deviation parameter; The normalization unit is used to normalize the feature data through the normalization layer of the target neural network based on the mean parameter and the standard deviation parameter of the fixed-point type.
8. The apparatus according to claim 7, characterized in that, The quantization unit is used to perform quantization-aware training on the standard deviation parameter to obtain the standard deviation parameter of the fixed-point type; and to perform rounding processing on the mean parameter to obtain the mean parameter of the fixed-point type.
9. The apparatus according to claim 8, characterized in that, The quantization unit is used to determine a first quantization parameter and a second quantization parameter through quantization perception training. The first quantization parameter is used by the normalization layer of the target neural network to quantize floating-point input data into fixed-point input data, and the second quantization parameter is used by the normalization layer of the target neural network to quantize floating-point output data into fixed-point output data. Based on the first quantization parameter and the second quantization parameter, the quantization mapping relationship is determined; Based on the quantization mapping relationship, the standard deviation parameter is quantized to obtain the standard deviation parameter of the fixed-point type.
10. The apparatus according to claim 9, characterized in that, The quantization unit is used to normalize the fixed-point type sample input data based on the standard deviation parameter and the average value parameter to obtain floating-point type output data; and to determine the floating-point type input data corresponding to the floating-point type output data based on the standard deviation parameter and the average value parameter. Based on the floating-point type input data and the fixed-point type sample input data, determine the first quantization parameter; The second quantization parameter is determined based on the fixed-point type sample output data corresponding to the fixed-point type sample input data and the floating-point type output data.
11. An electronic device, characterized in that, The electronic device includes a processor and a memory; the memory stores at least one piece of program code, which is executed by the processor to implement the data normalization method as described in any one of claims 1 to 5.
12. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores at least one piece of program code, which is executed by a processor to implement the data normalization method as described in any one of claims 1 to 5.
13. A computer program product, characterized in that, The computer program product stores at least one piece of program code, which is executed by a processor to implement the data normalization method as described in any one of claims 1 to 5.