Knowledge distillation methods and systems

Through the knowledge distillation method and loss function optimization, multiple teacher models are used to guide student model training, which solves the accuracy loss problem when the full-precision neural network is simplified into a binary neural network, and achieves efficient deep learning model deployment on edge devices.

CN112508169BActive Publication Date: 2024-09-24HUAWEI TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202011273058.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-11-13
Publication Date
2024-09-24
Estimated Expiration
2040-11-13

AI Technical Summary

Technical Problem

When existing technologies simplify full-precision neural networks into binary neural networks, they often lead to inaccurate gradient updates and accuracy losses, making it difficult to effectively deploy deep learning models on edge devices.

Method used

Through the knowledge distillation method, multiple high-bit-width teacher models are used to jointly guide the training of low-bit-width student models. Loss functions include Kullback-Leibler divergence, distance loss, and cross-entropy loss are used to adjust the student model parameters to match the teacher. Model output, dynamically adjust the weight coefficient to optimize the training effect.

Benefits of technology

It improves the accuracy of student models, reduces computing resource requirements, avoids accuracy loss, and enables deep learning model deployment on edge devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112508169B
    Figure CN112508169B
Patent Text Reader

Abstract

The present application relates to a method for training a neural network by knowledge distillation in the field of artificial intelligence. The method comprises: training at least one teacher machine learning model according to training data; inputting the training data into the trained teacher machine learning model to obtain the output result of the trained teacher machine learning model; and adjusting the parameters of the student machine learning model according to the loss function, so that the difference between the output result of the student machine learning model for the training data and the output result of the trained teacher machine learning model is less than a preset threshold. The loss function comprises a first part and a second part, the first part of the loss function is determined according to the output result of the trained teacher machine learning model, and the second part of the loss function is determined according to the intermediate layer output feature generated by the intermediate layer included in the trained teacher machine learning model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and specifically to a knowledge distillation method and system. Background Art

[0002] As one of the mainstream branches of machine learning, deep learning has been widely cited in image processing, face recognition and other fields. Convolutional Neural Networks (CNN) is one of the representative algorithms of deep learning. It has been widely used in large-scale computer vision applications (such as image classification, target detection, image segmentation and video analysis) and has achieved great success. Convolutional neural network models, especially deep neural network (DNN) models, require a large amount of computing power and memory. In common CNNs, the number of parameters of each convolution layer can reach tens of thousands or even hundreds of thousands, and the cumulative number of parameters of all convolution layers of the entire network can reach tens of millions. If represented by 32-bit floating point numbers, hundreds of megabytes of memory or cache are required. On the other hand, the computational complexity of convolution operations is huge. For a convolution kernel with hundreds of thousands of parameters, the number of floating point operations (FLOPs) of convolution operations can reach tens of millions. In common CNNs, the FLOPs of the entire network can be as high as billions.

[0003] Edge devices such as mobile phones and wearable devices need to process deep learning-related tasks locally, and are limited by limited resources and power consumption as well as latency and cost considerations, making it difficult to meet the computing power and memory requirements of common CNNs. Therefore, products based on deep learning are difficult to deploy on these edge devices. In order to promote the application of deep learning-based products on edge devices, one approach is to design dedicated hardware accelerators for given computing tasks, and another approach is to simplify the neural network model to reduce its computing power and memory requirements, which is model compression. Model compression includes a variety of methods, such as pruning, quantization, low-rank factorization, and knowledge distillation. Among them, the research on simplifying full-precision neural networks into binary neural networks has received widespread attention. Binary neural networks represent the weights / activation values ​​of full-precision neural networks in binary values ​​(such as 1 and -1), and convert the original floating-point multiplication and addition operations into bit operations, which can greatly reduce the required computing resources and increase the computing speed, which is conducive to deployment on mobile terminals. However, the method used in the prior art to simplify the full-precision neural network into a binary neural network is generally quantized by a sign function or approximated by a straight-through estimator (STE) to calculate the gradient of the network parameters of a 32-bit floating point number. This will lead to inaccurate gradients and affect the update accuracy of the network parameters of the full-precision neural network and the update accuracy of the network parameters of the binary neural network. In this way, when the weights and activation values ​​of the full-precision neural network are quantized to binary, the training of the network is prone to fall into local minimum points, resulting in insufficient training and a large loss of accuracy. On the other hand, model compression based on knowledge distillation transfers the reasoning and prediction capabilities of the trained more complex machine learning model to that of the simpler machine learning model. Therefore, knowledge distillation can be applied to the full-precision neural network to obtain a low-bit-width neural network with a lower bit-width weight / activation value. The low-bit-width neural network replaces the floating-point calculations of the full-precision neural network with low-bit-width values, thereby improving the computing efficiency but at the same time causing precision loss. The greater the difference in bit width between the teacher network and the student network used for knowledge distillation, the greater the precision loss, which is not conducive to simplifying the full-precision neural network into a binary neural network.

[0004] Therefore, a model compression method is needed that can effectively reduce the required computing resources and improve the computing speed while minimizing the loss of accuracy, especially for simplifying the full-precision neural network model into a binary neural network model. Summary of the invention

[0005] The purpose of the present application is to provide a method, system and computer-readable storage medium for training a neural network through knowledge distillation. The method includes: training at least one teacher machine learning model according to training data to obtain a trained teacher machine learning model; inputting the training data into the trained teacher machine learning model to obtain the output result of the trained teacher machine learning model, wherein the intermediate layer included in the trained teacher machine learning model generates corresponding intermediate layer output features in the process of generating the output result of the trained teacher machine learning model; and adjusting the parameters of the student machine learning model according to the loss function, so that the difference between the output result of the student machine learning model for the training data and the output result of the trained teacher machine learning model is less than a preset threshold, wherein the loss function includes a first part and a second part, the first part of the loss function is determined according to the output result of the trained teacher machine learning model, and the second part of the loss function is determined according to the intermediate layer output features generated by the intermediate layer included in the trained teacher machine learning model. In this way, it is realized that the training of the student machine model is jointly guided by multiple trained teacher machine learning models, thereby improving the accuracy of the student machine learning model. At the same time, the loss function takes into account the changes in the importance of distillation of different teacher networks and different intermediate layers to the student network, which is conducive to improving the training effect.

[0006] In the first aspect, an embodiment of the present application provides a method for training a neural network by knowledge distillation. The method includes: training at least one teacher machine learning model according to training data to obtain a trained teacher machine learning model; inputting the training data into the trained teacher machine learning model to obtain the output result of the trained teacher machine learning model, wherein the intermediate layer included in the trained teacher machine learning model generates corresponding intermediate layer output features in the process of generating the output result of the trained teacher machine learning model; and adjusting the parameters of the student machine learning model according to the loss function, so that the difference between the output result of the student machine learning model for the training data and the output result of the trained teacher machine learning model is less than a preset threshold, wherein the loss function includes a first part and a second part, the first part of the loss function is determined according to the output result of the trained teacher machine learning model, and the second part of the loss function is determined according to the intermediate layer output features generated by the intermediate layer included in the trained teacher machine learning model.

[0007] The technical solution described in the first aspect realizes the use of multiple trained teacher machine learning models to jointly guide the training of student machine models, thereby improving the accuracy of the student machine learning model. At the same time, the loss function takes into account the changes in the importance of different teacher networks and different intermediate layers to the distillation of the student network, which is conducive to improving the training effect.

[0008] According to the first aspect, in one possible implementation, the bit width used by the weights and activation values ​​of the at least one teacher machine learning model is greater than the bit width used by the weights and activation values ​​of the student machine learning model.

[0009] In this way, a high-bit-width teacher machine learning model is used to guide the training of a low-bit-width student machine model, which is beneficial for reducing the required computing resources and improving the computing speed while minimizing the loss of accuracy.

[0010] According to the first aspect, in one possible implementation, the first part of the loss function includes a Kullback-Leibler (KL) divergence determined based on an output result of the trained teacher machine learning model and an output result of the student machine learning model for the training data.

[0011] In this way, the influence of the output result is taken into account by the first part of the loss function.

[0012] According to the first aspect, in one possible implementation, the number of intermediate layers included in the student machine learning model is the same as the number of intermediate layers included in the at least one teacher machine learning model, and the intermediate layers included in the student machine learning model generate corresponding intermediate layer output features in the process of generating the output results of the student machine learning model, and the second part of the loss function includes the distance loss determined based on the intermediate layer output features generated by the intermediate layers included in the trained teacher machine learning model and the intermediate layer output features generated by the intermediate layers included in the student machine learning model after conversion by the point convolution layer.

[0013] In this way, the second part of the loss function takes into account the changes in the importance of distillation of different teacher networks and different intermediate layers to the student network.

[0014] According to the first aspect, in a possible implementation, the loss function also includes a third part, and the third part of the loss function includes a cross entropy loss determined based on the output results of the student machine learning model for the training data and the true label of the training data.

[0015] In this way, the training effect is improved by the third part of the loss function.

[0016] According to the first aspect, in a possible implementation method, the at least one teacher machine learning model includes multiple teacher machine learning models, wherein the number of intermediate layers included in each of the multiple teacher machine learning models and the number of intermediate layers included in the student machine learning model are the same, wherein, according to the training data, training at least one teacher machine learning model to obtain a trained teacher machine learning model includes: according to the training data, respectively training the multiple teacher machine learning models to obtain a corresponding multiple trained teacher machine learning models.

[0017] In this way, it is possible to use multiple trained teacher machine learning models to jointly guide the training of student machine models.

[0018] According to the first aspect, in one possible implementation, the bit width used for the weights and activation values ​​of each of the multiple teacher machine learning models is greater than the bit width used for the weights and activation values ​​of the student machine learning model.

[0019] In this way, a high-bit-width teacher machine learning model is used to guide the training of a low-bit-width student machine model, which is beneficial for reducing the required computing resources and improving the computing speed while minimizing the loss of accuracy.

[0020] According to the first aspect, in a possible implementation method, the training data is input into the trained teacher machine learning model to obtain the output result of the trained teacher machine learning model, including: inputting the training data into the multiple trained teacher machine learning models respectively to obtain the output results of the multiple trained teacher machine learning models corresponding to each other, wherein, for each of the multiple trained teacher machine learning models: the multiple intermediate layers included in the specific trained teacher machine learning model each generate corresponding intermediate layer output features in the process of the specific trained teacher machine learning model generating the output result of the specific trained teacher machine learning model.

[0021] In this way, the impact of the output results is taken into account.

[0022] According to the first aspect, in a possible implementation method, the multiple trained teacher machine learning models correspond one-to-one to multiple first weight coefficients in the first weight coefficient set, and the output results of the multiple trained teacher machine learning models are weighted and summed according to their respective corresponding first weight coefficients to obtain the classification layer output results of the multi-bit teacher machine learning model, and the first part of the loss function includes the Kullback-Leibler (KL) divergence determined based on the classification layer output results of the multi-bit teacher machine learning model and the output results of the student machine learning model for the training data.

[0023] In this way, the influence of the output result is taken into account by the first part of the loss function.

[0024] According to the first aspect, in a possible implementation method, the multiple intermediate layers included in each of the multiple trained teacher machine learning models correspond one-to-one to the multiple second weight coefficients in the second weight coefficient set, wherein, for one or more of the multiple intermediate layers included in the student machine learning model: determine the intermediate layer output features of the multi-bit teacher machine learning model corresponding to the specific intermediate layer of the student machine learning model, wherein the intermediate layer output features of the multi-bit teacher machine learning model are obtained by weighted summing the intermediate layer output features generated by the intermediate layers of the multiple trained teacher machine learning models at the same level as the specific intermediate layer according to their respective corresponding second weight coefficients; the second part of the loss function includes the distance loss determined based on the intermediate layer output features of the multi-bit teacher machine learning model and the intermediate layer output features generated by the specific intermediate layer of the student machine learning model after conversion by the point convolution layer.

[0025] In this way, the second part of the loss function takes into account the changes in the importance of distillation of different teacher networks and different intermediate layers to the student network.

[0026] According to the first aspect, in a possible implementation, the second part of the loss function also includes summing up the distance losses corresponding to each of the multiple intermediate layers included in the student machine learning model after smoothing.

[0027] In this way, smoothing is beneficial to training stability.

[0028] According to the first aspect, in a possible implementation, the loss function also includes a third part, and the third part of the loss function includes a cross entropy loss determined based on the output results of the student machine learning model for the training data and the true label of the training data.

[0029] In this way, the training effect is improved by the third part of the loss function.

[0030] According to the first aspect, in a possible implementation, the method further includes: differentiating the first weight coefficient through the loss function to obtain a first gradient, wherein the first gradient is the gradient of the loss function with respect to the classification layer output result of the multi-bit teacher machine learning model, and the first gradient is determined according to the KL divergence included in the first part of the loss function; differentiating the second weight coefficient through the loss function to obtain a second gradient, wherein the second gradient is the gradient of the loss function with respect to the intermediate layer output feature of the multi-bit teacher machine learning model, and the second gradient is determined according to the distance loss included in the second part of the loss function; back-propagating through the first gradient and the second gradient respectively, thereby dynamically adjusting the first weight coefficient and the second weight coefficient respectively.

[0031] In this way, dynamic self-adjustment is achieved according to the corresponding part of the loss function, which is beneficial to simplify calculations and improve system efficiency.

[0032] According to the first aspect, in one possible implementation, the weights and activation values ​​of the student machine learning model are both binarized.

[0033] In this way, a student machine learning model simplified into a binary model is achieved.

[0034] In a second aspect, an embodiment of the present application provides a knowledge distillation system. The knowledge distillation system includes: multiple teacher machine learning models, and a student machine learning model. The number of intermediate layers included in each of the multiple teacher machine learning models and the number of intermediate layers included in the student machine learning model are the same; the bit widths used for the weights and activation values ​​of each of the multiple teacher machine learning models are larger than the bit widths used for the weights and activation values ​​of the student machine learning model; the parameters of the student machine learning model are adjusted according to the loss function, so that the difference between the output results of the student machine learning model for the training data and the output results of the multiple teacher machine learning models for the training data is less than a preset threshold; the first part of the loss function includes the Kullback-Leibler (KL) divergence determined based on the classification layer output results of the multi-bit teacher machine learning model and the output results of the student machine learning model for the training data. The classification layer output result of the machine learning model is obtained by weighted summing the output results of the multiple teacher machine learning models for the training data according to their respective corresponding first weight coefficients; wherein, the second part of the loss function includes a distance loss determined based on the intermediate layer output features of the multi-bit teacher machine learning model and the intermediate layer output features generated by the specific intermediate layer of the student machine learning model after point convolution layer conversion, and the intermediate layer output features of the multi-bit teacher machine learning model are obtained by weighted summing the intermediate layer output features generated by the intermediate layers of the multiple teacher machine learning models at the same level as the specific intermediate layer according to their respective corresponding second weight coefficients; wherein, the third part of the loss function includes a cross entropy loss determined based on the output results of the student machine learning model for the training data and the true label of the training data.

[0035] The technical solution described in the second aspect realizes the use of multiple trained teacher machine learning models to jointly guide the training of student machine models, thereby improving the accuracy of student machine learning models. At the same time, the loss function takes into account the changes in the importance of distillation of different teacher networks and different intermediate layers to the student network, which is conducive to improving the training effect.

[0036] In a third aspect, an embodiment of the present application provides a computer-readable storage medium, which stores computer instructions, and is characterized in that when the computer instructions are executed by a processor, the processor performs the following operations: training at least one teacher machine learning model according to training data to obtain a trained teacher machine learning model; inputting the training data into the trained teacher machine learning model to obtain the output result of the trained teacher machine learning model, wherein the intermediate layer included in the trained teacher machine learning model generates corresponding intermediate layer output features in the process of generating the output result of the trained teacher machine learning model; and adjusting the parameters of the student machine learning model according to the loss function, so that the difference between the output result of the student machine learning model for the training data and the output result of the trained teacher machine learning model is less than a preset threshold, wherein the loss function includes a first part and a second part, the first part of the loss function is determined according to the output result of the trained teacher machine learning model, and the second part of the loss function is determined according to the intermediate layer output features generated by the intermediate layer included in the trained teacher machine learning model.

[0037] The technical solution described in the third aspect realizes the use of multiple trained teacher machine learning models to jointly guide the training of the student machine model, thereby improving the accuracy of the student machine learning model. At the same time, the loss function takes into account the changes in the importance of different teacher networks and different intermediate layers to the distillation of the student network, which is conducive to improving the training effect. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] In order to illustrate the technical solutions in the embodiments of the present application or the background technology, the drawings required for use in the embodiments of the present application or the background technology will be described below.

[0039] Figure 1 A knowledge distillation system including a single-teacher machine learning model provided in an embodiment of the present application is shown.

[0040] Figure 2 A knowledge distillation system including multiple teacher machine learning models provided in an embodiment of the present application is shown.

[0041] Figure 3 A schematic flow chart of a knowledge distillation method according to an embodiment of the present application is shown.

[0042] Figure 4 A schematic flow chart of another implementation method of the knowledge distillation method provided in an example of the present application is shown. DETAILED DESCRIPTION

[0043] The purpose of the present application is to provide a method, system and computer-readable storage medium for training a neural network through knowledge distillation. The method includes: training at least one teacher machine learning model according to training data to obtain a trained teacher machine learning model; inputting the training data into the trained teacher machine learning model to obtain the output result of the trained teacher machine learning model, wherein the intermediate layer included in the trained teacher machine learning model generates corresponding intermediate layer output features in the process of generating the output result of the trained teacher machine learning model; and adjusting the parameters of the student machine learning model according to the loss function, so that the difference between the output result of the student machine learning model for the training data and the output result of the trained teacher machine learning model is less than a preset threshold, wherein the loss function includes a first part and a second part, the first part of the loss function is determined according to the output result of the trained teacher machine learning model, and the second part of the loss function is determined according to the intermediate layer output features generated by the intermediate layer included in the trained teacher machine learning model. In this way, it is realized that the training of the student machine model is jointly guided by multiple trained teacher machine learning models, thereby improving the accuracy of the student machine learning model. At the same time, the loss function takes into account the changes in the importance of distillation of different teacher networks and different intermediate layers to the student network, which is conducive to improving the training effect.

[0044] The embodiments of the present application can be used in the following application scenarios, including but not limited to various scenarios in the field of computer vision applications such as face recognition, image classification, target detection, semantic segmentation, etc., or a processing system based on a neural network model deployed on an edge device (such as a mobile phone, wearable device, computing node, etc.), or an application scenario for speech signal processing, natural language processing, and recommendation system, or an application scenario where the neural network model needs to be compressed due to limited resources and latency requirements.

[0045] For illustrative purposes only, the embodiments of the present application can be used in the application scenario of object detection on a mobile phone. The technical problem that needs to be solved in this application scenario is: when a user uses a mobile phone to take a photo, it is necessary to automatically capture targets such as faces and animals to help the mobile phone automatically focus and beautify, etc. Therefore, a small and fast convolutional neural network model for target detection is needed, thereby bringing users a better user experience and improving the quality of mobile phone products.

[0046] For illustrative purposes only, the embodiments of the present application can also be used in the application scenario of autonomous driving scene segmentation. The technical problem that needs to be solved in this application scenario is that after the camera of the autonomous driving vehicle captures the road picture, the picture needs to be segmented to separate different objects such as the road surface, roadbed, vehicles, pedestrians, etc., so as to keep the vehicle driving in the correct area. Therefore, a convolutional neural network model that can quickly and correctly interpret and semantically segment the picture in real time is needed.

[0047] For illustrative purposes only, the embodiments of the present application can also be used in the application scenario of face verification at entrance gates. The technical problem that needs to be solved in this application scenario is: at the gates at the entrances of high-speed railways, airports, etc., when passengers perform face authentication, the camera will capture the face image and use the convolutional neural network to extract features, and then calculate the similarity with the image features of the identity document stored in the system; if the similarity is high, the verification is successful. Among them, feature extraction through convolutional neural networks is the most time-consuming, so an efficient convolutional neural network model that can quickly perform face verification and feature extraction is needed.

[0048] For illustrative purposes only, the embodiments of the present application can also be used in the application scenario of simultaneous interpretation by a translator. The technical problem that needs to be solved in this application scenario is that in the problem of speech recognition and machine translation, real-time speech recognition and translation must be achieved, so an efficient convolutional neural network model is required.

[0049] The embodiments of the present application can be adjusted and improved according to the specific application environment and are not specifically limited here.

[0050] In order to enable those skilled in the art to better understand the present application, the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.

[0051] See also Figure 1 , Figure 1 The knowledge distillation system including a single-teacher machine learning model provided by an embodiment of the present application is shown. Figure 1 As shown, the knowledge distillation system 100 includes a teacher machine learning model 110 and a student machine learning model 120. The student machine learning model 120 may be pre-trained, partially trained, or completely untrained. The knowledge distillation system 100 transfers the knowledge of the teacher machine learning model 110 to the student machine learning model 120, that is, the purpose of improving the reasoning and prediction ability of the student machine learning model 120 is achieved through the teacher machine learning model 110. The teacher machine learning model 110 is a trained model, and the output result of the classification layer 118 is represented as y t The teacher machine learning model 110 includes three intermediate layers 112, 114 and 116, and these intermediate layers are used to generate the output result yt The intermediate layer output features are generated in sequence in the process Know The output of the classification layer 128 of the student machine learning model 120 is denoted as y s The student machine learning model 120 includes three intermediate layers 122, 124 and 126, and these intermediate layers are used to generate the output result y s The intermediate layer output features are generated in sequence in the process and

[0052] Please continue reading Figure 1 The knowledge distillation system 100 first trains the teacher machine learning model 110 according to the training data to obtain the trained teacher machine learning model 110; then inputs the training data into the trained teacher machine learning model 110 to obtain the output result y of the trained teacher machine learning model 110 t ; Then adjust the parameters of the student machine learning model 120 according to the loss function, so that the output result y of the student machine learning model 120 for the training data s Matches the output result y of the trained teacher machine learning model 110 t The loss function includes a first part and a second part. The first part of the loss function is based on the output result y of the trained teacher machine learning model. t Determine that the second part of the loss function is based on the intermediate layer output features generated by the intermediate layer included in the trained teacher machine learning model and It should be understood that the output result y of the student machine learning model 120 is determined s Whether it matches the output result y of the teacher machine learning model 110 t , the difference between the two can be required to be less than a specified threshold after comparison, or the global minimization solution of the difference between the two can be solved, or other technical means can be used, which are not specifically limited here. In addition, when the training data for training the teacher machine learning model 110 has real labels, the prediction ability of the student machine learning model 120 or the training effect of the knowledge distillation system 100 can also be judged by the training data with real labels, and a matching judgment can be made when the prediction ability or training effect is good enough.

[0053] Please continue reading Figure 1, the bit width used by the weights and activation values ​​of the teacher machine learning model 110 is greater than the bit width used by the weights and activation values ​​of the student machine learning model 120. For example, the teacher machine learning model 110 can be a model using a 32-bit width, while the student machine learning model 120 can be a binary model, that is, a 1-bit width. In this way, compression from a high-bit width model to a low-bit width model can be achieved simultaneously, while knowledge transfer and inheritance of prediction capabilities can be achieved through knowledge distillation technology.

[0054] Please continue reading Figure 1 , the knowledge distillation system 100 adjusts the parameters of the student machine learning model 120 according to the loss function. The first part of the loss function includes the output result y based on the trained teacher machine learning model t and the output result y of the student machine learning model for the training data s And the Kullback-Leibler (KL) divergence is determined. In this way, the difference between the output results obtained for the same input data, that is, the training data, can be measured by the KL divergence. The knowledge distillation system 100 not only realizes knowledge transfer through the output results, but also improves the effect of knowledge distillation through the features of the intermediate layer output. Specifically, the number of intermediate layers included in the student machine learning model 120 is the same as the number of intermediate layers included in the teacher machine learning model 110. The second part of the loss function includes the intermediate layer output features generated based on the intermediate layers included in the trained teacher machine learning model 110 and and the intermediate layer output features generated by the intermediate layer included in the student machine learning model 120 after point convolution layer conversion and And the distance loss is determined. It should be understood that the number of intermediate layers included in the student machine learning model 120 is the same as the number of intermediate layers included in the teacher machine learning model 110, that is, the two have the same depth or the same number of hidden layers. The definition of depth here is relative to the output from the input to the classification layer of each of them. In other words, the number of intermediate layers or their depth included in the student machine learning model 120 refers to before the classification layer 128 of the student machine learning model 120; and the number of intermediate layers or their depth included in the teacher machine learning model 110 refers to before the classification layer 118 of the teacher machine learning model 110. Here, because the intermediate layers of the student machine learning model 120 and the teacher machine learning model 110 are not one-to-one corresponding channels, even the features output by the intermediate layers of the same layer may not necessarily have a corresponding relationship. For example, the first intermediate layer 122 of the student machine learning model 120 and the first intermediate layer 112 of the teacher machine learning model 110 are both located in the first layer, but the intermediate layer features output by each of them are and There is not necessarily a corresponding relationship between them, nor do they necessarily belong to the same channel. Therefore, it is necessary to generate the intermediate layer output features of the intermediate layer included in the student machine learning model 120 and The point convolution layer conversion is performed to improve the performance of the student machine learning model 120. In a possible implementation, the loss function also includes a third part. The third part of the loss function includes an output result y based on the student machine learning model 120 for the training data s and the cross entropy loss determined by the true labels of the training data.

[0055] See also Figure 2 , Figure 2 The knowledge distillation system including multiple teacher machine learning models provided by the embodiment of the present application is shown. Figure 2 As shown, the knowledge distillation system 200 includes teacher machine learning models 220, 240 and 260, and a student machine learning model 280. The student machine learning model 280 may be pre-trained, partially trained, or completely untrained. The student machine learning model 280 has three intermediate layers 282, 284 and 286 that output intermediate layer features in sequence. and And the classification layer 288 outputs ys. The teacher machine learning model 220 has three intermediate layers 222, 224 and 226 that output intermediate layer features in turn and And the classification layer 228 output The teacher machine learning model 240 has three intermediate layers 242, 244 and 246 that output intermediate layer features in sequence and And the classification layer 248 output The teacher machine learning model 260 has three intermediate layers 262, 264 and 266 that output intermediate layer features in sequence and And the classification layer 268 output It should be understood that the teacher machine learning models 220, 240 and 260, and the student machine learning model 280 each include the same number of intermediate layers, that is, these models have the same depth or the same number of hidden layers. The definition of depth here is relative to the output from the input to the respective classification layer. For example, the depth of the student machine learning model 280 is to the classification layer 288, while the depth of the teacher machine learning model 220 is to the classification layer 228. The teacher machine learning models 220, 240 and 260 are all models trained with the same training data. In one possible implementation, the teacher machine learning models 220, 240 and 260 are models with the same structure, or the depth of the models is the same, or the number of hidden layers is the same, or the number of channels is the same. The training of the teacher machine learning models 220, 240 and 260 uses the same training data to obtain the corresponding multiple trained teacher machine learning models 220, 240 and 260.

[0056] Please continue reading Figure 2 , the bit widths used for the weights and activation values ​​of the multiple teacher machine learning models 220, 240 and 260 are all greater than the bit widths used for the weights and activation values ​​of the student machine learning model 280. For example, the bit widths of the multiple teacher machine learning models 220, 240 and 260 can be 32 bits, 16 bits and 8 bits respectively, while the student machine learning model 120 can be a binary model, that is, 1 bit width. In this way, compression from a high-bit-width model to a low-bit-width model can be achieved simultaneously, and the inheritance of knowledge transfer and prediction capabilities can be achieved by combining the knowledge distillation technology of multiple teacher models. For another example, the bit widths of the multiple teacher machine learning models 220, 240 and 260 can be 32 bits, 32 bits and 16 bits respectively. In other words, multiple teacher machine learning models can have the same bit width or partially the same bit width.

[0057] Please continue reading Figure 2 The knowledge distillation system 200 inputs the same training data into the multiple trained teacher machine learning models 220, 240 and 260 respectively to obtain the output results of the multiple trained teacher machine learning models corresponding to each of them. and Furthermore, for each of the multiple trained teacher machine learning models 220, 240, and 260: the multiple intermediate layers included in the specific trained teacher machine learning model each generate corresponding intermediate layer output features in the process in which the specific trained teacher machine learning model generates the output result of the specific trained teacher machine learning model. The knowledge distillation system 200 adjusts the parameters of the student machine learning model 280 according to the loss function. Among them, the first part of the loss function requires the classification layer output result of the multi-bit teacher machine learning model, and the classification layer output result of the multi-bit teacher machine learning model is obtained by formula (1).

[0058]

[0059] In formula (1), y t Represents the classification layer output of the multi-bit teacher machine learning model; represents the classification layer output result of the teacher machine learning model with serial number m, where M is the total number of multiple teacher machine learning models; δ 0,m represents the first weight coefficient corresponding to the teacher machine learning model with sequence number m in the first weight coefficient set. The meaning of formula (1) is to obtain the classification layer output result of the multi-bit teacher machine learning model by weighted summing the output results of multiple trained teacher machine learning models according to their corresponding first weight coefficients. Figure 2 and formula (1), the output results of the trained teacher machine learning models 220, 240 and 260 are and The classification layer output results of the multi-bit teacher machine learning models representing the trained teacher machine learning models 220, 240 and 260 are obtained by weighting each of the corresponding first weight coefficients and summing them up. It should be understood that Figure 2 Only the case of three teacher machine learning models is schematically shown. The total number M of the multiple teacher machine learning models mentioned in formula (1) can be any positive integer greater than 1. Figure 2 The case of three teacher machine learning models shown can also be extended to the case of M teacher machine learning models.

[0060] Please continue reading Figure 2 , the first part of the loss function is expressed as formula (2).

[0061]

[0062] In formula (2), y t represents the classification layer output result of the multi-bit teacher machine learning model obtained by formula (1), y srepresents the output result of the student machine learning model for the training data, T is a hyperparameter or temperature parameter, σ represents the softmax activation function, and the left side of formula (2) represents the Kullback-Leibler (KL) divergence of the classification layer output. As shown in formula (2), the first part of the loss function includes the KL divergence determined based on the classification layer output result of the multi-bit teacher machine learning model and the output result of the student machine learning model for the training data. It should be understood that when the temperature parameter T increases, the probability distribution of the output of the softmax activation function becomes smoother.

[0063] Please continue reading Figure 2 And formula (2), the knowledge distillation system 200 uses KL divergence to measure the difference between the output results obtained for the same input data, that is, the training data, so as to realize the knowledge transfer from multiple teacher machine learning models to the student machine learning model through the output results. The knowledge distillation system 200 also improves the effect of knowledge distillation through the features of the intermediate layer output. Specifically, the knowledge distillation system 200 also uses the intermediate layer output features of the multi-bit teacher machine learning model in formulas (1) and (2). The intermediate layer output features of the multi-bit teacher machine learning model are obtained by formula (3).

[0064]

[0065] In formula (3), Represents the intermediate layer output features output by the intermediate layer with sequence number i of the multi-bit teacher machine learning model; represents the intermediate layer output features output by the intermediate layer with sequence number i in the teacher machine learning model with sequence number m; δ i,m represents the second weight coefficient corresponding to the middle layer with the serial number i in the teacher machine learning model with the serial number m; M is the total number of multiple teacher machine learning models. Figure 2 Taking the knowledge distillation system 200 shown as an example, M is 3. Formula (3) means that: the multiple intermediate layers included in each of the multiple trained teacher machine learning models correspond one-to-one to the multiple second weight coefficients in the second weight coefficient set; wherein, for one or more of the multiple intermediate layers included in the student machine learning model: determine the intermediate layer output features of the multi-bit teacher machine learning model corresponding to the specific intermediate layer of the student machine learning model, wherein the intermediate layer output features of the multi-bit teacher machine learning model are obtained by weighted summing the intermediate layer output features generated by the intermediate layers of the multiple trained teacher machine learning models at the same level as the specific intermediate layer according to the corresponding second weight coefficients. Here, δ i,mrepresents the weight coefficients of the intermediate layers of different teacher machine learning models, satisfying the constraints and being zero. In other words, for multiple weight coefficients δ at the same level i i,m (m=1 to M), these weight coefficients corresponding to the same level i satisfy the constraint that the sum is zero. In a possible implementation, the second weight coefficient δ i,m This is achieved through softmax.

[0066] Please continue reading Figure 2 and formula (3), the second part of the loss function includes a distance loss determined based on the intermediate layer output features of the multi-bit teacher machine learning model and the intermediate layer output features generated by the specific intermediate layer of the student machine learning model after the point convolution layer conversion. The second part of the loss function is obtained by formula (4).

[0067]

[0068] in, represents the intermediate layer output features of the multi-bit teacher machine learning model obtained by formula (3); Represents the intermediate layer output features output by the intermediate layer with serial number i of the student machine learning model; r i Represents a conversion layer that performs a point convolutional layer conversion on the output of the intermediate layer with serial number i of the student machine learning model; N represents the number of selected intermediate layers. Formula (4) means that for the selected N intermediate layers, the intermediate layer output features of the multi-bit teacher machine learning model corresponding to each of the N intermediate layers are paired with the intermediate layer output features of the student machine learning model, and the distance loss is solved for each pairing respectively. Finally, the distance losses of the N intermediate layers are summed to obtain the second part of the loss function. It should be understood that the intermediate layers of the student machine learning model and the teacher machine learning model are not one-to-one corresponding channels, and even the features output by the intermediate layers of the same layer do not necessarily have a corresponding relationship. Therefore, it is necessary to perform a point convolutional layer conversion on the output of the intermediate layer of the student machine learning model. The range of N is any positive integer greater than or equal to 1, but the maximum value of N is the total number of intermediate layers included in the teacher machine learning model and the student machine learning model. In other words, the features of all the intermediate layer outputs can be taken into account, or only the features of a part of the intermediate layer outputs can be selected, or only the features of a specific intermediate layer output can be selected. Figure 2Taking the multiple teacher machine learning models 220, 240 and 260 shown as examples, the features of all the intermediate layer outputs can be considered (N is 3), or only the output features of the first intermediate layer (N is 1), that is, the features of the intermediate layers 222, 242 and 262. Accordingly, according to the output features of the intermediate layer of the selected teacher machine learning model, the output features of the intermediate layer of the student machine learning model are converted by the point convolution layer to obtain the corresponding distance loss. The smooth in formula (4) represents smoothing processing, which can be obtained by formula (5).

[0069]

[0070] Combining formulas (4) and (5), the smoothed distance loss and the second part of the loss function are conducive to making the training process smoother. The second part of the loss function also includes summing the distance losses corresponding to the multiple intermediate layers included in the student machine learning model after smoothing.

[0071] Please continue reading Figure 2 , the loss function also includes a third part, and the third part of the loss function includes a cross entropy loss determined based on the output result of the student machine learning model for the training data and the true label of the training data. Combining formulas (1) to (5), the loss function is expressed as formula (6).

[0072]

[0073] Among them, L in formula (6) CE is the third part of the loss function, i.e., the cross entropy loss determined based on the output of the student machine learning model for the training data and the true label of the training data; L KL is the first part of the loss function, i.e., the KL divergence determined based on the classification layer output result of the multi-bit teacher machine learning model and the output result of the student machine learning model for the training data mentioned in formula (2); L Dis The second part of the loss function, that is, the distance loss mentioned in formula (4), is determined based on the intermediate layer output features of the multi-bit teacher machine learning model and the intermediate layer output features generated by the specific intermediate layer of the student machine learning model after point convolution layer conversion.

[0074] Please continue reading Figure 2And formula (6), the knowledge distillation system 200 can achieve dynamic adjustment. Specifically, the first weight coefficient is derived through the loss function to obtain a first gradient; wherein the first gradient is the gradient of the loss function with respect to the classification layer output result of the multi-bit teacher machine learning model, and the first gradient is determined according to the KL divergence included in the first part of the loss function. On the other hand, the second weight coefficient is derived through the loss function to obtain a second gradient; wherein the second gradient is the gradient of the loss function with respect to the intermediate layer output feature of the multi-bit teacher machine learning model, and the second gradient is determined according to the distance loss included in the second part of the loss function. The first gradient and the second gradient are back-propagated respectively, so as to dynamically adjust the first weight coefficient and the second weight coefficient respectively. The dynamic adjustment process is represented by formula (7).

[0075]

[0076]

[0077] In formula (7), δ 0,m represents the first weight coefficient corresponding to the teacher machine learning model with sequence number m in the first weight coefficient set mentioned in formula (1); δ i,m represents the second weight coefficient corresponding to the middle layer numbered i in the teacher machine learning model numbered m mentioned in formula (3), and L all It represents the overall loss function mentioned in formula (6). From formula (7), it can be seen that the overall loss function L all The first weight coefficient δ 0,m and the second weight coefficient δ i,mDerivation is performed to obtain a first gradient and a second gradient. The first gradient is expressed as being related to the KL divergence of the first part of the loss function mentioned in formula (2), and the second gradient is expressed as being related to the distance loss of the second part of the loss function mentioned in formula (4). Moreover, the solution of the first gradient does not require the use of the second part of the loss function, while the solution of the second gradient does not require the use of the first part of the loss function. Therefore, in combination with formulas (1) to (7), the overall loss function includes three parts, each of which has its own function and together improves the effect of knowledge distillation. At the same time, back propagation and gradients are obtained through their respective derivations, and the derivation results and gradients do not involve other parts of the loss function, which is conducive to achieving self-dynamic adjustment only according to the corresponding part of the loss function, thereby simplifying operations and improving system efficiency. In other words, the derivation results and back propagation obtained by formula (7) can each dynamically adjust the corresponding weight coefficients, thereby facilitating the adjustment of the parameters of the student machine learning model through the loss function, so that the output result of the student machine learning model for the training data matches the output result of the trained teacher machine learning model.

[0078] In this way, combined with knowledge distillation technology, multiple pre-trained high-bitwidth teacher machine learning models are used to jointly guide the training of low-bitwidth, such as binary, student machine models, thereby improving the accuracy of the student machine learning model. In addition, during the training process, the importance of different teacher networks and different layers to the distillation of the student network varies, so each teacher network is given a learnable weight coefficient, thereby achieving dynamic adjustment of the weights of different teacher networks.

[0079] Combined with formula (1) to formula (7), when the student machine learning model is a binary neural network model and is used for image classification tasks, the embodiment of the present application achieves significant technical effects. Specifically, experiments were conducted on CIFAR10 and CIFAR100 image classification tasks. Compared with the binary neural network in the prior art, the neural network model obtained by the knowledge distillation method of the embodiment of the present application has higher accuracy under the same amount of calculation, as shown in Table 1.

[0080]

[0081] Table 1 Comparison of classification results between CIFAR10 and CIFAR100

[0082] In addition, experiments were conducted on the large-scale image classification dataset ImageNet. Compared with other binary neural networks, the neural network proposed in the present invention has higher accuracy under the same computational workload, as shown in Tables 2 and 3.

[0083]

[0084] On the left is the comparison of ImageNet classification results in Table 2, and on the right is the comparison of single-bit and multi-bit distillation classification results in Table 3

[0085] In addition, the effectiveness of the present invention is verified by ablation experiments, as shown in Table 4 below. Among them, FULL means using all methods of the present invention, w / o AKA means not using dynamic knowledge adjustment, w / o CTL means not using 1x1 conversion convolution layer, w / o Intermediate Layers means not using intermediate layer feature distillation, and w / o Classification Layer means not using classification layer output distillation.

[0086]

[0087] Table 4 Ablation experiment results

[0088] See also Figure 3 , Figure 3 A schematic diagram of a knowledge distillation method according to an embodiment of the present application is shown. Figure 3 As shown, the method includes the following steps.

[0089] Step S300: Based on the training data, train at least one teacher machine learning model to obtain a trained teacher machine learning model.

[0090] Among them, the at least one teacher machine learning model is a model obtained by training with the same training data. In a possible implementation, the at least one teacher machine learning model has a model with the same structure, or the model has the same depth, or the number of hidden layers is the same, or the number of channels is the same.

[0091] Step S310: Input the training data into the trained teacher machine learning model to obtain the output result of the trained teacher machine learning model.

[0092] Among them, the intermediate layer included in the trained teacher machine learning model generates corresponding intermediate layer output features in the process of generating the output results of the trained teacher machine learning model.

[0093] Step S320: Adjust the parameters of the student machine learning model according to the loss function so that the output result of the student machine learning model for the training data matches the output result of the trained teacher machine learning model.

[0094] Among them, the loss function includes a first part and a second part. The first part of the loss function is determined according to the output result of the trained teacher machine learning model, and the second part of the loss function is determined according to the intermediate layer output characteristics generated by the intermediate layer included in the trained teacher machine learning model.

[0095] See also Figure 4 , Figure 4 FIG. 2 is a flow chart showing another embodiment of the knowledge distillation method provided in the present application. Figure 4 As shown, the method includes the following steps.

[0096] Step S400: According to the training data, train multiple teacher machine learning models separately to obtain corresponding multiple trained teacher machine learning models.

[0097] The number of intermediate layers included in each of the multiple teacher machine learning models is the same as the number of intermediate layers included in the student machine learning model. The bit width used for the weights and activation values ​​of each of the multiple teacher machine learning models is greater than the bit width used for the weights and activation values ​​of the student machine learning model.

[0098] Step S410: Input the training data into the multiple trained teacher machine learning models respectively to obtain the output results of the multiple trained teacher machine learning models corresponding to each other.

[0099] Among them, for each of the multiple trained teacher machine learning models: the multiple intermediate layers included in the specific trained teacher machine learning model each generate corresponding intermediate layer output features in the process of the specific trained teacher machine learning model generating the output result of the specific trained teacher machine learning model.

[0100] Step S420: Adjust the parameters of the student machine learning model according to the loss function so that the output result of the student machine learning model for the training data matches the output result of the trained teacher machine learning model.

[0101] Among them, the multiple trained teacher machine learning models correspond one-to-one to the multiple first weight coefficients in the first weight coefficient set, and the output results of the multiple trained teacher machine learning models are weighted and summed according to their respective corresponding first weight coefficients to obtain the classification layer output results of the multi-bit teacher machine learning model, and the first part of the loss function includes the Kullback-Leibler (KL) divergence determined based on the classification layer output results of the multi-bit teacher machine learning model and the output results of the student machine learning model for the training data.

[0102] Wherein, the multiple intermediate layers included in each of the multiple trained teacher machine learning models correspond one-to-one to the multiple second weight coefficients in the second weight coefficient set. Wherein, for one or more of the multiple intermediate layers included in the student machine learning model: determine the intermediate layer output features of the multi-bit teacher machine learning model corresponding to the specific intermediate layer of the student machine learning model, wherein the intermediate layer output features of the multi-bit teacher machine learning model are obtained by weighted summing the intermediate layer output features generated by the intermediate layers of the multiple trained teacher machine learning models at the same level as the specific intermediate layer according to the respective corresponding second weight coefficients; the second part of the loss function includes the distance loss determined based on the intermediate layer output features of the multi-bit teacher machine learning model and the intermediate layer output features generated by the specific intermediate layer of the student machine learning model after conversion by the point convolution layer.

[0103] Among them, the second part of the loss function also includes smoothing the distance losses corresponding to each of the multiple intermediate layers included in the student machine learning model and then summing them up.

[0104] Step S430: The first weight coefficient is differentiated by the loss function to obtain a first gradient; the second weight coefficient is differentiated by the loss function to obtain a second gradient; and the first gradient and the second gradient are back-propagated respectively to dynamically adjust the first weight coefficient and the second weight coefficient respectively.

[0105] Among them, the first gradient is the gradient of the loss function with respect to the classification layer output result of the multi-bit teacher machine learning model, and the first gradient is determined according to the KL divergence included in the first part of the loss function; the second gradient is the gradient of the loss function with respect to the intermediate layer output feature of the multi-bit teacher machine learning model, and the second gradient is determined according to the distance loss included in the second part of the loss function.

[0106] See also Figures 1 to 4 In some exemplary embodiments, the teacher machine learning model and the student machine learning model may refer to a fully connected neural network, and the corresponding intermediate layer output refers to the output of the fully connected layer; or the teacher machine learning model and the student machine learning model refer to a convolutional neural network, and the corresponding intermediate layer output refers to the output of the convolutional layer; or the teacher machine learning model and the student machine learning model are recurrent neural networks (RNN); or the teacher machine learning model and the student machine learning model are other models with the same structure, as long as they are applicable to the knowledge distillation method and system described in the embodiments of the present application. These can be adjusted according to the specific application scenario and are not specifically limited here.

[0107] The specific embodiments provided by the present application can be implemented with any one or combination of hardware, software, firmware or solid-state logic circuits, and can be implemented in combination with signal processing, control and / or special circuits. The equipment or device provided by the specific embodiments of the present application may include one or more processors (e.g., microprocessors, controllers, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field programmable gate arrays (FPGAs), etc.), which process various computer-executable instructions to control the operation of the equipment or device. The equipment or device provided by the specific embodiments of the present application may include a system bus or a data transmission system that couples various components together. The system bus may include any one or a combination of different bus structures, such as a memory bus or a memory controller, a peripheral bus, a universal serial bus and / or a processor or local bus utilizing any one of a variety of bus architectures. The equipment or device provided by the specific embodiments of the present application may be provided separately, may be a part of a system, or may be a part of other equipment or devices.

[0108] The specific embodiments provided in this application may include a computer-readable storage medium or be combined with a computer-readable storage medium, such as one or more storage devices capable of providing non-temporary data storage. The computer-readable storage medium / storage device may be configured to store data, programmers and / or instructions, which, when executed by a processor of a device or apparatus provided in a specific embodiment of this application, enable these devices or apparatuses to perform related operations. The computer-readable storage medium / storage device may include one or more of the following features: volatility, non-volatility, dynamic, static, readable / writable, read-only, random access, sequential access, location addressability, file addressability, and content addressability. In one or more exemplary embodiments, the computer-readable storage medium / storage device may be integrated into the device or apparatus provided in a specific embodiment of this application or belong to a common system. Computer-readable storage media / storage devices may include optical storage devices, semiconductor storage devices and / or magnetic storage devices, etc., and may also include random access memory (RAM), flash memory, read-only memory (ROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), registers, hard disks, removable disks, recordable and / or rewritable compact disks (CDs), digital versatile disks (DVDs), mass storage media devices or any other form of suitable storage media.

[0109] The above is the implementation method of the embodiment of the present application. It should be noted that the steps in the method described in the specific embodiment of the present application can be adjusted in order, merged and deleted according to actual needs. In the above embodiments, the description of each embodiment has its own emphasis. For the part that is not described in detail in a certain embodiment, refer to the relevant description of other embodiments. It is understandable that the structure shown in the embodiment of the present application and the accompanying drawings does not constitute a specific limitation on the relevant device or system. In other embodiments of the present application, the relevant device or system may include more or fewer components than the specific embodiments and the accompanying drawings, or combine certain components, or split certain components, or have different component arrangements. Those skilled in the art will understand that, without departing from the spirit and scope of the specific embodiments of the present application, various modifications or changes can be made to the arrangement, operation and details of the methods and equipment recorded in the specific embodiments; without departing from the principles of the embodiments of the present application, several improvements and modifications can also be made, and these improvements and modifications are also regarded as the scope of protection of the present application.

Claims

1. A method for training a neural network by knowledge distillation, characterized in that: The method comprises: According to the training data, training at least one teacher machine learning model to obtain a trained teacher machine learning model; wherein the training data is any one of image data, text data and voice data; Inputting the training data into the trained teacher machine learning model to obtain an output result of the trained teacher machine learning model, wherein the intermediate layer included in the trained teacher machine learning model generates corresponding intermediate layer output features in the process of generating the output result of the trained teacher machine learning model; and The parameters of the student machine learning model are adjusted according to the loss function so that the difference between the output result of the student machine learning model for the training data and the output result of the trained teacher machine learning model is less than a preset threshold, wherein the loss function includes a first part and a second part, the first part of the loss function is determined according to the output result of the trained teacher machine learning model, and the second part of the loss function is determined according to the intermediate layer output features generated by the intermediate layer included in the trained teacher machine learning model.

2. The method according to claim 1, characterized in that The bit width used by the weights and activation values ​​of the at least one teacher machine learning model is greater than the bit width used by the weights and activation values ​​of the student machine learning model.

3. The method according to claim 1, characterized in that The first part of the loss function includes a Kullback-Leibler (KL) divergence determined based on the output of the trained teacher machine learning model and the output of the student machine learning model for the training data.

4. The method according to claim 3, characterized in that The number of intermediate layers included in the student machine learning model is the same as the number of intermediate layers included in the at least one teacher machine learning model. The intermediate layers included in the student machine learning model generate corresponding intermediate layer output features in the process of generating the output results of the student machine learning model. The second part of the loss function includes the distance loss determined based on the intermediate layer output features generated by the intermediate layers included in the trained teacher machine learning model and the intermediate layer output features generated by the intermediate layers included in the student machine learning model after conversion by the point convolution layer.

5. The method according to claim 4, characterized in that The loss function also includes a third part, which includes a cross-entropy loss determined based on the output results of the student machine learning model for the training data and the true labels of the training data.

6. The method according to claim 1, characterized in that The at least one teacher machine learning model includes a plurality of teacher machine learning models, wherein the number of intermediate layers included in each of the plurality of teacher machine learning models is the same as the number of intermediate layers included in the student machine learning model, wherein, according to the training data, training at least one teacher machine learning model to obtain a trained teacher machine learning model includes: According to the training data, the multiple teacher machine learning models are trained respectively to obtain a corresponding multiple trained teacher machine learning models.

7. The method according to claim 6, characterized in that The bit width used for the weights and activation values ​​of each of the multiple teacher machine learning models is greater than the bit width used for the weights and activation values ​​of the student machine learning model.

8. The method according to claim 7, characterized in that Inputting the training data into the trained teacher machine learning model to obtain the output result of the trained teacher machine learning model includes: The training data are respectively input into the multiple trained teacher machine learning models to obtain the output results of the multiple trained teacher machine learning models corresponding to each other, Wherein, for each of the multiple trained teacher machine learning models: The multiple intermediate layers included in the specific trained teacher machine learning model each generate corresponding intermediate layer output features in the process of the specific trained teacher machine learning model generating the output results of the specific trained teacher machine learning model.

9. The method according to claim 8, characterized in that The multiple trained teacher machine learning models correspond one-to-one to the multiple first weight coefficients in the first weight coefficient set, and the output results of the multiple trained teacher machine learning models are weighted and summed according to the corresponding first weight coefficients to obtain the classification layer output result of the multi-bit teacher machine learning model. The first part of the loss function includes the Kullback-Leibler (KL) divergence determined based on the classification layer output result of the multi-bit teacher machine learning model and the output result of the student machine learning model for the training data.

10. The method according to claim 9, characterized in that The plurality of intermediate layers included in each of the plurality of trained teacher machine learning models correspond one-to-one to the plurality of second weight coefficients in the second weight coefficient set, Among them, for one or more of the multiple intermediate layers included in the student machine learning model: Determine an intermediate layer output feature of a multi-bit teacher machine learning model corresponding to a specific intermediate layer of the student machine learning model, wherein the intermediate layer output feature of the multi-bit teacher machine learning model is obtained by weighted summing the intermediate layer output features generated by the intermediate layers of the plurality of trained teacher machine learning models at the same level as the specific intermediate layer according to the respective corresponding second weight coefficients; The second part of the loss function includes a distance loss determined based on the intermediate layer output features of the multi-bit teacher machine learning model and the intermediate layer output features generated by a specific intermediate layer of the student machine learning model after conversion by a point convolution layer.

11. The method according to claim 10, characterized in that The second part of the loss function also includes smoothing the distance losses corresponding to each of the multiple intermediate layers included in the student machine learning model and then summing them up.

12. The method according to claim 11, characterized in that The loss function also includes a third part, which includes a cross-entropy loss determined based on the output results of the student machine learning model for the training data and the true labels of the training data.

13. The method according to claim 12, characterized in that The method further comprises: The first weight coefficient is derived by the loss function to obtain a first gradient, wherein the first gradient is the gradient of the loss function with respect to the classification layer output result of the multi-bit teacher machine learning model, and the first gradient is determined according to the KL divergence included in the first part of the loss function; The second weight coefficient is derived by the loss function to obtain a second gradient, wherein the second gradient is the gradient of the loss function with respect to the intermediate layer output feature of the multi-bit teacher machine learning model, and the second gradient is determined according to the distance loss included in the second part of the loss function; The first gradient and the second gradient are back-propagated respectively, so as to dynamically adjust the first weight coefficient and the second weight coefficient respectively.

14. The method according to any one of claims 1 to 13, characterized in that: The weights and activation values ​​of the student machine learning model are binarized.

15. A knowledge distillation system, characterized in that: The knowledge distillation system comprises: Multiple teacher machine learning models, and Student machine learning models; The number of intermediate layers included in each of the plurality of teacher machine learning models is the same as the number of intermediate layers included in the student machine learning model; The bit widths used for the weights and activation values ​​of each of the multiple teacher machine learning models are greater than the bit widths used for the weights and activation values ​​of the student machine learning model; The parameters of the student machine learning model are adjusted according to the loss function so that the difference between the output results of the student machine learning model for the training data and the output results of the multiple teacher machine learning models for the training data is less than a preset threshold; wherein the training data is any one of image data, text data and voice data; The first part of the loss function includes a Kullback-Leibler (KL) divergence determined based on a classification layer output result of a multi-bit teacher machine learning model and an output result of the student machine learning model for the training data, and the classification layer output result of the multi-bit teacher machine learning model is obtained by weighted summing the output results of the multiple teacher machine learning models for the training data according to their respective corresponding first weight coefficients; The second part of the loss function includes a distance loss determined based on an intermediate layer output feature of a multi-bit teacher machine learning model and an intermediate layer output feature generated by a specific intermediate layer of the student machine learning model after point convolution layer conversion, wherein the intermediate layer output feature of the multi-bit teacher machine learning model is obtained by weighted summing the intermediate layer output features generated by the intermediate layers of the multiple teacher machine learning models at the same level as the specific intermediate layer according to their respective corresponding second weight coefficients; Among them, the third part of the loss function includes a cross entropy loss determined based on the output results of the student machine learning model for the training data and the true labels of the training data.

16. The system according to claim 15, characterized in that A first gradient is obtained by derivatizing the first weight coefficient by the loss function, wherein the first gradient is the gradient of the loss function with respect to the classification layer output result of the multi-bit teacher machine learning model, and the first gradient is determined according to the KL divergence included in the first part of the loss function, The second gradient is obtained by derivatizing the second weight coefficient by the loss function, wherein the second gradient is the gradient of the loss function with respect to the intermediate layer output feature of the multi-bit teacher machine learning model, and the second gradient is determined according to the distance loss included in the second part of the loss function, The first weight coefficient and the second weight coefficient are dynamically adjusted respectively by back-propagating the first gradient and the second gradient.

17. A computer-readable storage medium storing computer instructions, characterized in that: When the computer instructions are executed by a processor, the processor performs the following operations: According to the training data, training at least one teacher machine learning model to obtain a trained teacher machine learning model; wherein the training data is any one of image data, text data and voice data; Inputting the training data into the trained teacher machine learning model to obtain an output result of the trained teacher machine learning model, wherein the intermediate layer included in the trained teacher machine learning model generates corresponding intermediate layer output features in the process of generating the output result of the trained teacher machine learning model; and The parameters of the student machine learning model are adjusted according to the loss function so that the difference between the output result of the student machine learning model for the training data and the output result of the trained teacher machine learning model is less than a preset threshold, wherein the loss function includes a first part and a second part, the first part of the loss function is determined according to the output result of the trained teacher machine learning model, and the second part of the loss function is determined according to the intermediate layer output features generated by the intermediate layer included in the trained teacher machine learning model.

18. The computer-readable storage medium according to claim 17, wherein: The bit width used by the weights and activation values ​​of the at least one teacher machine learning model is greater than the bit width used by the weights and activation values ​​of the student machine learning model.

19. The computer-readable storage medium according to claim 17, wherein: The first part of the loss function includes a Kullback-Leibler (KL) divergence determined based on the output of the trained teacher machine learning model and the output of the student machine learning model for the training data.

20. The computer-readable storage medium of claim 19, wherein: The number of intermediate layers included in the student machine learning model is the same as the number of intermediate layers included in the at least one teacher machine learning model. The intermediate layers included in the student machine learning model generate corresponding intermediate layer output features in the process of generating the output results of the student machine learning model. The second part of the loss function includes the distance loss determined based on the intermediate layer output features generated by the intermediate layers included in the trained teacher machine learning model and the intermediate layer output features generated by the intermediate layers included in the student machine learning model after conversion by the point convolution layer.

21. The computer-readable storage medium according to claim 20, wherein: The loss function also includes a third part, which includes a cross-entropy loss determined based on the output results of the student machine learning model for the training data and the true labels of the training data.

22. The computer-readable storage medium of claim 17, wherein: The at least one teacher machine learning model includes a plurality of teacher machine learning models, wherein the number of intermediate layers included in each of the plurality of teacher machine learning models is the same as the number of intermediate layers included in the student machine learning model, wherein, according to the training data, training at least one teacher machine learning model to obtain a trained teacher machine learning model includes: According to the training data, the multiple teacher machine learning models are trained respectively to obtain a corresponding multiple trained teacher machine learning models.

23. The computer-readable storage medium according to claim 22, wherein: The bit width used for the weights and activation values ​​of each of the multiple teacher machine learning models is greater than the bit width used for the weights and activation values ​​of the student machine learning model.

24. The computer-readable storage medium according to claim 23, wherein: Inputting the training data into the trained teacher machine learning model to obtain the output result of the trained teacher machine learning model includes: The training data are respectively input into the multiple trained teacher machine learning models to obtain the output results of the multiple trained teacher machine learning models corresponding to each other, Wherein, for each of the multiple trained teacher machine learning models: The multiple intermediate layers included in the specific trained teacher machine learning model each generate corresponding intermediate layer output features in the process of the specific trained teacher machine learning model generating the output results of the specific trained teacher machine learning model.

25. The computer-readable storage medium of claim 24, wherein: The multiple trained teacher machine learning models correspond one-to-one to the multiple first weight coefficients in the first weight coefficient set, and the output results of the multiple trained teacher machine learning models are weighted and summed according to the corresponding first weight coefficients to obtain the classification layer output result of the multi-bit teacher machine learning model. The first part of the loss function includes the Kullback-Leibler (KL) divergence determined based on the classification layer output result of the multi-bit teacher machine learning model and the output result of the student machine learning model for the training data.

26. The computer-readable storage medium of claim 25, wherein: The plurality of intermediate layers included in each of the plurality of trained teacher machine learning models correspond one-to-one to the plurality of second weight coefficients in the second weight coefficient set, Among them, for one or more of the multiple intermediate layers included in the student machine learning model: Determine an intermediate layer output feature of a multi-bit teacher machine learning model corresponding to a specific intermediate layer of the student machine learning model, wherein the intermediate layer output feature of the multi-bit teacher machine learning model is obtained by weighted summing the intermediate layer output features generated by the intermediate layers of the plurality of trained teacher machine learning models at the same level as the specific intermediate layer according to the respective corresponding second weight coefficients; The second part of the loss function includes a distance loss determined based on the intermediate layer output features of the multi-bit teacher machine learning model and the intermediate layer output features generated by a specific intermediate layer of the student machine learning model after conversion by a point convolution layer.

27. The computer-readable storage medium of claim 26, wherein: The second part of the loss function also includes smoothing the distance losses corresponding to each of the multiple intermediate layers included in the student machine learning model and then summing them up.

28. The computer-readable storage medium of claim 27, wherein: The loss function also includes a third part, which includes a cross-entropy loss determined based on the output results of the student machine learning model for the training data and the true labels of the training data.

29. The computer-readable storage medium of claim 28, wherein: The processor also performs the following operations: The first weight coefficient is derived by the loss function to obtain a first gradient, wherein the first gradient is the gradient of the loss function with respect to the classification layer output result of the multi-bit teacher machine learning model, and the first gradient is determined according to the KL divergence included in the first part of the loss function; The second weight coefficient is derived by the loss function to obtain a second gradient, wherein the second gradient is the gradient of the loss function with respect to the intermediate layer output feature of the multi-bit teacher machine learning model, and the second gradient is determined according to the distance loss included in the second part of the loss function; The first gradient and the second gradient are back-propagated respectively, so as to dynamically adjust the first weight coefficient and the second weight coefficient respectively.

Citation Information

Cited By

  • Skill generation method and system based on reasoning chain rule induction and hybrid packaging

    CN122840204A