Model quantification implementation method, service processing method and related equipment
Through quantization-aware training and configuration updates, the quantization configuration of the neural network layer is automatically adjusted to solve the problem of loss of model quantification accuracy, improve the performance and efficiency of the quantized model, and meet business needs.
Patent Information
- Application Number
- CN202410941229.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-12
- Publication Date
- 2024-09-27
AI Technical Summary
In the process of model quantification, unified quantification of neural network layers leads to loss of quantification accuracy and cannot meet business needs.
By obtaining the initial neural network model, performing a quantization configuration update operation, determining the quantization configuration of each neural network layer, performing quantification-aware training based on the training data set, obtaining the target neural network model, automatically adjusting the quantization configuration to optimize the quantification accuracy and range, and ensuring the model performance.
It improves the model quantification accuracy, reduces the performance loss after quantization, meets business processing needs, and reduces memory usage and computational complexity.
Smart Images

Figure CN118709733A
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a model quantization implementation method, a business processing method and related equipment. Background Art
[0002] In recent years, neural network models based on deep learning have been widely used in many fields. With the improvement of model performance, huge parameters and calculation amount have been introduced. In response to this, model quantization technology has been proposed, which is a technology that converts floating-point calculations into low-bit fixed-point calculations. It can effectively reduce the model's calculation intensity, parameter size and memory consumption, and improve the model's running speed.
[0003] However, in the actual model quantization process, all neural network layers of the neural network model are usually uniformly quantized and converted so that the quantized neural network model can be used to execute business. However, this can easily cause the loss of quantization accuracy of the neural network model, resulting in failure to meet business needs. Summary of the invention
[0004] In view of the above problems, this application provides the following solutions:
[0005] The first aspect of the present application provides a model quantization implementation method, the method comprising:
[0006] Acquire an initial neural network model; the initial neural network model includes multiple initial neural network layers and is obtained by performing quantization perception training based on a training data set;
[0007] Performing a quantization configuration update operation to determine the quantization configuration of each of the initial neural network layers includes:
[0008] Quantizing different initial neural network layers to obtain reference neural network models corresponding to the quantized initial neural network layers;
[0009] Obtaining a characteristic parameter deviation of at least one target feature after each of the reference neural network models processes the training data set;
[0010] Determining at least one target neural network layer in the initial neural network model according to the characteristic parameter deviation;
[0011] Determine different quantization configurations corresponding to the at least one target neural network layer and other initial neural network layers in the initial neural network model;
[0012] Based on the determined quantization configuration and the training data set, the initial neural network model
[0013] The model is trained by quantization perception to obtain the target neural network model.
[0014] In a possible implementation, the quantizing different initial neural network layers to obtain a reference neural network model corresponding to the quantized initial neural network layer includes:
[0015] Quantizing different numbers of the initial neural network layers of the initial neural network model to obtain a plurality of reference neural network models;
[0016] Or, quantizing each of the initial neural network layers of the initial neural network model respectively, and obtaining a plurality of reference neural network models accordingly;
[0017] The step of obtaining a characteristic parameter deviation of at least one target feature after each of the reference neural network models processes the training data set comprises:
[0018] According to each of the reference neural network models, the reference training data in the training data set are processed respectively to obtain the processed reference training data output by the corresponding reference neural network model;
[0019] According to the characteristic parameters of at least one target feature of the reference training data respectively and the processed reference training data output by each reference neural network model, the characteristic parameter deviation of at least one target feature corresponding to each quantized initial neural network layer is obtained.
[0020] In a possible implementation, determining at least one target neural network layer in the initial neural network model according to the characteristic parameter deviation includes:
[0021] If the number of quantized neural network layers in each of the reference neural network models is different, the target feature parameter deviation change corresponding to each of the quantized initial neural network layers is obtained according to the feature parameter deviation change of at least one target feature between the i+1th reference neural network model and the i-th reference neural network model; the i-th reference neural network model is obtained by quantizing i consecutive layers or the 1st to i-th initial neural network layers, where i is an integer;
[0022] If the number of quantized neural network layers in each of the reference neural network models is the same, but the quantized neural network layers are different, the target feature parameter deviation change corresponding to each of the quantized initial neural network layers is obtained according to the feature parameter deviation change of at least one target feature between each of the reference neural network models and the initial neural network model;
[0023] Determine at least one of the quantized initial neural network layers that meets a preset condition according to the target feature parameter deviation variation corresponding to each of the quantized initial neural network layers;
[0024] At least one of the quantized initial neural network layers in the initial neural network model that meets preset conditions is determined as a target neural network layer.
[0025] In a possible implementation, determining at least one target neural network layer in the initial neural network model according to the characteristic parameter deviation includes:
[0026] Integrate the characteristic parameter deviations of the plurality of target features corresponding to the quantized initial neural network layers to obtain the target characteristic parameter deviations corresponding to the quantized initial neural network layers;
[0027] At least one target neural network layer in the initial neural network model is determined based on the target feature parameter deviations corresponding to each quantized initial neural network layer.
[0028] In a possible implementation, determining different quantization configurations corresponding to the at least one target neural network layer and other initial neural network layers in the initial neural network model includes:
[0029] Obtaining a target quantization configuration in the reference neural network model corresponding to each of the at least one target neural network layers;
[0030] Update the original quantization configuration of at least one target neural network layer in the initial neural network model to the corresponding target quantization configuration, and maintain the quantization configurations of other initial neural network layers in the initial neural network model unchanged.
[0031] In a possible implementation, performing quantization-aware training on the initial neural network model based on the determined quantization configuration and the training data set to obtain a target neural network model includes:
[0032] Based on the determined quantization configuration and the training data set, the initial neural network model is subjected to quantization-aware training to obtain a quantized pending neural network model;
[0033] If it is determined that the feature parameter deviation of at least one target feature after the pending neural network model processes the test data in the training data set does not meet the training termination condition, continue to perform the quantization configuration update operation on the pending neural network model;
[0034] If it is determined that the feature parameter deviation of at least one target feature after the pending neural network model processes the test data in the training data set meets the training termination condition, the pending neural network model is determined as the target neural network model.
[0035] A second aspect of the present application provides a service processing method, the method comprising:
[0036] Obtaining a business request; the business request includes business data to be processed;
[0037] Calling the target neural network model to process the business data and obtain a business processing result; the target
[0038] The standard neural network model is obtained by quantization-aware training with at least two different quantization configurations;
[0039] Output the business processing result.
[0040] In a possible implementation, the two different quantization configurations include at least a first quantization configuration and a second quantization configuration, and the first quantization configuration and the second quantization configuration have different quantization range update modes;
[0041] The first quantization configuration corresponds to a neural network layer in the target neural network model having a first degree of influence on a characteristic parameter deviation of at least one target characteristic of the business processing result;
[0042] The second quantization configuration corresponds to a neural network layer in the target neural network model having a second degree of influence on a feature parameter deviation of at least one target feature of the business processing result;
[0043] The first influence is greater than the second influence.
[0044] A third aspect of the present application provides an electronic device, the electronic device comprising at least one first memory and at least one first processor, wherein:
[0045] The first processor loads and executes a plurality of first computer instructions stored in the first memory to implement the following steps:
[0046] Acquire an initial neural network model; the initial neural network model includes multiple initial neural network layers and is obtained by performing quantization perception training based on a training data set;
[0047] Performing a quantization configuration update operation to determine the quantization configuration of each of the initial neural network layers includes:
[0048] Quantizing different initial neural network layers to obtain reference neural network models corresponding to the quantized initial neural network layers;
[0049] Obtaining a characteristic parameter deviation of at least one target feature after each of the reference neural network models processes the training data set;
[0050] Determine at least one target neural network layer in the initial neural network model according to the characteristic parameter deviation of at least one target feature corresponding to each quantized initial neural network layer; the target neural network layer is the quantized initial neural network layer corresponding to the characteristic parameter deviation that meets the preset condition;
[0051] Determine different quantization configurations corresponding to the at least one target neural network layer and other initial neural network layers in the initial neural network model;
[0052] Based on the determined quantization configuration and the training data set, quantization-aware training is performed on the initial neural network model to obtain a target neural network model.
[0053] A fourth aspect of the present application provides a service device, the service device comprising at least one second memory and at least one second processor, wherein:
[0054] The second processor loads and executes the plurality of second computer instructions stored in the second memory to implement the following steps:
[0055] Obtaining a business request; the business request includes business data to be processed;
[0056] Calling a target neural network model to process the business data to obtain a business processing result; the target neural network model is obtained through at least two different quantization configuration quantization perception training;
[0057] Output the business processing result. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale.
[0059] Figure 1 A schematic diagram of the hardware structure of an optional embodiment 1 of an electronic device adapted to the model quantization implementation method proposed in the present application;
[0060] Figure 2 A schematic diagram of the hardware structure of an optional second embodiment of an electronic device adapted to the model quantization implementation method proposed in the present application;
[0061] Figure 3 A schematic diagram of a system architecture for an optional application scenario of the business processing method provided in an embodiment of the present application;
[0062] Figure 4 A flowchart of an optional embodiment 1 of the model quantization implementation method provided in this application;
[0063] Figure 5 A flowchart of an optional second embodiment of the model quantization implementation method provided in this application;
[0064] Figure 6 A flowchart of an optional third embodiment of the model quantization implementation method provided in this application;
[0065] Figure 7 A flowchart of an optional embodiment 1 of the business processing method provided by the present application;
[0066] Figure 8 A schematic diagram of the structure of a model quantization implementation device provided in an embodiment of the present application;
[0067] Fig. 9 A schematic diagram of the structure of a business processing device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0068] The embodiments of the present application are described below in conjunction with the drawings in the embodiments of the present application. The terms used in the implementation mode of the present application are only used to explain the specific embodiments of the present application and are not intended to limit the present application. The embodiments of the present application will be described below in conjunction with the drawings. It is known to those of ordinary skill in the art that with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0069] The terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and need not be used to describe a specific order or sequential order. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, which is only to describe the distinction mode adopted by the objects of the same attributes when describing in the embodiments of the present application. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, so that the process, method, system, product or equipment comprising a series of units need not be limited to those units, but may include other units that are not clearly listed or inherent to these processes, methods, products or equipment.
[0070] This application can be applied to image / speech / text and other data processing fields, such as image denoising, speech enhancement, text recognition and other application scenarios to meet the corresponding business data processing needs. This application can be applied, but not limited to, to applications with data processing functions (such as image processing software or audio processing software, etc.) or cloud services provided by cloud-side servers, etc., which can be determined according to actual needs.
[0071] Exemplarily, when running image processing software on an electronic device, a trained target neural network model can be called to perform denoising on the original image. The target neural network model can be obtained by performing quantized perceptual training on the initial neural network model used to implement image denoising in accordance with the model quantization implementation method proposed in the embodiment of the present application. This can improve the quality of the processed image, improve the color fineness, and avoid color distortion while ensuring the color consistency before and after image processing.
[0072] Similarly, for other types of data processing software such as audio, video or text running on electronic devices, the target neural network model called to process the corresponding type of raw data can also be obtained by first performing quantization perception training on the initial neural network used to process this type of data in accordance with the model quantization implementation method proposed in the embodiment of the present application. The implementation process can refer to the description of the corresponding part of the method embodiment below, and this embodiment will not be repeated here. Of course, for other business services or data processing services and other types of business services based on cloud services, after obtaining the initial neural network model used to implement the business service, the model quantization implementation method proposed in the embodiment of the present application can still be used. In the process of quantization perception training of the initial neural network model, the quantization accuracy and quantization range are accurately weighed to improve the quantization quality of the obtained target neural network model, thereby improving the business performance of processing the corresponding type of business based on the target neural network model.
[0073] It should be noted that the neural network model (Neural Network Model) involved in the embodiments of the present application is a mathematical calculation model that imitates the behavioral characteristics of the human brain neural network and performs distributed parallel information processing. It can usually include a variety of neural network layers with different functions (such as convolutional layers for feature extraction, etc.), each layer contains a large number of parameters and calculation formulas, or is composed of a combination of multiple existing neural network sub-models. The application of neural network models can realize artificial intelligence (AI) technology. The AI models (such as neural network models) used in AI technology are diverse, and different application scenarios (such as classification scenarios or recognition scenarios, etc.) can use AI models with different structures. This application does not limit the type of neural network models involved in each embodiment and their network structure.
[0074] Reference Figure 1, which is a hardware structure diagram of an optional embodiment 1 of an electronic device adapted to the model quantization implementation method proposed in the present application, the electronic device 100 may be a server or a terminal device, and the server may be one or more servers, such as a physical server or a cloud server, etc.; the terminal device may include but is not limited to a smart phone, a tablet computer, a wearable device, a personal computer (personal computer, PC), a smart watch, an augmented reality technology (Augmented Reality, AR) device, a virtual reality (Virtual Reality, VR) device, a vehicle-mounted device, a smart speaker, a robot or a smart medical / transportation device, etc., and the present application does not limit the product form of the electronic device 100.
[0075] Take the electronic device 100 as an example to illustrate. Figure 1 As shown, the electronic device 100 may include at least one first memory 110 and at least one first processor 120, and the at least one first memory 110 and the at least one first processor 120 may communicate with each other via a bus. The bus may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 1 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0076] The first memory 110 can be used to store computer instructions and data, and may include an instruction storage area and a data storage area. The data storage area may store various data, such as an initial neural network model, a training data set, and various intermediate data generated during the model quantization implementation process; the instruction storage area may store software units such as an operating system, an application, and computer instructions required for at least one function (such as image / audio data processing functions). In an embodiment of the present application, the first memory 110 may provide the first processor 120 with a plurality of computer instructions for implementing the model quantization implementation method of the embodiment of the present application, as well as data or other software and hardware resources required during the execution of the model quantization implementation method.
[0077] The first processor 120, as the control center of the electronic device, can use various interfaces and lines to connect various parts of the entire electronic device, and implement the various steps of the model quantization implementation method proposed in the embodiment of the present application by loading and executing multiple computer instructions stored in the memory. The implementation process can refer to the description of the corresponding part of the method embodiment below. Other components of the electronic device (such as communication elements, one or more input components and output components, etc.) can also be called to implement corresponding functions.
[0078] In the embodiment of the present application, the first memory 110 may include a volatile memory, such as a random access memory (RAM), and may also include a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard drive drive (HDD) or a solid state drive (SSD). The first processor 120 may include any one or more of a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), a digital signal processor (DSP), an application specific integrated circuit (ASIC) or a field programmable gate array (FPGA). The present application does not limit the types of the first memory 110 and the first processor 120 and their working principles, and can be flexibly configured according to actual needs.
[0079] It should be understood that Figure 1 The structure of the electronic device shown does not constitute a limitation on the electronic device in the embodiment of the present application. In practical applications, the electronic device may include Figure 1 More or fewer components as shown, or combinations of certain components. In the case where the electronic device is a terminal device, such as Figure 2 As shown, the electronic device 100 may also include at least one input component such as a touch sensing unit for sensing touch events on a touch display panel, a keyboard, a mouse, a camera, a microphone, etc.; at least one output component such as a display, a speaker, a vibration mechanism, an indicator light, etc.; an antenna, a radio frequency unit; various sensors; a power module, etc. Figure 2The listed components are not shown. The hardware structure can be determined according to the terminal device type and its functional requirements, and this application does not list them one by one here.
[0080] For the electronic device 100 executing the model quantization implementation method proposed in the embodiment of the present application, the target neural network model obtained for business data processing in the corresponding business scenario can be used by the electronic device 100 or other business devices 200 to implement the various steps of the business processing method proposed in the embodiment of the present application based on the target neural network model, thereby ensuring the high reliability and accuracy of the business processing results and better meeting the corresponding business needs. The following is an example of a business device 200 that is different from the electronic device 100 above and implements the business processing method proposed in the embodiment of the present application. Figure 3 The system architecture diagram of an optional application scenario shown in FIG. 1 may include at least one electronic device 100 and at least one service device 200. The service device 200 may be connected to the electronic device 100 for communication (eg, Figure 3 The wireless network communication connection shown in the figure may also adopt a wired network communication connection mode, and the present application does not limit the communication connection mode between different devices), calling or obtaining the target neural network model used in the electronic device 100 to implement the corresponding business data processing, and executing each step of the business processing method proposed in the application embodiment. It should be noted that Figure 3 This is only an optional system architecture disclosed in this application, and does not constitute a limitation on the product form of the device composed of the system architecture.
[0081] In some embodiments, the service device 200 proposed in the embodiment of the present application may include at least one second memory and at least one second processor. The component types and connection methods thereof may refer to the above description. Figure 1 The electronic device 100 shown in the figure includes the first memory 110 and the first processor 120, and the type and connection method thereof. The connection method and type between the second memory and the second processor are not described in detail in this embodiment. Among them, the second processor can be used to load and execute multiple second computer instructions stored in the second memory to implement the steps of the business processing method proposed in the embodiment of the present application. The implementation process can refer to the description of the corresponding part of the business processing method embodiment below.
[0082] In a possible implementation, in order to realize the communication connection between the business device 200 and the electronic device 100, the two devices may include a corresponding communication port, and the communication port may include a communication element corresponding to a wireless communication method such as wifi, 5G / 6G, GPRS communication, Bluetooth and / or a near-field channel method, so that the business device 200 can realize data transmission between the electronic device 100 through wireless communication, such as the transmission of a target neural network model or business data. It may also include one or more interfaces supporting wired communication methods, such as a general-purpose input / output (GPIO) interface, a USB interface, a universal asynchronous receiver / transmitter (UART) interface, etc., to realize data transmission between the various components inside the business device (or electronic device), and the communication port can realize the connection with other components inside the corresponding device through a bus, etc. The present application does not limit the communication transmission mechanism between the electronic device 100 and the business device 200, which can be determined according to the circumstances.
[0083] It should be understood that the service device 200 is as follows Figure 3 The terminal equipment shown (which may also include independent terminals, access control equipment or other monitoring equipment in various industries, etc., is not limited to Figure 3 In the case of the terminal device product forms shown in the figure and listed above), refer to Figure 2 As shown in the terminal device structure diagram, the business device 200 may also include one or more input components, and one or more output components, etc., which can be determined according to the business requirements of the business terminal 200, and this application does not list them one by one here.
[0084] In conjunction with the above description of the application of the electronic device 100 and its composition structure proposed in the embodiment of the present application, in order to improve the quantization accuracy and operating efficiency of the neural network model and reliably and quickly meet business needs, the embodiment of the present application provides a model quantization implementation method. The model quantization implementation method of the embodiment of the present application is described in detail below in conjunction with the accompanying drawings.
[0085] Reference Figure 4 , is a flow chart of an optional embodiment 1 of the model quantization implementation method provided by the present application, and the method can be applied to the electronic device 100 described above, such as Figure 4 As shown, the model quantization implementation method proposed in this embodiment may include but is not limited to the following steps:
[0086] Step S410, obtaining an initial neural network model; the initial neural network model includes a plurality of initial neural network layers, and is obtained by performing quantization perception training based on a training data set;
[0087] As described above in the technical solution of the present application, for neural network models suitable for business scenarios (such as classification or recognition scenarios, etc.), such as image segmentation network models, target recognition models, speech enhancement models or text classification models, etc., they often have a large number of high-precision floating-point parameters, resulting in high memory usage (Footprint), power consumption (Power) and latency (Latency), which limits the range of operating devices and reduces business processing efficiency. For this, it is necessary to quantize high-precision floating-point parameters such as model weights and activation values into low-precision fixed-point parameters through model quantization, so as to allow the quantized model to occupy less memory overhead, speed up the reasoning speed, and better meet business processing requirements. In this regard, the embodiment of the present application proposes to implement model quantization in the model training process, and a floating-point model, i.e., an initial neural network model, can be constructed and trained first, so as to determine the quantization parameters through subsequent methods to quantize the training, so as to achieve the purpose of model quantization, and avoid the adverse effects of excessive quantization range or excessive quantization accuracy on the overall performance of the model (processing accuracy or running speed).
[0088] Among them, in the process of building and training a floating-point model, the embodiment of the present application can obtain a neural network that has been built and is suitable for a business scenario (such as an initial neural network built based on a suitable deep learning algorithm) or build an initial neural network for an actual business scenario, and obtain a training data set for the business scenario (such as an image data set for an image processing scenario, a speech data set for a speech processing scenario, or a text data set for a text recognition scenario, etc. The present application does not limit the data type contained in the training data set and its acquisition method, including but not limited to various open source data sets). After that, the QAT (Quantization-Aware Training) method can be used to train a quantizable initial neural network model. The present application does not elaborate on how to implement quantization-aware training based on the training data set.
[0089] In one possible implementation, the embodiment of the present application can train the model in PyTorch (an open source Python machine learning library) by simulating the quantization process to ensure that the model can still maintain good performance after quantization. It can be seen that the model parameters of the initial neural network model of the embodiment of the present application are still floating-point parameters. In order to truly reduce the storage requirements and computational complexity of the model, it is still necessary to perform quantization training according to the method described below to convert the floating-point model into a fixed-point model, support use on low-precision computing hardware, and ensure the high performance of the model.
[0090] In an embodiment of the present application, the benchmark QAT process executed in PyTorch may include using the same type of observer (quantizer) to simulate the global quantization of the model during the model training process, and determine the global initial quantization configuration that improves the operating efficiency and minimizes the loss of quantization accuracy. For example, the Moving Max Min (moving / sliding maximum and minimum) Observer can be used to perform two rounds (or 3 rounds or less) of QAT initialization training, and then perform LSQ or LSQ+ (Learned Step Size Quantization, learning step size quantization, i.e., neural network low-bit quantization) quantization training on each neural network layer to obtain the initial neural network model corresponding to the training convergence. Among them, the observer is an entity or mechanism for observing and recording model behavior or performance, a tool for collecting model output data, calculating performance indicators, or monitoring model runtime, and its observation results are used to evaluate the accuracy, efficiency or other relevant performance indicators of the model. This application does not elaborate on the working process of different types of observers under the model quantization architecture.
[0091] It should be noted that the observer type of global quantization in the benchmark QAT process can also be one of Max Min (maximum minimum) Observer, Moving Average (moving / sliding average) Observer, Percentile (percentile) Observer, MSE (Mean Squared Error) Observer, KL (Kullback Leibler, divergence) Observer and Mix (mixed) Observer, etc. This application can select a suitable type of observer for simulation quantization based on the performance differences (such as one or more of accuracy, time consumption and parameter adjustment complexity) between various types of observers. The embodiments of this application do not elaborate on the quantization performance and implementation process of various types of observers.
[0092] In addition, the present application does not limit the type of initial neural network model and its network structure, including but not limited to classification / recognition network models used for classification tasks or recognition tasks of various business data, etc., which undergo the same or similar benchmark QAT process, and simulate the effect of quantization during the training process to achieve the initial configuration of the model quantization processing, and obtain a floating-point initial neural network model. The present application does not elaborate on the quantization-aware training process of the benchmark QAT process. It can be understood that, in combination with the above description of the neural network model, the initial neural network model includes multiple initial neural network layers, such as one or more convolutional layers, pooling layers, activation layers, and fully connected layers. The number of initial neural network layers and the functions of each layer of the initial neural network can be determined based on actual business processing requirements.
[0093] Step S420, performing a quantization configuration update operation to determine the quantization configuration of each initial neural network layer, which may include steps S421 to S424:
[0094] Following the above analysis, in the process of model quantization implementation, if the number of quantized bits is too high, the model's memory overhead, power consumption and latency will increase, and it is likely that it cannot be used on low-precision hardware devices. If the initial neural network layers contained in the initial neural network model are directly quantized globally, it is easy to cause the quantization range to be too large, resulting in excessive loss of model quantization accuracy and failure to meet business processing requirements. It can be seen that under the limitation of the number of quantization bits, it is necessary to reasonably balance the quantization accuracy and quantization range to ensure the performance of the quantized model and reliably meet business processing requirements.
[0095] Taking the initial neural network model suitable for image processing tasks as an example to illustrate the technical problems in the model quantization process, if the initial neural network model is a neural network model built based on the super-resolution algorithm, after the image is super-resolved during the same quantization conversion process of each neural network layer, the saturation of highly saturated colors in the image is reduced due to the limitation of the quantization range, or the color richness of the areas with frequent color changes in the image is reduced due to the limitation of the quantization accuracy, that is, the image processed by the quantized model has color difference, which reduces the image quality. Even if the precision loss is compensated by a pure color image, the color difference cannot be reliably eliminated. If a higher number of quantization bits is used, although the color delicacy can be improved, the image processing efficiency will be affected by increasing memory usage, power consumption and latency.
[0096] In order to further improve the above problems, the present application proposes to adopt different quantization configurations for the initial neural network model globally, corresponding to different types of quantizers (observers), to achieve different quantization of the initial neural network layers of the corresponding layers, and avoid the inappropriate quantization range and quantization accuracy leading to too low overall performance of the model. Based on this, the present application proposes to analyze the quantization sensitive layer of the initial neural network model, determine which initial neural network layers are sensitive layers that need to correct the analog quantization configuration (which can be called the target neural network layer), and what quantization configuration the sensitive layer has, so that it can be adjusted to the appropriate quantization range to improve the quantization accuracy and reduce the impact on the overall performance of the quantized neural network model.
[0097] For the screening of at least one sensitive layer in the initial neural network model, at least one initial neural network layer can be manually selected as the sensitive layer for quantization testing, that is, the floating-point parameters of the initial neural network model are quantized through the observers corresponding to different quantization configurations, and whether the selection of the sensitive layer is appropriate each time is determined based on the quantization accuracy test. However, this manual repeated long trial method is too costly, and the quantization range corresponding to the sensitive layer screened out may not be the most appropriate, and it is easy to have problems such as excessive quantization range leading to excessive precision loss. In this regard, the embodiment of the present application proposes to automatically perform a quantization configuration update operation on the initial neural network model according to the method described in steps S421 to S424, and quickly and accurately obtain at least one target neural network layer (i.e., sensitive layer) of the quantization configuration that needs to be updated and initialized and its updated quantization configuration, so as to reduce the impact on the overall performance of the model through quantization training, and obtain higher quantization accuracy within a suitable quantization range.
[0098] It should be noted that the updated quantization configuration of at least one target neural network layer determined in the quantization configuration update operation process of the present application, i.e., the updated observer, can optimize the overall performance of the model, such as achieving one or more of shorter time consumption, higher quantization accuracy, and lower parameter complexity, relative to the initial observer used for simulating quantization of the initial neural network model in the benchmark QAT process. The observer type for updating the quantization configuration of the target neural network layer can be flexibly selected based on the initial observer type and the performance differences of different types of observers. The present application does not limit the observer type used / determined in the execution stages of different steps in the model quantization implementation method.
[0099] Step S421, quantizing different initial neural network layers to obtain a reference neural network model after the corresponding initial neural network layer is quantized;
[0100] Following the above analysis, in order to determine which one or more initial neural network layers contained in the initial neural network model are suitable as the target neural network layer, different initial neural network layers in the initial neural network model can be quantized, and the neural network model with at least one corresponding neural network layer after quantization is recorded as a reference neural network model. In this way, multiple reference neural network models can be obtained, and the at least one neural network layer after quantization contained in different reference neural network models is different or not completely the same, that is, the number or position of the neural network layers after quantization contained in different reference neural network models can be different, so that each reference neural network model has a different quantization range, so as to automatically test and obtain the target neural network layer corresponding to the appropriate quantization range. The present application does not elaborate on the process of obtaining each reference neural network model.
[0101] Among them, the quantization processing of any initial neural network layer in the initial neural network model can be a quantization conversion processing that reduces the high precision (i.e., floating point numbers) of the weights and activation values of the initial neural network layer to lower precision (such as fixed point numbers). This application does not elaborate on the quantization conversion processing method. The initial neural network layer that has not been quantized can be directly used as the corresponding neural network layer in the corresponding reference neural network model, so that the impact of the quantized neural network layer on the performance of the entire model can be accurately determined later.
[0102] Step S422, obtaining a characteristic parameter deviation of at least one target feature after each reference neural network model processes the training data set;
[0103] According to the above description of each reference neural network model, different reference neural network models have different quantization ranges, and the influence change relationship between different quantization ranges and quantization accuracy can be automatically analyzed to determine the sensitive layer in the initial neural network model, that is, at least one target neural network layer that needs to update the quantization configuration. Therefore, the present application can evaluate the performance of the corresponding reference neural network model based on the feature parameter deviation of at least one target feature after each reference neural network model processes the training data set, thereby determining the influence of the corresponding quantization range on the model quantization accuracy, and screening the neural network layer corresponding to the quantization range with a greater impact. Among them, the target feature can be a feature of the training data that will be affected by the reference neural network model in the process of processing the training data set, and the feature type can be determined based on the data type of the training data set. The present application does not limit the feature type of at least one target feature.
[0104] Exemplarily, if the training data set is a training image set, the context involves that each neural network model may be a neural network model suitable for image processing (such as any one or more processing methods such as image segmentation, target object recognition or image denoising). After obtaining the corresponding reference neural network models according to the quantization configuration update operation described above, the image in the training image set can be input into the reference neural network model to obtain the feature parameter deviation of at least one target feature between its output image (i.e., the processed image) and the input image (i.e., the image in the training image set), such as color deviation, brightness deviation, texture deviation or shape deviation, etc. The corresponding target features can be color features, brightness features, texture features and shape features, which can be based on the high-precision features required by the actual business scenario.
[0105] Similarly, if the training data set is a training speech data set, after obtaining any reference neural network model as described above, the speech data can be input into the reference neural network model for speech enhancement processing, and the characteristic parameter deviation of one or more target features (which can ensure that the speech before and after the reference neural network model is processed is not distorted) in the pitch feature, tone weight, speech speed and timbre between the enhanced speech data and the original input speech data is obtained, thereby determining the processing performance of the reference neural network model for images. If the training data set is a text data set, the text data can be processed according to any reference neural network model to obtain the characteristic parameter deviation of one or more target features in the text type, text element and text structure of the text data before and after the processing, thereby determining the processing performance of the reference neural network model for text data.
[0106] Among them, the characteristic parameter deviation of each target feature of different categories of training data sets can be determined according to the characteristic category of the corresponding target feature and its influence on the model processing performance. This application does not elaborate on the method of obtaining the characteristic parameter deviation of each category of target features. If the target feature is a color feature, its characteristic parameter deviation can be the color difference of the same pixel point between the input image and the processed output image.
[0107] Step S423, determining at least one target neural network layer in the initial neural network model according to the characteristic parameter deviation;
[0108] In the embodiment of the present application, the target neural network layer is the initial neural network layer that is quantized and corresponds to the characteristic reference deviation layer that meets the preset conditions. According to the method described in step S422, the performance test of each reference neural network model with different quantization ranges, i.e., the quantization accuracy test, can be characterized by the characteristic parameter deviation of at least one target feature corresponding to it to characterize the adverse effect (i.e., accuracy loss) of the corresponding quantization range of the initial neural network model on the quantization accuracy. In this way, by analyzing the changes in the quantization accuracy of the reference neural network models with multiple different quantization ranges, it can be determined what kind of quantization range of the initial neural network model has a greater impact on the quantization accuracy, thereby quickly and reliably selecting a reference neural network model with a larger quantization range and having at least one higher layer of quantized neural network layer, and determining the initial neural network layer of the corresponding layer in the initial neural network model as the target neural network layer, so that through the quantization training method described in step S430, the larger quantization range is adjusted to a smaller and more suitable quantization range, and the quantization accuracy of the quantized neural network model is ensured to be sufficient and not too high (i.e., it can meet the business processing requirements), and the automatic and reasonable trade-off between the quantization range and quantization accuracy of the initial neural network model is achieved, solving the technical problems of high cost and inappropriate quantization range in manually trying to select the target neural network layer.
[0109] Step S424, determining different quantization configurations corresponding to at least one target neural network layer and other initial neural network layers in the initial neural network model;
[0110] According to the method described above, after automatically screening out at least one target neural network layer corresponding to the corresponding quantization range that has a greater impact on the quantization accuracy of the model (i.e., a greater impact on the characteristic parameter deviation of at least one target feature of the processed data) from the multiple initial neural network layers included in the initial neural network model, in order to ensure the overall performance of the neural network model after quantization, relative to updating the global quantization configuration, the present application proposes to locally update the initial quantization configuration of the simulated quantization of the initial neural network model, that is, to update the quantization configuration of the at least one target neural network layer so that it is different from the quantization configuration of other initial neural network layers in the initial neural network model (i.e., each initial neural network layer except the target neural network layer), such as at least one target neural network layer corresponds to the first quantization configuration, and other initial neural network layers correspond to the second quantization configuration. The present application does not restrict the observer types corresponding to different quantization configurations and their quantization implementation methods.
[0111] Referring to the various types of observers listed above, the Max Min Observer is a simple quantizer that only needs to track the maximum and minimum values of the activation value during the training process. The parameter adjustment complexity is very low and the time consumption is very small. As an improved version of the Max Min Observer, the Moving Max Min Observer uses exponential moving average (EMA) to smoothly update the maximum and minimum values, which can provide higher accuracy than the Max Min Observer. Therefore, in a possible implementation, if the global Observer used for simulating quantization during the model training process through the benchmark QAT process in step S410 is the Moving Max Min Observer, the present application can update the quantization configuration of at least one target neural network layer to the Max Min Observer, and the quantization configuration of other initial neural network layers is still the Moving Max Min Observer. Compared with directly turning off the quantization of the target neural network layer or still using the original Moving Max Min Observer, or globally updating to the Max Min Observer, the present application can minimize the impact on the overall performance of the neural network model through a suitable quantization range, maintain a higher quantization accuracy, and better meet business processing requirements.
[0112] It should be noted that, when the initialized observer is Moving Max Min Observer, the quantization configuration updated by the present application for at least one target neural network layer may also be other types of observers that can improve the quantization accuracy, such as Mix Observer. By searching for the quantization parameters of a certain operator, only the output similarity of the operator is used as an evaluation index to search for the optimal quantization parameter, that is, the quantization parameter with the smallest error before and after quantization and dequantization, which has higher quantization accuracy. If the initialized observer is another type of Observer, such as MSE Observer, that is, by adjusting the moving step of the sliding window on the input data in the convolution operation, it has higher quantization accuracy, but it is very time-consuming; the quantization configuration updated by the target neural network layer can be Max Min Observer / Moving Max Min Observer to improve the quantization speed, so as to achieve the technical effect of the above-mentioned quantization model, but it is not limited to the observer type in the scheme of using different types of observers for different neural network layers in the same neural network model listed in this embodiment, and can be flexibly set according to actual needs.
[0113] In addition, for the initialized global quantization configuration, different types of observers can also be used for model weights and activation values. When updating the quantization configuration of the target neural network layer, at least one of the different initialized observers corresponding to the model weights and activation values can be updated to other types of observers, so that different observers corresponding to different initial neural network layers complete the model quantization training, that is, high-precision floating-point parameters such as model weights and activation values are converted into low-precision fixed-point parameters. Compared with the global use of initialized observers or the global use of updated observers for model quantization, it can reduce the loss of quantization accuracy and ensure the model output quality at a higher operating efficiency. Of course, the present application can also update the quantization configurations corresponding to the target neural network layer and other initial neural network layers to other different quantization configurations that are different from the initial quantization configurations, etc. The present application does not limit the implementation method of step S424.
[0114] Step S430, based on the determined quantization configuration and training data set, quantization-aware training is performed on the initial neural network model to obtain a target neural network model.
[0115] According to the method described above, after automatically and reliably determining the different quantization configurations of the target neural network layer and other initial neural network layers in the initial neural network model, different quantizers observers can be used for QAT training. After several rounds (such as two or three rounds of smaller training times) of QAT training, a maximum quantization range is obtained, and then all neural network layers are subjected to the above-mentioned LSQ or LSQ+ quantization, that is, the automatically determined larger quantization range is adjusted to a smaller and more suitable quantization range through LSQ or LSQ+ quantization. In this way, while minimizing the feature parameter deviation of at least one target feature during the training process, the model quantization accuracy is improved as much as possible, and the impact on the global performance of the model (such as accuracy and operating efficiency, etc.) is reduced until the training converges or the number of training times reaches the training number threshold, etc., and the training termination conditions are met, so as to ensure that the obtained target neural network model can meet the performance requirements such as business processing accuracy and operating speed.
[0116] In summary, in the embodiment of the present application, the initial neural network model after the initial quantization training will perform a quantization configuration update operation on it, and the quantization processing of different initial neural network layers will be automatically measured, and the characteristic parameter deviation of at least one target feature corresponding to each reference neural network model after processing the training data set will be obtained. At least one target neural network layer in the initial neural network model that is highly sensitive to the characteristic parameter deviation of at least one target feature is quickly determined, and its quantization configuration is distinguished from the quantization configurations of other initial neural network layers in the initial neural network model. Based on different quantization configurations and training data sets, the initial neural network model is trained for quantization perception to ensure that the quantization accuracy of the obtained target neural network model is sufficient and not too high, so as to meet the business processing accuracy requirements while improving the model operation efficiency and reducing the occupancy of storage resources.
[0117] Reference Figure 5 , which is a flow chart of an optional embodiment 2 of the model quantization implementation method provided by the present application. This embodiment can provide a detailed description of the model quantization implementation method proposed above, such as performing a quantization configuration update operation in step S420 to determine an optional detailed implementation method of the quantization configuration of each initial neural network layer. For other processing steps of the model quantization implementation method, please refer to the description of the corresponding part of the context embodiment, and this embodiment will not be repeated here. Based on this, Figure 5 As shown, the above quantization configuration update operation may include but is not limited to the following steps:
[0118] Step S510, quantizing different numbers of initial neural network layers of the initial neural network model to obtain a plurality of reference neural network models;
[0119] Regarding the method for obtaining the initial neural network model, please refer to the description of the corresponding part of the above embodiment, and this embodiment will not be described in detail here. In order to determine the target neural network layer in the initial neural network model, the embodiment of the present application can dynamically adjust the quantization range of the initial neural network model, that is, quantize different numbers of initial neural network layers, such as converting their high-precision floating-point parameters into low-precision fixed-point parameters, and determine the neural network model after quantization of any number of initial neural network layers as a reference neural network model to analyze the impact of different quantization ranges on the model quantization accuracy.
[0120] According to this quantization processing method, the N reference neural network models obtained in the embodiment of the present application have different quantization ranges, that is, the number of neural network layers that are quantized is different, and the corresponding reference neural network models have different quantization accuracy. The performance for processing business data may also vary. The present application does not limit the number of neural network layers that are quantized in each reference neural network model. It can be set based on historical quantization data or experience, or it can be determined by the total number of initial neural network layers contained in the initial neural network model. For the N reference neural network models, the i-th reference neural network model is obtained by quantizing the i-th initial neural network layer. For example, the 4 initial neural network layers in the initial neural network model are quantized, and only one network layer is quantized each time to obtain the 4th reference neural network model.
[0121] In a possible implementation, during the implementation of step S510, the initial neural network layers added layer by layer in the initial neural network model can be quantized to obtain corresponding N reference neural network models. At this time, the i-th reference neural network model is obtained by quantizing the initial neural network layers from layer 1 to layer i. For example, starting from the first layer of the initial neural network model, the corresponding reference neural network model is obtained after each quantization process. On this basis, the added initial neural network layer is quantized, so that the reference neural network model after this quantization process will sequentially add a quantized neural network layer, so that the number of quantized neural network layers in different reference neural network models is different. N and i are both integers, i≤N, and N can be determined based on the total number of initial neural network layers contained in the initial neural network model.
[0122] Exemplarily, the first reference neural network model is obtained by quantizing the first initial neural network layer of the initial neural network model, and only the first neural network layer is quantized; the second reference neural network model is obtained by quantizing the first and second initial neural network layers of the initial neural network model, and only the first and second neural network layers are quantized; the third reference neural network model is obtained by quantizing the first, second and third initial neural network layers of the initial neural network model, and only the first, second and third neural network layers are quantized; and so on, the consecutive i neural network layers from the first layer to the i-th layer in the i-th reference neural network model are quantized, and all neural network layers in the N-th reference neural network model are quantized.
[0123] It should be understood that in the layer-by-layer quantization processing process proposed in the embodiment of the present application, in addition to the layer-by-layer increasing quantization processing method starting from the first initial neural network layer, the layer-by-layer decreasing quantization processing method starting from the last initial neural network layer can also be used. Based on this progressive quantization training method proposed in the embodiment of the present application, by measuring the characteristic parameter deviation of at least one target feature after each reference neural network model processes the training data set, it is possible to more accurately obtain the impact of the corresponding increase / decrease of one layer of the quantized initial neural network layer on the performance of the entire model, thereby automatically and reliably realizing the sensitive layer analysis of the initial neural network model, and determining at least one initial neural network layer whose larger quantization range has a greater impact on the quantization accuracy as the target neural network layer.
[0124] Step S520, processing the reference training data in the training data set according to each reference neural network model, respectively, to obtain processed reference training data output by the corresponding reference neural network model;
[0125] In the process of analyzing the changes in the deviation of characteristic parameters of different initial neural network layers that have been quantized, in order to improve the analysis accuracy and accurately determine the quantization precision loss caused by different quantization ranges, thereby improving the accuracy and reliability of the target neural network layer determined accordingly, the above-mentioned training data set can be configured with training data and reference training data. The reference training data has the same data type as the training data, and the reference training data can be data with one or more features in the training data that are the same, thereby reducing the adverse effects of interfering feature data on the analysis results in the above-mentioned analysis process and improving the analysis efficiency.
[0126] For example, if the training data set is an image data set, the training data is a training image composed of any image collected or obtained from a third platform or a third device, and the reference training data can be a single color image, i.e., a pure color image. If the training data set is a voice data set, the training data can be a training voice composed of any voice signal collected or obtained from a third party, and the reference training data can be voice data with a single voice signal content, such as a single word voice signal, etc. This application does not limit the content of each type of reference training data and its acquisition method.
[0127] Combined with the description of the relevant part of step S422 above, according to the method described above, after obtaining each reference neural network model, the reference training data in the training data set can be processed according to the reference neural network model to obtain the corresponding processed reference training data. For example, the reference image is input into the reference neural network model for denoising to obtain the denoised reference image; or the reference speech is input into the reference neural network model for enhancement to obtain the enhanced reference speech, etc. The processing method of the reference neural network model for the reference training data can be determined according to the model type, and the embodiments of this application will not be described in detail.
[0128] Step S530, obtaining a characteristic parameter deviation of at least one target feature corresponding to each reference neural network model according to the characteristic parameters of at least one target feature of the reference training data and the processed reference training data output by each reference neural network model;
[0129] Following the above analysis, after obtaining the processed reference training data output by each reference neural network model, the characteristic parameters of at least one target feature can be extracted from the input reference training data and the corresponding output processed reference training data, respectively, and the characteristic parameter deviation corresponding to the quantized neural network layer of the reference neural network model increased or decreased relative to the last obtained reference neural network model is obtained. Since each quantized neural network layer has a one-to-one corresponding initial neural network layer, the characteristic parameter deviation also corresponds to the initial neural network layer, that is, step S530 obtains the characteristic parameter deviation of at least one target feature corresponding to each quantized initial neural network layer. Wherein, if the number of reference training data is multiple, the characteristic parameter deviation of the same target feature described above can be the average value of the characteristic parameter deviation of the target feature for multiple reference training data.
[0130] Assume that the present application uses L to represent the feature parameter deviation. In this way, after the initial neural network model processes the reference training data, the feature parameter deviation of at least one target feature between the input reference training data and the output processed reference training data can be recorded as L0. In this way, the i-th reference neural network model obtained after quantizing the initial neural network layers 1 to i, the feature parameter deviation of at least one target feature after processing the reference training data is recorded as Li. In this way, N+1 feature parameter deviations such as L0, L1, L2, ..., Li, ..., LN can be obtained.
[0131] Exemplarily, taking the reference training data as a pure color image and at least one target feature as a color feature as an example, the present application can obtain the asymptotic change of the color saturation of each reference neural network model. According to the method described above, the initial neural network model processes each pure color image to obtain the average value of the color deviation of all processed pure color images relative to the input pure color image, which is recorded as the color deviation amount L0. Among them, the color deviation test process on the pure color image set may include but is not limited to: obtaining the color value (i.e., color pixel value, a value between 0-255) histogram of each pure color image, and the color histogram of the processed pure color image, and selecting the maximum color value from them for difference operation to obtain the color deviation. If the difference between the maximum color values of the input pure color image and the processed pure color image is greater than a threshold value (such as 5, etc., the present application does not limit the threshold value), it can be considered that the color deviation is large and the model performance is low.
[0132] It can be seen that the color difference test process of each reference neural network model on the reference image can be: obtain the first color histogram of each reference image input to the reference neural network model, and the second color histogram of the corresponding processed reference image output by the reference neural network model, determine the target color corresponding to the maximum pixel value in the second color histogram and the first color histogram, obtain the first pixel value of the target color in the input reference image of the reference neural network model, and the second pixel value of the target color in the corresponding output processed reference image, and determine the pixel difference between the second pixel value and the first pixel value as the color deviation of the corresponding reference image.
[0133] In this way, the initial neural network model performs a color deviation test on the pure color image set and obtains the corresponding color deviation L0, which is recorded as L0=color_deviation(f 1 ,f 2 ,f 3 ,…f N ); the first layer of the initial neural network model is quantized (such as converting the floating-point parameters of the layer into fixed-point parameters, etc.), and the first reference neural network model is obtained. The other layers of the neural network layer are still the initial neural network layer (the model parameters are still high-precision floating-point parameters). According to the method described above, the color deviation test can be performed on the pure color image set to obtain the corresponding color deviation L1, which is recorded as L1=color_deviation(d 1 ,f 2 ,f 3 ,…f N); Based on the reference neural network model, the second initial neural network layer is quantized, or based on the initial neural network model, the first and second initial neural network layers are quantized to obtain the second reference neural network model, and its color deviation L2 on the pure color image set is obtained, which is recorded as L2=color_deviation(d 1 ,d 2 ,f 3 ,…f N ), such asymptotic quantization training can obtain the color deviation Li corresponding to the i-th reference neural network model, denoted as Li=color_deviation(d 1 ,d 2 ,…di,f i+1 ,f N ), until all initial neural network layers are quantized, and the color deviation LN corresponding to the Nth reference neural network model is obtained, which is recorded as LN=color_deviation(d 1 ,d 2 ,d 3 ,…d N ). Among them, for each element in color_deviation(), it corresponds to the quantization state of each neural network layer, d i Indicates that the initial neural network layer of the i-th layer is quantized and is a low-precision fixed-point parameter; f i Indicates that the initial neural network layer of the i-th layer is not quantized and is still a high-precision floating-point parameter.
[0134] The testing process of the initial neural network model and the N+1 models composed of N reference neural network models on the reference training data in the training data set of other data types is similar to the color deviation testing process described above, and this application does not give detailed examples one by one. Of course, in the color deviation testing process, the average deviation of the color value between the input pure color image (or color image) and the pure color image processed by the model can be, but not limited to, the color deviation acquisition method based on the color histogram described above.
[0135] Step S540, obtaining target feature parameter deviation changes corresponding to each quantized initial neural network layer according to the feature parameter deviation change of at least one target feature between the i+1th reference neural network model and the ith reference neural network model;
[0136] Step S550, determining at least one quantized initial neural network layer that meets a preset condition according to the target feature parameter deviation variation corresponding to each quantized initial neural network layer;
[0137] Step S560, determining at least one quantized initial neural network layer in the initial neural network model that meets preset conditions as a target neural network layer;
[0138] According to the progressive quantization training method proposed in the embodiment of the present application (i.e., according to the order of the initial neural network layers in the initial neural network model, i.e., quantization processing is performed layer by layer starting from the first layer), the N reference neural network models obtained have the number of quantized neural network layers included that increases one by one, and the i+1th reference neural network model has one more quantized layer than the number of quantized neural network layers of the i-th reference neural network model, that is, the quantization range of the initial neural network model is gradually adjusted, so that the quantization configurations of two adjacent reference neural network models are associated, so as to more accurately determine the target neural network layer whose characteristic parameter deviation meets the preset conditions.
[0139] Based on this, in the embodiment of the present application, progressive quantization training is performed layer by layer starting from the first layer, and one initial neural network layer is quantized each time to obtain corresponding N reference neural network models. After each of the models is tested on the reference training data, at least one feature parameter deviation corresponding to an initial neural network layer that has been quantized is obtained. Then, the target feature parameter deviation increment (i.e., the target feature parameter deviation change) can be obtained, such as ▽Li=Li-L(i-1), i=1,2,3…,N, and at least one target neural network layer that has a greater impact on the model quantization accuracy is determined accordingly.
[0140] In a possible implementation, according to the ranking of the target feature parameter deviation changes corresponding to each quantized initial neural network layer, at least one initial neural network layer corresponding to a larger target feature parameter deviation change can be selected as the target neural network layer, such as screening K larger target feature parameter deviation changes, and determining the corresponding quantized initial neural network layer as the target neural network layer, K is an integer such as 1, 2, or 3, and the value of K can be determined according to the actual quantization accuracy and quantization range requirements. It can be seen that the preset conditions in step S550 may include screening target feature parameter deviation changes greater than the feature parameter deviation change threshold, or screening a specified number K of larger target feature parameter deviation changes that are ranked top (sorted from large to small), etc., but are not limited to the implementation method described in the embodiments of the present application.
[0141] Preferably, the present application can directly select an initial neural network layer corresponding to the maximum target feature parameter deviation change as the target neural network layer, that is, the initial neural network layer whose model before and after quantization processing has the greatest impact on the business processing performance, that is, the initial neural network layer with the highest sensitivity to the target feature parameter deviation, by updating the quantization configuration of the target neural network layer, that is, correcting the QAT configuration of the target neural network layer in the initial neural network model so that the target neural network layer executes the updated quantization configuration, after candidate quantization training, it is possible to quickly and reliably improve the operating efficiency and accuracy of the quantized neural network model, and obtain a target neural network model with a suitable quantization range and sufficient quantization accuracy.
[0142] Step S570, obtaining a target quantization configuration in a reference neural network model corresponding to each of the at least one target neural network layers;
[0143] Step S580, updating the original quantization configuration of at least one target neural network layer in the initial neural network model to the corresponding target quantization configuration, and maintaining the quantization configurations of other initial neural network layers in the initial neural network model unchanged.
[0144] According to the method described above, at least one target neural network layer in the initial neural network model that meets the preset conditions is determined. The target quantization configuration of the target neural network layer in the corresponding reference neural network model can be used to correct the quantization configuration of the target neural network layer in the initial neural network model. For example, the quantization configuration (i.e., quantizer) of the most sensitive target neural network layer is updated to Max Min Observer, and the quantization configuration of other initial neural network layers remains unchanged and is still the original Moving Max Min Observer. However, it is not limited to these two types of observers and can be determined based on the quantization method used in the process of acquiring the initial neural network model.
[0145] Still taking the scenario where the training data set is an image data set as an example, the embodiment of the present application can adopt color saturation-aware quantization training, so that the quantization training focuses on minimizing the color deviation of the input and output images, and through a progressive quantization training method, the color deviation is reduced while maintaining the original image quality as much as possible, so that the image color before and after super-resolution remains consistent (that is, the color deviation is less than the threshold), thereby improving the output image quality and improving the image color delicacy.
[0146] It can be seen that the present application adds a quantization configuration update operation to the initial neural network model, obtains a reference neural network model after quantization processing with different quantization ranges through a progressive quantization training method, performs a feature parameter deviation test on at least one target feature on the reference training data, considers minimizing the target feature parameter deviation, and considers improving the quantization accuracy of the model as soon as possible, and only updates the quantization configuration of the screened target neural network layer to make it different from the quantization configuration of other initial neural network layers. The initial neural network model is quantized by corresponding to different quantizers. Training is performed on the initial neural network model based on quantization perception. Compared with the method of using the same quantizer to perform quantization training on each initial neural network layer, this embodiment adjusts from the maximum quantization range to a smaller and more suitable quantization range, and obtains the highest model quantization accuracy, reduces the feature loss of the target neural network model for the processed data, and compared with the method of manually selecting the target neural network layer, the present application adopts an automatic quantization configuration update operation and a dynamic adjustment of the quantization range, which reduces labor costs, improves the accuracy of the quantization range, and obtains smaller memory footprint, power consumption, and latency, so that the final target neural network model can reliably meet business processing requirements.
[0147] In some embodiments proposed in the present application, in the process of quantizing different initial neural network layers, each initial neural network layer of the initial neural network model can also be quantized separately, and correspondingly multiple reference neural network models are obtained. For example, each layer of the N initial neural network layers is quantized to obtain N reference neural network models containing the corresponding neural network layers that have been quantized. At this time, each reference neural network model only contains one quantized neural network layer, and the other layers are still the corresponding initial neural network layers. The quantization conversion implementation process of each initial neural network layer is not described in detail in this application.
[0148] Afterwards, the embodiment of the present application can still perform a feature parameter deviation test of at least one target feature on the reference training data based on each reference neural network model to obtain the feature parameter deviation of at least one target feature corresponding to each reference neural network model, thereby obtaining the target feature parameter deviation corresponding to each quantized initial neural network layer. Referring to the description of the corresponding part of the above embodiment 2, the target feature parameter deviation corresponding to each initial neural network layer can be recorded as Li, i=1,2,3…,N, and the calculation process is not repeated in this application.
[0149] Since the number of neural network layers to be quantized in each reference neural network model in this embodiment is the same, only the neural network layers to be quantized are different, thus, the target feature parameter deviation change corresponding to each quantized initial neural network layer can be obtained according to the feature parameter deviation change of at least one target feature between each reference neural network model and the initial neural network model, that is, according to the target feature parameter deviation change between each reference neural network model and the initial neural network model, the target feature parameter deviation change corresponding to each quantized initial neural network layer can be obtained, which is recorded as ▽Li=Li-L0, to evaluate whether the corresponding quantization range of each initial neural network layer is appropriate, that is, the corresponding quantization range has a greater impact on the quantization accuracy of the model, so as to determine at least one sensitive layer with a greater impact, that is, the target neural network layer. Regarding how to determine at least one target neural network layer in the initial neural network model according to the feature parameter deviation in this embodiment, determine the different quantization configurations of the target neural network and other initial neural network layers, so as to complete the quantization perception training of the initial neural network model through different quantizers, and obtain the implementation method of the target neural network model, you can refer to the description of the corresponding part of the context embodiment, and this embodiment will not be described in detail.
[0150] During the quantization configuration update operation in the model quantization implementation method described in the above embodiments, in a possible implementation, when the reference training data is processed according to each reference neural network model to obtain the feature parameter deviations of multiple target features, the feature parameter deviations of each of the multiple target features corresponding to each of the quantized initial neural network layers can be integrated to obtain the target feature parameter deviations corresponding to the corresponding initial neural network layer, such as averaging or averaging weighted operations on the feature parameter deviations of each of the multiple target features corresponding to any of the quantized initial neural network layers (the present application does not impose any restrictions on the weight values of various target features, which may be determined depending on the circumstances), etc., to obtain the target feature parameter deviation corresponding to the quantized initial neural network layer, that is, the test result of the target feature deviation test of any of the above reference neural network models on the reference training data.
[0151] Exemplarily, the feature parameter deviation test of the neural network model on a pure color image set is still taken as an example for explanation. If the model needs to be used to improve the color (any color among red, green, blue RGB) deviation and brightness deviation of the image, the pure color image can be processed according to the initial neural network model and each model in the reference neural network model to obtain the color value and brightness of the processed pure color image, which are compared with the color value and brightness value of the original pure color image to obtain the color deviation and brightness deviation of the pure color image before and after processing with the model (corresponding to the feature parameter deviation amounts of the above-mentioned multiple target features), and the average value or weighted average value of the color deviation and the brightness deviation is determined as the color difference of the model (corresponding to the above-mentioned target feature parameter deviation amount), thereby evaluating the quantization accuracy under the quantization range of the corresponding reference neural network model.
[0152] Afterwards, the method described above can be used to perform a difference operation on the target feature parameter deviations of the i+1th reference neural network model and the i-th reference neural network model to obtain the target feature parameter deviation change corresponding to the (i+1)th initial neural network layer that has been quantized. In this way, at least one target neural network layer in the initial neural network model can be determined by sorting the target feature parameter deviation changes corresponding to each layer, that is, the initial neural network layer that is more sensitive to the target feature parameter deviation. The determination method can refer to the description of the corresponding part of the above embodiment, and this embodiment will not be described in detail here.
[0153] Reference Figure 6 , which is a flow chart of the optional embodiment 3 of the model quantization implementation method provided in this application, such as Figure 6 As shown, the method may include:
[0154] Step S610, obtaining an initial neural network model; the initial neural network model includes a plurality of initial neural network layers, and is obtained by performing quantization perception training based on a training data set;
[0155] Step S620, performing a quantization configuration update operation to determine a different quantization configuration between at least one target neural network layer in the initial neural network and other initial neural network layers;
[0156] Step S630, based on the determined quantization configuration and the training data set, the initial neural network model is subjected to quantization-aware training to obtain a quantized pending neural network model;
[0157] Step S640, determining whether the characteristic parameter deviation of at least one target characteristic after the pending neural network model processes the test data in the training data set meets the training termination condition, if not, returning to step S620 to continue to perform the quantization configuration update operation on the pending neural network model; if so, executing step S650;
[0158] Step S650, determining the pending neural network model as the target neural network model.
[0159] Regarding the implementation method of step S610 and step S620, reference may be made to the description of the corresponding steps in the model quantization implementation method described in the above embodiments, and this embodiment will not be repeated here. According to the implementation method of the quantization configuration update operation described above, a quantization configuration update operation is performed, and after determining that the target neural network layer in the initial neural network model has different quantization configurations from other initial neural network layers, the training data in the training data set can be used to perform two rounds (or other small number of training times) of QAT training on the initial neural network model through the corresponding different quantizers, and then continue to perform LSQ or LSQ+ quantization on all neural network layers, so as to ensure higher quantization accuracy during the quantization training process while adjusting a smaller and more suitable quantization range until the training converges, and the final fixed-point model is determined as the pending neural network model to be tested. Regarding the implementation method of QAT quantization and LSQ quantization, it can be determined according to the respective model quantization principles, and this application will not describe in detail.
[0160] Afterwards, the test data in the training data set can be used to perform a feature parameter deviation test on at least one target feature of the pending neural network model. If the test passes, it means that the training termination condition is met, the pending neural network model has reasonably weighed the quantization accuracy and quantization range, and the performance of the entire model meets the business processing requirements, and it can be recorded as the target neural network model. If the test fails, it means that the selected target neural network layer may not be suitable, and the pending neural network model can continue to be updated for a second time, that is, the pending neural network model is used as the new initial neural network model described in the above embodiments, and the quantization configuration update operation is performed again. Based on the determined different quantization configurations and training data sets, a new pending neural network model is obtained through quantization perception training, and then the new pending neural network model is tested for parameter deviation. If the test passes, the new pending neural network model is determined as the target neural network model. If the test fails, the quantization configuration update operation is continued for the new pending neural network model. The implementation process is similar and will not be described in detail in this application.
[0161] In one possible implementation, during the feature parameter deviation test of the pending neural network model, the test data used can still be data of the same type as the above-mentioned reference training data, such as a reference image of a pure color, a reference speech with a single speech content, a reference text data of a single element, etc. The test process is similar to the feature parameter deviation test process of the reference neural network model on the reference training data, and is not described in detail in this application.
[0162] Exemplarily, if the test data is a pure color image, it is input into the pending neural network model for processing. After the processed pure color image is obtained, the color deviation can be performed through the target color corresponding to the maximum pixel value in each color histogram to determine whether the training termination condition is met. If the color deviation is less than a threshold value (such as 5, etc.), it can be considered that the pending neural network model processes the pure color image, and even at high saturation, the processed pure color image has no color difference. The target neural network model determined in this way improves the quantization quality relative to the global quantization of each layer of the initial neural network model, that is, when the number of quantization bits is limited, the quantization range is reasonably improved while ensuring the image quality, reducing the impact of model quantization on the performance of the entire model, reducing the target neural network model's consumption of electronic equipment operating resources, and improving the model's operating speed, so as to improve business processing efficiency and performance.
[0163] Reference Figure 7 , which is a flow chart of an optional embodiment 1 of the service processing method provided by the present application. The method can be applied to a service device, which can be a terminal device or a server, and can refer to but is not limited to Figure 3 The application scenarios shown are as follows: Figure 7 As shown, the service processing method proposed in this embodiment may include but is not limited to the following steps:
[0164] Step S710, obtaining a service request; the service request includes service data to be processed;
[0165] In the embodiment of the present application, the business request may be generated by a business personnel using one or more input components of a business device (such as a touch screen, a physical keyboard, a function key (such as a volume control button, a switch button, etc.), a trackball, a mouse, a joystick, etc.) to perform an input operation. It may also be that after receiving or detecting the business data to be processed, a corresponding business request is automatically generated to obtain a corresponding business processing result according to the business processing method proposed in the embodiment of the present application. The present application does not limit the method for obtaining the business request and its content, which may be determined according to the circumstances.
[0166] The business data may include but is not limited to one or more of image data, audio data, and text data, and may be determined based on actual business scenarios.
[0167] Step S720, calling the target neural network model to process the business data to obtain a business processing result; the target neural network model is obtained by at least two different quantization configurations and quantization perception training;
[0168] Step S730: output the business processing result.
[0169] like Figure 3In the application scenario shown, when a business device responds to a business request, it can call a target neural network model that is compatible with the business data to be processed from the target neural network models for different types of business data stored in the electronic device through wireless network communication or wired network communication, or call a compatible target neural network model already stored in the business device to process the business data and output the corresponding business processing results.
[0170] In some other embodiments, the business device may also send a business request to an electronic device, which parses the business data to be processed and calls a corresponding quantized target neural network model to process the business data, and feeds back the obtained business processing results to the business device for output. This application does not limit the system architecture of the business processing method.
[0171] It should be noted that the output of business results may include but is not limited to output using output components such as a display screen or an audio player, and may also be output to other devices or other processors through a communication connection port to continue to perform subsequent tasks on the processed business data, such as segmenting the denoised image, etc. This application does not limit the implementation method of step S730. In addition, the business device and the electronic device may also be the same device, or different processing devices integrated in the same device, so that it can be applied to the model quantization implementation method and business processing method proposed in the embodiment of this application, and the implementation process is not described in detail in this application.
[0172] Exemplarily, if the business request indicates that noise reduction be performed on the image to be processed, the target neural network model may be an image denoising model quantized according to the model quantization implementation method proposed in the embodiment of the present application, and the image to be processed is input into the target neural network model for denoising, and the denoised image is output. As described in the model quantization implementation method in the above embodiment, the target neural network model is obtained through quantization perception training with at least two different quantization configurations, which reasonably balances the quantization accuracy and quantization range, reduces the consumption of processing resources, makes it suitable for more types of business equipment, and improves the efficiency and reliability of image denoising, reduces the image quality loss after denoising, so as to meet the subsequent processing requirements of the denoised image.
[0173] Similarly, in business scenarios such as image segmentation or target recognition, or speech enhancement or text classification, an appropriate quantized target neural network model, such as an image segmentation model, a target recognition model, an audio enhancement model or a text classification model, can be called to process the input corresponding business data to obtain the corresponding business processing results quickly, reliably and accurately. The implementation process is not described in detail in this application.
[0174] In the actual application of the present application, the above two different quantization configurations include at least a first quantization configuration and a second quantization configuration, and the first quantization configuration and the second quantization configuration have different quantization range update methods, such as the first quantization configuration is Max MinObserver, and the second quantization configuration is Moving Max MinObserver, but is not limited to these two types of observers.
[0175] In one possible implementation, the first quantization configuration corresponds to the neural network layer in the target neural network model, which has a first degree of influence on the characteristic parameter deviation of at least one target feature of the business processing result; the second quantization configuration corresponds to the neural network layer in the target neural network model, which has a second degree of influence on the characteristic parameter deviation of at least one target feature of the business processing result, and the first degree of influence is greater than the second degree of influence. Combined with the above description of the model quantization implementation method, model quantization is the conversion of high-precision floating-point parameters into low-precision fixed-point parameters, which may sacrifice a certain degree of model output accuracy, but the present application reasonably weighs the quantization accuracy and quantization range, even if it will affect the model output accuracy, but the impact is small, and the business processing results of the business data can still meet the business performance requirements, and because the quantized target neural network model obtains smaller memory consumption, power consumption and delay, the business processing efficiency is improved.
[0176] A model quantization implementation method provided in an embodiment of the present application is introduced above, and a device for executing the above model quantization implementation method will be introduced below.
[0177] Reference Figure 8 , is a schematic diagram of the structure of a model quantization implementation device provided in an embodiment of the present application. Figure 8 As shown, the model quantization implementation device may include:
[0178] An initial neural network model acquisition module 810 is used to acquire an initial neural network model; the initial neural network model includes a plurality of initial neural network layers and is obtained by performing quantization perception training based on a training data set;
[0179] The quantization configuration updating module 820 is used to perform a quantization configuration updating operation to determine the quantization configuration of each of the initial neural network layers. The quantization configuration updating module 820 may include:
[0180] A reference neural network model obtaining unit 821 is used to perform quantization processing on different initial neural network layers to obtain a reference neural network model corresponding to the quantized initial neural network layer;
[0181] A feature parameter deviation obtaining unit 822 is used to obtain a feature parameter deviation of at least one target feature after each of the reference neural network models processes the training data set;
[0182] A target neural network layer determination unit 823 is used to determine at least one target neural network layer in the initial neural network model according to the characteristic parameter deviation;
[0183] A quantization configuration determining unit 824 is used to determine different quantization configurations corresponding to the at least one target neural network layer and other initial neural network layers in the initial neural network model;
[0184] The target neural network model acquisition module 830 is used to perform quantization-aware training on the initial neural network model based on the determined quantization configuration and the training data set to obtain a target neural network model.
[0185] In a possible implementation, the reference neural network model obtaining unit 821 may include:
[0186] A first quantization processing unit, used to perform quantization processing on different numbers of the initial neural network layers of the initial neural network model, and correspondingly obtain multiple reference neural network models;
[0187] Or, a second quantization processing unit is used to perform quantization processing on each of the initial neural network layers of the initial neural network model respectively, and obtain a plurality of reference neural network models accordingly;
[0188] Based on this, the characteristic parameter deviation obtaining unit 822 may include:
[0189] A first processing unit, configured to process reference training data in the training data set according to each of the reference neural network models, to obtain processed reference training data output by the corresponding reference neural network model;
[0190] The first obtaining unit is used to obtain the characteristic parameter deviation of at least one target feature corresponding to each quantized initial neural network layer according to the characteristic parameters of at least one target feature of the processed reference training data output by each reference neural network model respectively.
[0191] In a possible implementation, the target neural network layer determination unit 823 may include:
[0192] A second obtaining unit is used for obtaining the target feature parameter deviation change corresponding to each of the quantized initial neural network layers according to the feature parameter deviation change of at least one target feature between the i+1th reference neural network model and the i-th reference neural network model if the number of quantized neural network layers in each of the reference neural network models is different; the i-th reference neural network model is obtained by quantizing i consecutive layers or the 1st to i-th initial neural network layers, where i is an integer;
[0193] A third obtaining unit is used to obtain the target feature parameter deviation change amount corresponding to each of the quantized initial neural network layers according to the feature parameter deviation change amount of at least one target feature between each of the reference neural network models and the initial neural network model if the number of quantized neural network layers in each of the reference neural network models is the same but the quantized neural network layers are different;
[0194] A first determining unit is used to determine at least one of the quantized initial neural network layers that meets a preset condition according to the target feature parameter deviation variation corresponding to each of the quantized initial neural network layers;
[0195] The second determination unit is used to determine at least one of the quantized initial neural network layers in the initial neural network model that meets the preset conditions as the target neural network layer.
[0196] In a possible implementation, the target neural network layer determination unit 823 may also include:
[0197] An integration processing unit, used for integrating the characteristic parameter deviations of the plurality of target features corresponding to the quantized initial neural network layers to obtain the target characteristic parameter deviations corresponding to the quantized initial neural network layers;
[0198] The third determination unit is used to determine at least one target neural network layer in the initial neural network model according to the target feature parameter deviation corresponding to each quantized initial neural network layer.
[0199] In some embodiments, the quantization configuration determining unit 824 may include:
[0200] A target quantization configuration obtaining unit, used to obtain a target quantization configuration in a reference neural network model corresponding to each of the at least one target neural network layers;
[0201] An updating unit is used to update the original quantization configuration of at least one target neural network layer in the initial neural network model to the corresponding target quantization configuration, and maintain the quantization configurations of other initial neural network layers in the initial neural network model unchanged.
[0202] In some embodiments, the target neural network model acquisition module 830 may include:
[0203] A training unit, configured to perform quantization-aware training on the initial neural network model based on the determined quantization configuration and the training data set to obtain a quantized pending neural network model;
[0204] A fourth determination unit is configured to trigger the quantization configuration update module 820 to continue to perform the quantization configuration update operation on the pending neural network model if it is determined that the feature parameter deviation of at least one target feature after the pending neural network model processes the test data in the training data set does not meet the training termination condition;
[0205] The fifth determination unit is used to determine the pending neural network model as the target neural network model if it is determined that the feature parameter deviation of at least one target feature after the pending neural network model processes the test data in the training data set meets the training termination condition.
[0206] In combination with a service processing method provided by an embodiment of the present application introduced above, a device for executing the above service processing method will be introduced below.
[0207] Reference Fig. 9 , is a schematic diagram of the structure of a service processing device provided in an embodiment of the present application. Fig. 9 As shown, the service processing device may include:
[0208] The service request obtaining module 910 is used to obtain a service request; the service request includes service data to be processed;
[0209] The business data processing module 920 is used to call the target neural network model to process the business data and obtain a business processing result; the target neural network model is obtained by quantization perception training with at least two different quantization configurations;
[0210] The business processing result output module 930 is used to output the business processing result.
[0211] The above two different quantization configurations include at least a first quantization configuration and a second quantization configuration, and the first quantization configuration and the second quantization configuration have different quantization range update methods. The first quantization configuration corresponds to a neural network layer in the target neural network model having a first influence on the characteristic parameter deviation of at least one target feature of the business processing result; the second quantization configuration corresponds to a neural network layer in the target neural network model having a second influence on the characteristic parameter deviation of at least one target feature of the business processing result; the first influence is greater than the second influence.
[0212] A computer program product is also provided in an embodiment of the present application, including multiple first computer-readable instructions. When the first computer-readable instructions are executed on an electronic device, the electronic device implements any model quantization implementation method provided in the embodiment of the present application.
[0213] Another computer program product is also provided in an embodiment of the present application, including multiple second computer-readable instructions. When the second computer-readable instructions are executed on a service device, the service device implements any service processing method provided in the embodiment of the present application.
[0214] A computer-readable storage medium is also provided in an embodiment of the present application. The storage medium carries one or more first computer programs. When the one or more first computer programs are executed by an electronic device, the electronic device can implement any model quantization implementation method provided in the embodiment of the present application.
[0215] Another computer-readable storage medium is also provided in an embodiment of the present application. The storage medium carries one or more second computer programs. When the one or more second computer programs are executed by a business device, the business device can implement any business processing method provided in the embodiment of the present application.
[0216] It should also be noted that the device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the drawings of the device embodiments provided by the present application, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines.
[0217] Through the description of the above implementation mode, the technicians in the field can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course, it can also be implemented by special hardware including special integrated circuits, special CPUs, special memories, special components, etc. In general, all functions completed by computer programs can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be various, such as analog circuits, digital circuits or special circuits. However, for the present application, software program implementation is a better implementation mode in more cases. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer floppy disk, a U disk, a mobile hard disk, a ROM, a RAM, a disk or an optical disk, etc., including a number of instructions to enable a computer device (which can be a personal computer, a training device, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0218] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the above-mentioned process or function according to the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, a computer, a training device or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, training device or data center. The computer-readable storage medium can be any available medium that a computer can store or a data storage device such as a training device, a data center, etc. that contains one or more available media integrations. The available medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (eg, a DVD), or a semiconductor medium (eg, a solid state disk (SSD)).
Claims
1. A method for implementing model quantization, the method comprising: Get the initial neural network model; The initial neural network model includes a plurality of initial neural network layers and is obtained by performing quantization-aware training based on a training data set; Performing a quantization configuration update operation to determine the quantization configuration of each of the initial neural network layers includes: Quantizing different initial neural network layers to obtain reference neural network models corresponding to the quantized initial neural network layers; Obtaining a characteristic parameter deviation of at least one target feature after each of the reference neural network models processes the training data set; Determining at least one target neural network layer in the initial neural network model according to the characteristic parameter deviation; Determine different quantization configurations corresponding to the at least one target neural network layer and other initial neural network layers in the initial neural network model; Based on the determined quantization configuration and the training data set, quantization-aware training is performed on the initial neural network model to obtain a target neural network model.
2. According to the method of claim 1, the quantizing of different initial neural network layers to obtain a reference neural network model corresponding to the quantized initial neural network layer comprises: Quantizing different numbers of the initial neural network layers of the initial neural network model to obtain a plurality of reference neural network models; Or, quantizing each of the initial neural network layers of the initial neural network model respectively, and obtaining a plurality of reference neural network models accordingly; The step of obtaining a characteristic parameter deviation of at least one target feature after each of the reference neural network models processes the training data set comprises: According to each of the reference neural network models, the reference training data in the training data set are processed respectively to obtain the processed reference training data output by the corresponding reference neural network model; According to the reference training data and the characteristic parameters of at least one target feature of each of the processed reference training data output by each of the reference neural network models, each quantized The feature parameter deviation of at least one target feature corresponding to the processed initial neural network layer.
3. The method according to claim 1 or 2, wherein determining at least one target neural network layer in the initial neural network model according to the characteristic parameter deviation comprises: If the number of quantized neural network layers in each of the reference neural network models is different, the target feature parameter deviation change corresponding to each of the quantized initial neural network layers is obtained according to the feature parameter deviation change of at least one target feature between the i+1th reference neural network model and the i-th reference neural network model; the i-th reference neural network model is obtained by quantizing i consecutive layers or the 1st to i-th initial neural network layers, where i is an integer; If the number of quantized neural network layers in each of the reference neural network models is the same, but the quantized neural network layers are different, the target feature parameter deviation change corresponding to each of the quantized initial neural network layers is obtained according to the feature parameter deviation change of at least one target feature between each of the reference neural network models and the initial neural network model; Determine at least one of the quantized initial neural network layers that meets a preset condition according to the target feature parameter deviation variation corresponding to each of the quantized initial neural network layers; At least one of the quantized initial neural network layers in the initial neural network model that meets preset conditions is determined as a target neural network layer.
4. The method according to claim 1 or 2, wherein determining at least one target neural network layer in the initial neural network model according to the characteristic parameter deviation comprises: Integrate the characteristic parameter deviations of the plurality of target features corresponding to the quantized initial neural network layers to obtain the target characteristic parameter deviations corresponding to the quantized initial neural network layers; At least one target neural network layer in the initial neural network model is determined based on the target feature parameter deviations corresponding to each quantized initial neural network layer.
5. The method according to claim 1, wherein determining different quantization configurations corresponding to the at least one target neural network layer and other initial neural network layers in the initial neural network model comprises: Obtaining a target quantization configuration in the reference neural network model corresponding to each of the at least one target neural network layers; Update the original quantization configuration of at least one target neural network layer in the initial neural network model to the corresponding target quantization configuration, and maintain the quantization configurations of other initial neural network layers in the initial neural network model unchanged.
6. The method according to claim 1, wherein the initial neural network model is subjected to quantization-aware training based on the determined quantization configuration and the training data set to obtain a target neural network model, comprising: Based on the determined quantization configuration and the training data set, the initial neural network model is subjected to quantization-aware training to obtain a quantized pending neural network model; If it is determined that the feature parameter deviation of at least one target feature after the pending neural network model processes the test data in the training data set does not meet the training termination condition, continue to perform the quantization configuration update operation on the pending neural network model; If it is determined that the feature parameter deviation of at least one target feature after the pending neural network model processes the test data in the training data set meets the training termination condition, the pending neural network model is determined as the target neural network model.
7. A business processing method, the method comprising: Obtaining a business request; the business request includes business data to be processed; Calling the target neural network model to process the business data and obtain a business processing result; The target neural network model is obtained by quantization-aware training with at least two different quantization configurations; Output the business processing result.
8. The method according to claim 7, wherein the two different quantization configurations include at least a first quantization configuration and a second quantization configuration, and the first quantization configuration and the second quantization configuration have different quantization range update modes; in, The first quantization configuration corresponds to a neural network layer in the target neural network model having a first degree of influence on a feature parameter deviation of at least one target feature of the business processing result; The second quantization configuration corresponds to a neural network layer in the target neural network model having a second degree of influence on a feature parameter deviation of at least one target feature of the business processing result; The first influence is greater than the second influence.
9. An electronic device, comprising at least one first memory and at least one first processor, wherein: The first processor loads and executes a plurality of first computer instructions stored in the first memory to implement the following steps: Acquire an initial neural network model; the initial neural network model includes multiple initial neural network layers and is obtained by performing quantization perception training based on a training data set; Performing a quantization configuration update operation to determine the quantization configuration of each of the initial neural network layers includes: Quantizing different initial neural network layers to obtain reference neural network models corresponding to the quantized initial neural network layers; Obtaining a characteristic parameter deviation of at least one target feature after each of the reference neural network models processes the training data set; Determine at least one target neural network layer in the initial neural network model according to the characteristic parameter deviation of at least one target feature corresponding to each quantized initial neural network layer; the target neural network layer is the quantized initial neural network layer corresponding to the characteristic parameter deviation that meets the preset condition; Determine different quantization configurations corresponding to the at least one target neural network layer and other initial neural network layers in the initial neural network model; Based on the determined quantization configuration and the training data set, quantization-aware training is performed on the initial neural network model to obtain a target neural network model.
10. A service device, comprising at least one second memory and at least one second processor, wherein: The second processor loads and executes the plurality of second computer instructions stored in the second memory to implement the following steps: Obtaining a business request; the business request includes business data to be processed; Calling a target neural network model to process the business data to obtain a business processing result; the target neural network model is obtained through at least two different quantization configuration quantization perception training; Output the business processing result.
