A generative data-free quantization method, identification method and device, and storage medium

By generating pseudo-data and training a quantization model using a knowledge matching generator and a loss function, the problem of accuracy degradation in data-free quantization is solved, achieving high-precision object recognition and embedded device deployment.

CN115223209BActive Publication Date: 2026-02-24SOUTH CHINA UNIV OF TECH
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210703685.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-21
Publication Date
2026-02-24
Estimated Expiration
2042-06-21

AI Technical Summary

Technical Problem

Existing quantization methods rely on training data, making them unsuitable for use in scenarios such as healthcare and finance. Furthermore, the generated data lacks the diversity and categorical information of real-world data, leading to a decrease in the accuracy of quantization models.

Method used

By collecting target datasets and pre-training a full-precision neural network, pseudo-data is generated and a knowledge-matching data generator is used to mine classification and distribution information. The generator is trained by combining cross-entropy and BNS loss functions to generate a driving quantization model. The quantization model is then iteratively optimized to approximate the performance of the full-precision model.

Benefits of technology

It improves the accuracy of quantization models in the absence of data, achieves high-precision object recognition, and is suitable for deployment in embedded devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115223209B_ABST
    Figure CN115223209B_ABST
Patent Text Reader

Abstract

The application discloses a generative data-free quantization method, a recognition method, a device and a storage medium, and the method comprises the following steps: collecting a data set of a target, pre-training a full-precision neural network according to the data set, and obtaining a full-precision pre-training model; training a knowledge matching data generator according to the full-precision pre-training model, and generating pseudo data as generated data; wherein the knowledge matching data generator excavates classification information and distribution information of original data from the full-precision pre-training model; using the generated data to drive quantization of the full-precision model, and obtaining a quantization model; and iteratively optimizing the quantization model according to the knowledge matching data generator. The application excavates knowledge, such as data category information and distribution information, which has a guiding effect on the quantization model from the full-precision pre-training model through the knowledge matching data generator, so as to provide the accuracy of the quantization model, and further improve the accuracy of object classification. The application can be widely applied to the technical field of data processing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data processing technology, and in particular to a generative data-free quantization method, identification method, apparatus, and storage medium. Background Technology

[0002] Deep neural networks have achieved great success in many fields; however, their massive number of parameters and high computational cost make them difficult to deploy on embedded devices. Model quantization reduces model size, increases running speed, and reduces energy consumption by quantizing floating-point values ​​to lower precision. Existing quantization methods typically require training data for calibration or fine-tuning. However, in many real-world scenarios such as healthcare and finance, training data may be unavailable due to trade secrets or privacy concerns. This lack of training data renders existing quantization methods inapplicable, rendering existing automatic recognition models unusable.

[0003] To address the aforementioned issues, data-free quantization attempts to eliminate the quantization algorithm's dependence on the original training data, achieving quantization solely using a pre-trained model. Existing methods use the BN statistic of the full-precision model to generate synthetic data, facilitating knowledge transfer from the full-precision model to its quantized version. However, these methods suffer from two significant problems. First, the generated data exhibits homogeneity in distribution, lacking the diversity of real-world data. Second, the generated data lacks the category information of the real-world data. These two issues lead to a significant difference between the distribution of the generated data and the real-world data, resulting in a decrease in the accuracy of the quantization model and indirectly reducing the precision of object recognition. Summary of the Invention

[0004] In order to at least partially solve one of the technical problems existing in the prior art, the present invention aims to provide a generative data-free quantization method, identification method, apparatus and storage medium.

[0005] The technical solution adopted in this invention is:

[0006] A generative data-free quantization method includes the following steps:

[0007] Collect the target dataset, and pre-train the full-precision neural network based on the dataset to obtain a full-precision pre-trained model;

[0008] A knowledge matching data generator is trained based on a full-precision pre-trained model, and pseudo-data is generated as generated data; the knowledge matching data generator extracts classification and distribution information from the original data from the full-precision pre-trained model.

[0009] The generated data is used to drive the quantization of the full-precision model to obtain a quantized model;

[0010] The quantization model is iteratively optimized based on the knowledge-matching data generator.

[0011] Further, the collection of the target dataset, and the pre-training of a full-precision neural network based on the dataset to obtain a full-precision pre-trained model, includes:

[0012] Collect images from the target task scenario, and label the images by category to obtain a dataset;

[0013] The labeled dataset is divided into three parts: training set, validation set, and test set.

[0014] Determine the neural network to be used for the target task;

[0015] The neural network is trained using the dataset to obtain a full-precision pre-trained model.

[0016] Furthermore, the step of training a knowledge-matching data generator based on a full-precision pre-trained model includes:

[0017] The knowledge matching data generator is defined as follows:

[0018]

[0019] In the formula, Let z represent pseudo-data, z be a noise vector conditioned on label y, and G(z|y) represent the data generated by the generator from the noise. This indicates sampling noise from a Gaussian distribution;

[0020] The knowledge matching data generator is trained using cross-entropy loss, and the loss function during training is:

[0021]

[0022] In the formula, CE represents the cross-entropy loss, G is the knowledge matching data generator, and E z,y M(G(z|y)) represents the expected value, and M(G(z|y)) represents the input of the generated data into the full-precision model M.

[0023] The knowledge matching data generator is trained using BNS loss, and the loss function during training is:

[0024]

[0025] In the formula, and These are the mean and variance of the pseudo-data distribution in the l-th BN layer, respectively. and σ l These are the mean and variance parameters stored in the first BN layer of the fully-precision pre-trained model.

[0026] Furthermore, the step of using the generated data to drive the quantization of the full-precision model to obtain the quantized model includes:

[0027] The full-precision model is quantized and compressed to obtain a quantized model;

[0028] The quantization model is trained and fine-tuned using the cross-entropy loss function to bring its performance close to that of the full-precision model. The loss function used in training is:

[0029]

[0030] In the formula, Q represents the quantization model, and CE represents the cross-entropy loss. Indicates the expected value. This represents the cross-entropy loss calculated on the output and labels of the quantized model Q;

[0031] The logits of the full-precision pre-trained model are calculated using the mean squared error function. and quantization model output Alignment is performed to fine-tune the quantization model;

[0032] The normalized statistics of the full-precision pre-trained model are used in the quantization model and kept constant.

[0033] Furthermore, the step of quantizing and compressing the full-precision model to obtain a quantized model includes:

[0034] Determine the weights θ and quantization precision b corresponding to the full-precision model, and calculate the discrete values ​​mapped by linear quantization. in η = l·Δ + 2 b-1 l and u are the minimum and maximum values ​​of the weight θ, respectively;

[0035] The discrete value θ′ is truncated to θ. q =[-2 b-1 ,2 b-1 -1],θ q This refers to the quantified weights and activation amounts.

[0036] Furthermore, the iterative optimization quantization model includes:

[0037] During fine-tuning, the knowledge matching data generator G and the quantization model Q are alternately optimized in each iteration; in the alternating optimization strategy, the knowledge matching data generator G generates different data each time it is updated; by increasing the diversity of data, the quantization model Q is optimized.

[0038] Continuously update the knowledge matching data generator G and the quantization model Q until the quantization model Q converges.

[0039] Furthermore, the optimized quantization model is deployed on mobile devices, including mobile smart terminals and control terminals in automobiles.

[0040] Another technical solution adopted in this invention is:

[0041] An identification method includes the following steps:

[0042] Obtain the image to be classified and recognized;

[0043] The obtained images are input into a quantization model for classification and recognition, and the classification results are output; wherein, the quantization model is obtained through a generative data-free quantization method as described above;

[0044] Among them, classification recognition includes at least one of facial recognition, medical image recognition, and traffic scene recognition (such as traffic light recognition and traffic sign recognition).

[0045] Another technical solution adopted in this invention is:

[0046] An apparatus comprising:

[0047] At least one processor;

[0048] At least one memory for storing at least one program;

[0049] When the at least one program is executed by the at least one processor, the at least one processor implements the method described above.

[0050] Another technical solution adopted in this invention is:

[0051] A computer-readable storage medium storing a processor-executable program, which, when executed by a processor, performs the method described above.

[0052] The beneficial effects of this invention are: This invention uses a knowledge matching data generator to mine knowledge that guides the quantization model from the full-precision pre-trained model, such as data category information and distribution information, thereby improving the accuracy of the quantization model and thus improving the accuracy of object classification. Attached Figure Description

[0053] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following description is provided with accompanying drawings of the relevant technical solutions in the embodiments of the present invention or the prior art. It should be understood that the accompanying drawings described below are only for the purpose of clearly illustrating some embodiments of the technical solutions of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0054] Figure 1 This is a flowchart of the steps of a generative data-free quantization method in an embodiment of the present invention;

[0055] Figure 2 This is a schematic diagram of generative dataless quantization based on knowledge matching in an embodiment of the present invention;

[0056] Figure 3 This is a flowchart of the steps of an identification method in an embodiment of the present invention. Detailed Implementation

[0057] The embodiments of the present invention are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and should not be construed as limiting the present invention. The step numbers in the following embodiments are set only for ease of explanation, and there is no limitation on the order between the steps. The execution order of each step in the embodiments can be adaptively adjusted according to the understanding of those skilled in the art.

[0058] In the description of this invention, it should be understood that the orientation descriptions, such as up, down, front, back, left, right, etc., are based on the orientation or positional relationship shown in the accompanying drawings. They are only for the convenience of describing this invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limiting this invention.

[0059] In the description of this invention, "several" means one or more, "more than" means two or more, "greater than," "less than," and "exceeding" are understood to exclude the stated number, while "above," "below," and "within" are understood to include the stated number. The use of "first" and "second" in the description is merely for distinguishing technical features and should not be construed as indicating or implying relative importance, or implicitly indicating the number of indicated technical features, or implicitly indicating the order of the indicated technical features.

[0060] In the description of this invention, unless otherwise explicitly defined, terms such as "set up," "install," and "connect" should be interpreted broadly, and those skilled in the art can reasonably determine the specific meaning of the above terms in this invention in conjunction with the specific content of the technical solution.

[0061] Terminology Explanation:

[0062] BNS: Batch Normalized Statistics.

[0063] MSE: Mean Square Error Alignment.

[0064] like Figure 1As shown, this embodiment provides a generative data-free quantization method. The first step involves constructing a target dataset and pre-training a full-precision neural network. Then, a knowledge-matching generator is learned to produce meaningful data. The generator mines the classification boundaries and distribution information of the original data from the pre-trained full-precision model. Next, the generated data is used to quantize the pre-trained model, and the quantized model is fine-tuned using fixed-batch normalized statistics (BNS) to obtain more stable accuracy. Furthermore, mean squared error alignment is introduced to learn more knowledge directly from the pre-trained model, which has a significant effect on obtaining a better-performing quantized model. Finally, the generator and the quantized model are trained iteratively, alternating between the two, until the quantized model converges.

[0065] The above method will be explained in detail below with reference to the accompanying drawings.

[0066] like Figure 1 and Figure 2 As shown, this embodiment provides a generative data-free quantization method based on knowledge matching, including:

[0067] S1. Collect the target dataset, and pre-train the full-precision neural network based on the dataset to obtain a full-precision pre-trained model.

[0068] Step S1 specifically includes:

[0069] S1-1: Collect images from the target task scenario and label the images by category to construct a dataset;

[0070] S1-2: Divide the labeled dataset into three parts: training set, validation set, and test set;

[0071] S1-3: Identify the neural network required for the target task;

[0072] S1-4: Use the dataset to perform regular training on the neural network to obtain a pre-trained full-precision neural network.

[0073] S2. Train a knowledge matching data generator based on the full-precision pre-trained model and generate pseudo data as generated data; wherein, the knowledge matching data generator mines the classification and distribution information of the original data from the full-precision pre-trained model.

[0074] Step S2 specifically includes:

[0075] S2-1: When training a deep neural network, it captures enough data information to make decisions. Therefore, the pre-trained neural network contains some knowledge information about the training data, such as classification boundary information and distribution information. However, this information is difficult to use to recover data close to the classification boundary. Recently, Generative Adversarial Networks (GANs) have achieved considerable success in generating data. This invention proposes a knowledge matching generator capable of generating pseudo-data that can be used for tasks without data quantization. For this task, although the original data cannot be observed, the number of classes in the original data can be easily determined through the last layer of the pre-trained model.

[0076] To generate fake data, a noise vector z conditioned on a label y is introduced. Noise is sampled from a normal distribution, and a label is sampled from a uniform distribution {0,1,...,n-1}. The generator then maps a prior input noise vector and a given label to the fake data. In form, the knowledge matching generator is defined as follows:

[0077] S2-2: Training the Knowledge-Matching Data Generator: To improve quantization performance, the generator needs to be able to generate data that is effective for fine-tuning the quantization model. For this purpose, the generated data should be classified into the same category y by the full-precision pre-trained model M. Therefore, the following cross-entropy loss CE(·,·) is introduced to train the generator G:

[0078] S2-3: The BNS layer in the pre-trained model contains distribution information of the training data. If the generated data can retain the BNS information, it will help the distribution of the generated data match the distribution of the real data. Therefore, BNS loss is used to train the generated data G: in and These are the mean and variance of the pseudo-data distribution in the l-th BN layer, respectively. and σ l These are the mean and variance parameters stored in the l-th Batch Normalization (BN) layer of the pre-trained full-precision model. This allows us to learn a good generator that preserves the distribution information of the training data.

[0079] S3. Use the generated data to drive the quantization of the full-precision model to obtain the quantized model.

[0080] Step S3 specifically includes:

[0081] S3-1: By using generators, missing data can be filled in when there is no data, and then meaningful data generated can be used to quantize the model. This is a data-driven quantization method that uses knowledge from pre-trained models to solve the optimization problem of the quantized model.

[0082] S3-2: Model quantization maps full-precision (32-bit) weights and activations to low precision. For weights and activations, a simple and efficient quantization method is used. Specifically, given the full weights θ and the quantization precision b, discrete values ​​mapped by linear quantization are calculated. in η = l·Δ + 2 b-1 l and u are set to the minimum and maximum values ​​of the floating-point weight θ, respectively. Then, θ′ will be truncated to θ within a symmetric b-bit range. q =[-2 b-1 ,2 b-1 -1]. θ q This refers to the quantified weights and activation amounts.

[0083] S3-3: Quantization can be limited when real training data is unavailable. First, direct quantization from a full-precision model can lead to a significant performance degradation. To address this, the quantization model is fine-tuned to approximate the performance of the full-precision model. The fine-tuned quantization model Q should be able to correctly classify fake data. Q is updated using the cross-entropy loss function CE(·,·) for this purpose.

[0084] S3-4: Since the data is fabricated, using only common classification loss functions is insufficient for fine-tuning. However, knowledge distillation can be used with the fabricated data to further improve quantization performance. Specifically, given the same input, the outputs of the quantized model and the full-precision model should be sufficiently close to ensure that the quantized model achieves almost identical performance compared to the full-precision model. The Mean Squared Error function is used to distill the output of the pre-trained full-precision model. and the quantized model Alignment is performed to fine-tune the quantization model:

[0085]

[0086] By optimizing this function, the quantization model can learn more from the full-precision model.

[0087] S3-5: Fine-tuning using a fixed BNS: To stabilize the fine-tuning process, the normalized statistic (BNS) of the pre-trained full-precision model is used in the quantization model and kept constant. With a fixed BNS, the quantization model always maintains the distribution information of the real data, thereby improving quantization performance.

[0088] S4. Iteratively optimize the quantization model based on the knowledge matching data generator.

[0089] Step S4 specifically includes:

[0090] S4-1: To make the fine-tuning of Q more stable, train G separately a few times as a warm-up process.

[0091] S4-2: During fine-tuning, the generator G and the quantization model Q are alternately optimized in each epoch. In this alternating training strategy, the generator can generate different data with each update. By increasing the diversity of data, the quantization model Q can be trained to improve performance.

[0092] S4-3: Continuously update the G and Q models until Q converges. Continuously training G can make the fake data closer to the real training data, and the upper limit of Q optimization will also be increased.

[0093] Existing technologies use KL alignment to fine-tune the quantized model, while the MSE proposed in this invention demonstrates superiority and rationality compared to KL alignment in data-free quantization tasks. Firstly, MSE alignment is superior in the absence of data. In normal knowledge distillation, KL divergence makes the student's logits distribution close to the teacher's, which is sufficiently suitable and effective for extracting hidden knowledge from the teacher to the student, and optimizing the student model with real data. The teacher model's logits distribution provides sufficient information for the student model to utilize knowledge. However, according to the distribution shift:

[0094]

[0095] Even after training convergence and the KL divergence reaches its minimum, the student's logits distribution may still deviate significantly from the teacher's model distribution. This is especially critical in the absence of data, where the teacher's knowledge is inaccessible due to the lack of access to real-world data. If we fail to fully utilize the logits information in the teacher's model, we will only obtain a poorly performing model. Therefore, we introduce MSE alignment to address the distribution shift problem in the case of data freedom. When the MSE distance reaches its minimum, the student's logits distribution is closer to the teacher's model distribution.

[0096] Secondly, MSE alignment is reasonable for quantization tasks. In knowledge distillation, the teacher-student architecture is crucial for knowledge transfer. Typically, teacher and student models have different sizes and architectures during distillation. Forcing two models with different sizes and architectures to have the same logits is unreasonable. Therefore, KL divergence uses the probability calculated by the softmax operation as a soft objective to fit the structural gap between models. Conversely, unlike ordinary knowledge distillation, in our quantization task, we use a full-precision model as the teacher and a quantized model as the student. The student model is a quantized version of the teacher network, preserving the network's structure. Therefore, we consider using a more stringent metric, MSE alignment, to push the quantized model closer to the full-precision model, which is reasonable under the same architecture. If we use MSE as the optimization function, we can encourage the quantized model to move closer to the full-precision model for better performance while compensating for missing data.

[0097] In summary, the generative data-free quantization algorithm based on knowledge matching proposed in this invention can effectively restore the accuracy of the quantization model through generated pseudo-data and MSE knowledge distillation. Tables 1 and 2 show the comparison results with existing state-of-the-art methods on the CIFAR and ImageNet datasets, respectively. After applying the method of this embodiment, high-precision data-free quantization can be achieved on two commonly used image recognition datasets, which is a significant improvement over existing methods and approaches the accuracy of data-based quantization.

[0098] Table 1

[0099]

[0100] Table 2

[0101]

[0102]

[0103] like Figure 3 As shown, this embodiment also provides an identification method including the following steps:

[0104] A1. Obtain the image to be classified and recognized;

[0105] A2. Input the obtained images into a quantization model for classification and recognition, and output the classification results; wherein, the quantization model uses, for example... Figure 1 This is obtained using a generative, data-free quantization method.

[0106] Among them, classification recognition includes at least one of face recognition, traffic light recognition, and traffic sign recognition.

[0107] In some real-world implementations, the data used to train pre-trained models may need to be kept confidential and cannot be accessed during quantization because many pre-models only publish the model itself, not the dataset, making it impossible to know what data was used. There are also many scenarios where data is privacy-sensitive and cannot be used, whether for pre-training or quantization. Examples include facial recognition data, medical imaging data, and autonomous driving data.

[0108] This invention enables the quantization of image classification models such as ResNet and MobileNet without the need for original training data, and then trains the quantized models to improve classification accuracy. The quantized models can be deployed on mobile devices such as smartphones and cars to perform image classification tasks such as face recognition, traffic light recognition, and traffic sign recognition.

[0109] Among them, ResNet convolutional neural networks achieve superior performance in image classification and object recognition. Residual networks are characterized by their ease of optimization and the ability to improve accuracy by significantly increasing depth. Their internal residual blocks use skip connections to mitigate the vanishing gradient problem inherent in increasing depth in deep neural networks. MobileNet is a convolutional neural network with a smaller model size, fewer trainable parameters, and lower computational cost, making it suitable for mobile devices. It aims to fully utilize limited computational resources and maximize model accuracy to meet various application scenarios with limited resources, and is one of the commonly used models deployed at the edge.

[0110] This embodiment also provides an apparatus, including:

[0111] At least one processor;

[0112] At least one memory for storing at least one program;

[0113] When the at least one program is executed by the at least one processor, the at least one processor performs the following: Figure 1 or Figure 3 The method shown.

[0114] One apparatus of this embodiment can execute the method provided in the method embodiment of the present invention, and can execute any combination of the implementation steps of the method embodiment, and has the corresponding functions and beneficial effects of the method.

[0115] This application also discloses a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device can read the computer instructions from the computer-readable storage medium and execute the computer instructions, causing the computer device to perform... Figure 1 or Figure 3 The method shown.

[0116] This embodiment also provides a storage medium storing instructions or programs that can execute the methods provided in the method embodiments of the present invention. When the instructions or programs are run, any combination of implementation steps of the method embodiments can be executed, and the method has the corresponding functions and beneficial effects.

[0117] In some alternative embodiments, the functions / operations mentioned in the block diagrams may not occur in the order shown in the operation diagrams. For example, depending on the functions / operations involved, two consecutively shown blocks may actually be executed substantially simultaneously, or the blocks may sometimes be executed in reverse order. Furthermore, the embodiments presented and described in the flowcharts of this invention are provided by way of example to provide a more comprehensive understanding of the technology. The disclosed methods are not limited to the operations and logic flows presented herein. Alternative embodiments are contemplated in which the order of various operations is altered and sub-operations described as part of a larger operation are executed independently.

[0118] Furthermore, although the invention has been described in the context of functional modules, it should be understood that, unless otherwise stated, one or more of the described functions and / or features may be integrated into a single physical device and / or software module, or one or more functions and / or features may be implemented in a separate physical device or software module. It is also understood that a detailed discussion of the actual implementation of each module is unnecessary for understanding the invention. Rather, given the properties, functions, and internal relationships of the various functional modules in the apparatus disclosed herein, the actual implementation of the module will be understood within the scope of conventional skill of an engineer. Therefore, those skilled in the art can implement the invention as set forth in the claims using ordinary techniques without excessive experimentation. It is also understood that the specific concepts disclosed are merely illustrative and not intended to limit the scope of the invention, which is determined by the full scope of the appended claims and their equivalents.

[0119] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, essentially, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0120] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-included system, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device.

[0121] More specific examples of computer-readable media (a non-exhaustive list) include: electrical connections (electronic devices) having one or more wires, portable computer disk drives (magnetic devices), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Furthermore, computer-readable media can even be paper or other suitable media on which the program can be printed, since the program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpreting, or otherwise processing as necessary, and then stored in computer memory.

[0122] It should be understood that various parts of the present invention can be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.

[0123] In the foregoing description of this specification, references to terms such as "one embodiment," "another embodiment," or "some embodiments" indicate that a specific feature, structure, material, or characteristic described in connection with an embodiment or example is included in at least one embodiment or example of the present invention. In this specification, illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.

[0124] Although embodiments of the invention have been shown and described, those skilled in the art will understand that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the claims and their equivalents.

[0125] The above is a detailed description of the preferred embodiments of the present invention. However, the present invention is not limited to the above embodiments. Those skilled in the art can make various equivalent modifications or substitutions without departing from the spirit of the present invention. All such equivalent modifications or substitutions are included within the scope defined by the claims of this application.

Claims

1. A generative data-free quantization method, characterized in that, Includes the following steps: Collect the target image dataset, and pre-train the full-precision neural network based on the image dataset to obtain the full-precision pre-trained model; A knowledge matching data generator is trained based on a full-precision pre-trained model, and pseudo-data is generated as generated data; the knowledge matching data generator extracts classification and distribution information from the original data from the full-precision pre-trained model. The generated data is used to drive the quantization of the full-precision model to obtain a quantized model; The quantization model is iteratively optimized based on the knowledge-matching data generator. The process of using the generated data to drive the quantization of the full-precision model to obtain the quantized model includes: The full-precision model is quantized and compressed to obtain a quantized model; The quantization model is trained and fine-tuned using the cross-entropy loss function, so that the performance of the quantization model approaches that of the full-precision model. The logits of the full-precision pre-trained model are calculated using the mean squared error function. And quantization model output logits Alignment is performed to fine-tune the quantization model; In the quantization model, the normalized statistics of the full-precision pre-trained model are used and kept constant; The knowledge matching data generator trained based on the full-precision pre-trained model includes: The knowledge matching data generator is defined as follows: In the formula, This represents pseudo data. For the purpose of using tags For the conditional noise vector, This indicates that the generator produces data from noise. This indicates sampling noise from a Gaussian distribution; The knowledge matching data generator is trained using cross-entropy loss, and the loss function during training is: In the formula, Represents cross-entropy loss, For knowledge matching data generator, Indicates the expected value. This indicates that the generated data will be input into the full-precision model M; The knowledge matching data generator is trained using BNS loss, and the loss function during training is: In the formula, They are the first The mean and variance of the pseudo-data distribution in the layer BN layer. It is the first one stored in the full-precision pre-trained model. Mean and variance parameters in a layered BN layer; The cross-entropy loss function during training is: In the formula, For quantification models, Represents cross-entropy loss, Indicates the expected value. This represents the cross-entropy loss calculated on the output and label of the quantized model Q.

2. The generative dataless quantization method according to claim 1, characterized in that, The image dataset of the collection target is used to pre-train a full-precision neural network to obtain a full-precision pre-trained model, including: Collect images from the target task scenario, and label the images by category to obtain a dataset; The labeled dataset is divided into three parts: training set, validation set, and test set. Determine the neural network to be used for the target task; The neural network is trained using the dataset to obtain a full-precision pre-trained model.

3. The generative dataless quantization method according to claim 1, characterized in that, The process of quantizing and compressing the full-precision model to obtain a quantized model includes: Determine the weights corresponding to the full-precision model and quantization accuracy Calculate the discrete values ​​mapped by linear quantization. ,in , , and Weights The minimum and maximum values; Discrete values Cut off as , This refers to the quantified weights and activation amounts.

4. The generative dataless quantization method according to claim 1, characterized in that, The iterative optimization quantization model includes: During fine-tuning, the knowledge matching data generator G and the quantization model Q are alternately optimized in each iteration; in the alternating optimization strategy, the knowledge matching data generator G generates different data each time it is updated; by increasing the diversity of data, the quantization model Q is optimized. Continuously update the knowledge matching data generator G and the quantization model Q until the quantization model Q converges.

5. The generative dataless quantization method according to claim 1, characterized in that, The optimized quantization model is deployed on mobile devices, including mobile smart terminals and control terminals in automobiles.

6. A method for identification, characterized in that, Includes the following steps: Obtain the image to be classified and recognized; The obtained images are input into a quantization model for classification and recognition, and the classification results are output; wherein, the quantization model is obtained by a generative data-free quantization method as described in any one of claims 1-5; Among them, classification and recognition include at least one of facial recognition, medical image recognition, and traffic scene recognition.

7. A generative dataless quantization device, characterized in that, include: At least one processor; At least one memory for storing at least one program; When the at least one program is executed by the at least one processor, the at least one processor implements the method according to any one of claims 1-6.

8. A computer-readable storage medium storing a processor-executable program, characterized in that, The processor-executable program, when executed by the processor, is used to perform the method as described in any one of claims 1-6.

Citation Information

Patent Citations

  • INT8 offline quantization and integer inference method based on Transform model

    CN113011571A