Neural network training method, target recognition method, device and electronic device

By decomposing the teacher network into multiple sub-networks and conducting distillation training in order of channel numbers, the problem of application obstacles of deep neural networks on devices with limited resources and the impact of the amount of knowledge on accuracy is solved, and the prediction performance and recognition accuracy of the student network are improved.

CN113792871BActive Publication Date: 2024-09-06BEIJING KUANGSHI TECHNOLOGY CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110893233.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-08-04
Publication Date
2024-09-06
Estimated Expiration
2041-08-04

AI Technical Summary

Technical Problem

Existing deep neural networks have application obstacles in practical applications due to excessive computing power and storage requirements, especially on devices such as smartphones, and existing knowledge distillation technology fails to effectively consider the impact of the amount of knowledge on the accuracy of distillation results.

Method used

By obtaining the pre-trained teacher network, the teacher network contains multiple sub-networks with the same number of layers but different numbers of channels. The initial student network is distilled and trained in order from the least to the most channel number. The training process is decomposed into multiple cycles, using a linear Or the cosine learning rate decay strategy gradually transfers knowledge to improve the prediction performance and recognition accuracy of the student network.

Benefits of technology

It effectively improves the training efficiency of the student network and the accuracy of the output results, narrows the performance gap between compact and efficient small models and large models, and is suitable for devices with limited resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113792871B
    Figure CN113792871B
Patent Text Reader

Abstract

The present invention provides a neural network training method, a target recognition method, a device and an electronic device, the neural network training method comprising: obtaining a pre-trained teacher network, the teacher network comprising a plurality of teacher sub-networks, the plurality of teacher sub-networks having the same number of layers and different number of channels; applying the teacher sub-networks in the teacher network in order of the number of channels from small to large, and sequentially performing distillation training on the initial student network to obtain a target student network. Through the neural network training method provided by the embodiment of the present invention, the training of the student network by the teacher network is divided into a plurality of training cycles, so that the student network can extract knowledge step by step, which can effectively improve the training efficiency of the student network, and further improve the prediction performance and recognition accuracy of the student network.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of machine learning, and in particular to a neural network training method, a target recognition method, a device and an electronic device. Background Art

[0002] In recent years, deep neural networks have made significant progress in artificial intelligence fields such as computer vision (such as the AlexNet model), natural language processing (such as the BERT model), and reinforcement learning (such as the DQN model). In order to achieve better prediction results for deep neural networks, existing technologies usually design deep neural networks to be deeper and have larger parameters, such as ResNet-1202 in computer vision and GBT-3 in NLP, which contain 175M parameters. In this case, although deep neural networks have achieved higher performance, they require greater computing power and model storage capabilities, which has caused great obstacles to the actual application of deep neural networks in real environments, especially in devices such as smartphones and microprocessors. In order to further promote deep neural networks, it is particularly important to design more compact and efficient deep neural networks and narrow the performance gap between compact and efficient small models and high-performance large models.

[0003] Knowledge distillation is a representative and effective method for improving compact and efficient small models in the current field of deep neural network research. Distillation technology has been widely used in computer vision, self-speech processing and other fields. This method is mainly inspired by the way teachers teach students in human society, that is, the small model (as a student) accepts the knowledge of the large model (as a teacher) to imitate the prediction performance of the large model. The existing mainstream distillation methods are: off-line distillation, on-line distillation and self-distillation. In order to further improve knowledge distillation technology, current research mainly pursues the improvement of knowledge quality from three aspects: knowledge type, distillation method and pairing relationship between teacher and student. Current knowledge distillation technology usually only focuses on the improvement of knowledge quality and distillation method on distillation network, but does not consider the impact of knowledge quantity on the accuracy of distillation results. Summary of the invention

[0004] In view of this, an object of the present invention is to provide a neural network training method, a target recognition method, a device and an electronic device to improve the prediction performance and recognition accuracy of the student network.

[0005] In a first aspect, an embodiment of the present invention provides a neural network training method, the method comprising: obtaining a pre-trained teacher network, the teacher network comprising multiple teacher sub-networks, the multiple teacher sub-networks having the same number of layers and different numbers of channels; applying the teacher sub-networks in the teacher network in order of the number of channels from small to large, and performing distillation training on the initial student network in turn to obtain a target student network.

[0006] Furthermore, in any two adjacent teacher sub-networks of the above teacher network, the teacher sub-network with more channels contains all network parameters of the teacher sub-network with fewer channels.

[0007] Furthermore, the above-mentioned step of applying the teacher sub-networks in the teacher network in order of the number of channels from small to large to perform distillation training on the initial student network in sequence to obtain the target student network includes: applying the teacher sub-networks in the teacher network in order of the number of channels from small to large to perform distillation training on the initial student network for a preset number of stages in sequence to obtain the target student network, wherein the preset number of stages is equal to the total number of teacher sub-networks.

[0008] Furthermore, the above-mentioned step of applying the teacher sub-networks in the teacher network in order of the number of channels from small to large to perform distillation training on the initial student network in turn to obtain the target student network includes: selecting the teacher sub-networks from the teacher network in order of the number of channels from small to large as the training network of the current stage, and for each training network, performing the following operations: applying the training network to perform distillation training on the initial student network to obtain the initial student network trained in the current stage; using the initial student network trained in the current stage as the initial student network for the next stage of training, and continuing training until the training corresponding to all teacher sub-networks is completed to obtain the target student network.

[0009] Furthermore, during the distillation training of the initial student network, the learning rate decay strategy of the student network remains unchanged as the linear decay strategy or the cosine decay strategy.

[0010] Furthermore, the above-mentioned step of obtaining a pre-trained teacher network includes: constructing a teacher network including multiple teacher sub-networks, wherein the multiple teacher sub-networks have the same number of layers and different numbers of channels; training the multiple teacher sub-networks according to sample data to obtain a teacher network, wherein the sample data contains corresponding labels.

[0011] Furthermore, the above-mentioned step of training multiple teacher sub-networks according to the sample data includes: training a maximum teacher sub-network according to the sample data, wherein the maximum teacher sub-network is the teacher sub-network with the largest number of channels in the teacher network; training multiple smaller teacher sub-networks according to the sample data and the maximum teacher sub-network, wherein the smaller teacher sub-networks are other teacher sub-networks in the teacher network except the largest teacher sub-network.

[0012] Furthermore, the above-mentioned step of training a smaller teacher sub-network based on the sample data and the maximum teacher sub-network includes: inputting the sample data into the maximum teacher sub-network to obtain a first feature; inputting the sample data into the smaller teacher sub-network to obtain a second feature output by the smaller teacher sub-network; and training the smaller teacher sub-network based on the label, the first feature and the second feature.

[0013] Furthermore, the above-mentioned step of training the smaller teacher sub-network according to the label, the first feature and the second feature includes: determining the label loss value according to the label and the second feature; calculating the KL divergence of the first feature and the second feature, and determining the KL divergence as the KL divergence loss value; determining the network loss value corresponding to the smaller teacher sub-network according to the label loss value and the KL divergence loss value; and training the smaller teacher sub-network using the network loss value corresponding to the smaller teacher sub-network.

[0014] In a second aspect, an embodiment of the present invention further provides a target recognition method, which is applied to an electronic device, wherein the electronic device pre-stores a target student network trained using the method of the first aspect, and the method comprises: obtaining data to be recognized; performing target recognition on the data to be recognized through the target student network to obtain a recognition result with a target object.

[0015] In a third aspect, an embodiment of the present invention also provides a neural network training device, which includes: a teacher network acquisition module, used to obtain a pre-trained teacher network, the teacher network includes multiple teacher sub-networks, the multiple teacher sub-networks have the same number of layers and different numbers of channels; a training module, used to apply the teacher sub-networks in the teacher network in order from small to large number of channels, and perform distillation training on the initial student network in turn to obtain a target student network.

[0016] In a fourth aspect, an embodiment of the present invention further provides a target recognition device, which pre-stores a target student network trained using the method of the first aspect above, and the device includes: a data acquisition module for acquiring data to be recognized; and a recognition module for performing target recognition on the data to be recognized through the target student network to obtain a recognition result with a target object.

[0017] In a fifth aspect, an embodiment of the present invention further provides an electronic device, comprising a processor and a memory, wherein the memory stores computer executable instructions that can be executed by the processor, and the processor executes the computer executable instructions to implement the neural network training method of the first aspect or the target recognition method of the second aspect.

[0018] In a sixth aspect, an embodiment of the present invention further provides a computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement the neural network training method of the first aspect or the target recognition method of the second aspect.

[0019] The neural network training method, target recognition method, device and electronic device provided by the embodiments of the present invention obtain a pre-trained teacher network, the teacher network includes multiple teacher sub-networks, the multiple teacher sub-networks have the same number of layers and different number of channels; in order of the number of channels from small to large, the teacher sub-networks in the teacher network are applied to perform distillation training on the initial student network in turn to obtain the target student network. Through the neural network training technology and target recognition technology provided by the embodiments of the present invention, the training of the student network by the teacher network is divided into multiple training cycles, so that the student network can extract knowledge step by step, which can effectively improve the training efficiency of the student network, and then improve the prediction performance and recognition accuracy of the student network.

[0020] Other features and advantages of the present disclosure will be set forth in the following description, or some features and advantages may be inferred or unambiguously determined from the description, or may be learned by implementing the above-mentioned technology of the present disclosure.

[0021] In order to make the above-mentioned objectives, features and advantages of the present disclosure more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0023] Figure 1 A schematic diagram of the structure of an electronic system provided by an embodiment of the present invention;

[0024] Figure 2 A flowchart of a neural network training method provided by an embodiment of the present invention;

[0025] Figure 3 A schematic diagram of a neural network training method provided by an embodiment of the present invention;

[0026] Figure 4 A flowchart of a teacher network training method provided by an embodiment of the present invention;

[0027] Figure 5 A flowchart of a teacher network training method in a practical application scenario provided by an embodiment of the present invention;

[0028] Figure 6 A flowchart of a student network training method in a practical application scenario provided by an embodiment of the present invention;

[0029] Figure 7 A schematic diagram of a flow chart of a target recognition method provided by an embodiment of the present invention;

[0030] Figure 8 A schematic diagram of a network training device provided by an embodiment of the present invention;

[0031] Fig. 9 A schematic diagram of a target recognition device provided by an embodiment of the present invention;

[0032] Fig.10 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0033] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0034] In recent years, research on computer vision, deep learning, machine learning, image processing, image recognition and other technologies based on artificial intelligence has made important progress. Artificial Intelligence (AI) is an emerging science and technology that studies and develops theories, methods, technologies and application systems for simulating and extending human intelligence. Artificial intelligence is a comprehensive discipline involving many types of technologies such as chips, big data, cloud computing, the Internet of Things, distributed storage, deep learning, machine learning, neural networks, etc. Computer vision, as an important branch of artificial intelligence, specifically allows machines to recognize the world. Computer vision technology usually includes face recognition, liveness detection, fingerprint recognition and anti-counterfeiting verification, biometric recognition, face detection, pedestrian detection, target detection, pedestrian recognition, image processing, image recognition, image semantic understanding, image retrieval, text recognition, video processing, video content recognition, behavior recognition, 3D reconstruction, virtual reality, augmented reality, simultaneous localization and mapping (SLAM), computational photography, robot navigation and positioning and other technologies. With the research and advancement of artificial intelligence technology, this technology has been applied in many fields, such as security, urban management, traffic management, building management, park management, facial access, facial attendance, logistics management, warehouse management, robots, intelligent marketing, computational photography, mobile phone imaging, cloud services, smart homes, wearable devices, unmanned driving, automatic driving, smart medical care, facial payment, facial unlocking, fingerprint unlocking, identity verification, smart screens, smart TVs, cameras, mobile Internet, live streaming, beauty, makeup, medical beauty, and smart temperature measurement.

[0035] Current neural network distillation methods usually only focus on the improvement of the knowledge quality and the distillation process on the distillation network, and do not consider the impact of the amount of knowledge on the accuracy of the distillation results. Based on this, the embodiments of the present invention provide a neural network training method, a target recognition method, a device and an electronic device, which can effectively improve the training efficiency of the student network in terms of the amount of knowledge, thereby improving the prediction performance and recognition accuracy of the student network.

[0036] Reference Figure 1 The electronic system 100 is a schematic diagram of the structure of the electronic system 100. The electronic system can be used to implement the network training method, device and target recognition method and device of the embodiment of the present invention.

[0037] like Figure 1 The electronic system 100 includes one or more processing devices 102, one or more storage devices 104, an input device 106, an output device 108, and one or more data acquisition devices 110. These components are interconnected via a bus system 112 and / or other forms of connection mechanisms (not shown). It should be noted that Figure 1The components and structure of the electronic system 100 shown are merely exemplary and non-limiting. The electronic system may also have other components and structures as required.

[0038] The processing device 102 can be a server, an intelligent terminal, or a device including a central processing unit (CPU) or other forms of processing units with data processing capabilities and / or instruction execution capabilities. It can process data of other components in the electronic system 100 and can also control other components in the electronic system 100 to perform the function of neural network training.

[0039] The storage device 104 may include one or more computer program products, and the computer program product may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. Volatile memory may include, for example, random access memory (RAM) and / or cache memory (cache), etc. Non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc. One or more computer program instructions may be stored on the computer-readable storage medium, and the processing device 102 may run the program instructions to implement the client functions and / or other desired functions in the embodiments of the present invention (implemented by the processing device) described below. Various applications and various data, such as various data used and / or generated by the application, may also be stored in the computer-readable storage medium.

[0040] The input device 106 may be a device used by a user to input instructions, and may include one or more of a keyboard, a mouse, a microphone, a touch screen, and the like.

[0041] The output device 108 may output various information (eg, images or sounds) to the outside (eg, a user), and may include one or more of a display, a speaker, and the like.

[0042] The data acquisition device 110 can acquire data to be processed and store the data in the storage device 104 for use by other components.

[0043] Exemplarily, the components used to implement the neural network training method, device, electronic device, and target recognition method, device, and electronic device according to the embodiments of the present invention can be integrated or dispersed, such as integrating the processing device 102, storage device 104, input device 106, and output device 108 into one, and setting the data acquisition device 110 at a designated location where data can be collected. When the components in the above electronic system are integrated, the electronic system can be implemented as an intelligent terminal such as a camera, a smart phone, a tablet computer, a computer, a vehicle-mounted terminal, etc.

[0044] Figure 2A flowchart of a neural network training method provided by an embodiment of the present invention, the method is applied to the above electronic device, see Figure 2 , the method comprises the following steps:

[0045] S202: Obtain a pre-trained teacher network, where the teacher network includes multiple teacher sub-networks, and the multiple teacher sub-networks have the same number of layers but different numbers of channels;

[0046] Before using the teacher network to train the student network, first obtain a pre-trained teacher network. The training of the teacher network can be completed on the same electronic device as the training of the student network, or it can be completed on different electronic devices. It is understandable that the teacher network can be a neural network used for image recognition or image detection in an actual application scenario, or it can be a neural network used for speech recognition. This application does not limit the purpose and application scenario of the teacher network. The above-mentioned teacher network for training includes multiple teacher sub-networks. Specifically, the original teacher network can be reconstructed into multiple teacher sub-networks, and these teacher sub-networks have the same number of layers and different numbers of channels. The training process of the teacher network will be described in detail later, so I will not repeat it here.

[0047] In order to ensure the accuracy of the output results of the trained student network, in some possible implementations, the parameters of the teacher sub-networks in the teacher network are shared, that is, in any two adjacent teacher sub-networks in the above-mentioned teacher network, the teacher sub-network with more channels contains all the network parameters of the teacher sub-network with fewer channels.

[0048] S204: In order of the number of channels from small to large, apply the teacher sub-networks in the teacher network to perform distillation training on the initial student network in sequence to obtain the target student network.

[0049] For multiple trained teacher sub-networks, the sub-network structures they contain represent knowledge of different amounts of knowledge, that is, the more channels they contain, the greater the amount of knowledge the teacher sub-network has. Similar to the process of teachers teaching students in nature, the embodiment of the present invention gradually transfers knowledge to the student network from less knowledge to more knowledge according to the amount of knowledge in the process of teacher network training student network. Specifically, in the order of the number of channels from small to large, the teacher sub-networks in the teacher network are applied to perform distillation training for a preset number of stages on the initial student network in sequence to obtain the target student network, where the preset number of stages is equal to the total number of teacher sub-networks. For example, the trained teacher network includes three teacher sub-networks, namely ResNet20×4, ResNet20×2 and ResNet20×1 teacher sub-networks, where ResNetM×N represents a neural network with M layers and N channels. For the convenience of description, the structure of the neural network is represented in the above form below. The initial student network is subjected to three stages of distillation training in order from small to large number of channels, that is, the initial student network is subjected to the first stage training, the second stage training and the third stage training using the teacher networks of ResNet20×1, ResNet20×2 and ResNet20×4 respectively.

[0050] The above-mentioned neural network training method provided by the embodiment of the present invention first obtains a pre-trained teacher network, wherein the teacher network includes multiple teacher sub-networks, wherein the multiple teacher sub-networks have the same number of layers and different number of channels, and the teacher sub-networks in the teacher network are applied in order of the number of channels from small to large, and the initial student network is sequentially distilled and trained to obtain a target student network. By decomposing the teacher network into multiple teacher sub-networks containing different amounts of knowledge, and decomposing the distillation process of the student network into multiple cycles according to the multiple teacher sub-networks, and learning a piece of knowledge in each cycle, the learning effect of the student network can be effectively improved, thereby improving the accuracy of the output results of the student network.

[0051] In some possible implementations, the step of applying the teacher sub-networks in the teacher network to perform distillation training on the initial student network in sequence according to the number of channels from small to large in S204 to obtain the target student network may specifically include:

[0052] (1) Select the teacher sub-network from the teacher network in order from the smallest to the largest number of channels as the training network for the current stage. For each training network, perform the following operations:

[0053] (2) Apply the training network to perform distillation training on the initial student network to obtain the initial student network that has been trained in the current stage;

[0054] (3) The initial student network trained in the current stage is used as the initial student network for the next stage of training, and training continues until the training corresponding to all teacher sub-networks is completed, and the target student network is obtained.

[0055] Figure 3 A schematic diagram of a neural network training method provided for an embodiment of the present invention, wherein the initial student network is trained in two stages respectively. The original teacher network has 2 layers and 4 channels. We decompose it into 2 sub-networks in the channel dimension, and the corresponding channel numbers are 2 (0.5×the amount of knowledge) and 4 (1×the amount of knowledge), respectively. The depths of the two teacher sub-networks obtained are the same as the original teacher network, both of which are 2. They are only scaled in the channel dimension of each layer. The larger of the two sub-networks is the original teacher network, and the smaller network is smaller than the teacher network in terms of the channel. The parameters of the large network and the small network are the same. First, the initial student network is trained using the small teacher sub-network to obtain an updated student network. Further, the updated student network is trained using the large teacher network to obtain the final target student network.

[0056] In order to enable each teacher sub-network to fully train the student network, the student network must converge to the local minimum in each training stage. Based on this, during the distillation training of the above initial student network, the learning rate decay strategy of the student network remains unchanged in each training stage. The learning rate decay strategy can be a linear decay strategy or a cosine decay strategy.

[0057] Figure 4 A flow chart of a teacher network training method provided by an embodiment of the present invention, the method comprising the following steps:

[0058] S402: constructing a teacher network including multiple teacher sub-networks, wherein the multiple teacher sub-networks have the same number of layers but different numbers of channels;

[0059] S404: Train multiple teacher sub-networks according to sample data to obtain a teacher network, wherein the sample data includes corresponding labels.

[0060] It can be understood that the above sample data is labeled sample data, and the above teacher network contains the teacher sub-network with the same number of channels as the original teacher network, that is, the teacher sub-network with the largest number of channels, and also includes other teacher sub-networks with smaller numbers of channels than the original teacher network. The teacher sub-network with the largest number of channels may be called the largest teacher sub-network, and other teacher sub-networks with smaller numbers of channels may be called smaller teacher sub-networks. Based on this, the above process of training multiple teacher sub-networks using sample data can specifically include: training the largest teacher sub-network according to the sample data; training multiple smaller teacher sub-networks according to the sample data and the largest teacher sub-network.

[0061] In some possible implementations, multiple smaller teacher sub-networks may be trained as follows:

[0062] (1) Input the sample data into the maximum teacher-student network to obtain the first feature;

[0063] (2) Input the sample data into the smaller teacher sub-network to obtain the second feature output by the smaller teacher sub-network;

[0064] (3) Train the smaller teacher sub-network based on the label, the first feature, and the second feature.

[0065] It should be noted that, for the maximum teacher self-network, only sample data need to be used for training. The specific training method can adopt a common neural network training method, which is not limited in the embodiment of the present invention.

[0066] In the training process of the smaller teacher sub-network, in addition to considering the sample data, it is also necessary to consider the output features of the largest teacher sub-network. Based on this, after obtaining the first feature and the second feature, the training of the smaller teacher sub-network can be achieved through the following steps:

[0067] (1) Determine the label loss value based on the label and the second feature;

[0068] (2) calculating the KL divergence between the first feature and the second feature, and determining the KL divergence as a KL divergence loss value;

[0069] KL divergence is a relative entropy that can characterize the distance between two random distributions. When the two random distributions are the same, their relative entropy is zero. When the difference between the two random distributions increases, their relative entropy will also increase. The KL divergence can be calculated using the following formula:

[0070]

[0071] Among them, P represents the first characteristic and Q represents the second characteristic.

[0072] (3) According to the label loss value and the KL divergence loss value, determine the network loss value corresponding to the smaller teacher sub-network;

[0073] In this step, the label loss value and the KL divergence loss value may be combined, and the combined loss value may be used as the network loss value of the smaller self-network. Specifically, the label loss value and the KL divergence loss value may be weighted and summed 1:1, or other mathematical operations may be used to combine them.

[0074] (4) Using the network loss value corresponding to the smaller teacher sub-network, the smaller teacher sub-network is trained.

[0075] It can be understood that the above process only illustrates the case where the teacher network contains a smaller teacher sub-network. When the teacher network contains more than one smaller teacher sub-network, the above training process can be performed on multiple smaller teacher sub-networks at the same time, or the smaller teacher sub-networks can be trained in sequence using sample data and the largest teacher sub-network in a preset order. The embodiment of the present invention does not limit the training order of multiple smaller teacher sub-networks.

[0076] After obtaining the gradients of each teacher sub-network, the teacher network is repeatedly updated with the gradients of each teacher sub-network until the preset proficiency condition is met and the training is stopped.

[0077] It should be noted that the neural network training method provided in the embodiment of the present invention takes into account the influence of the amount of knowledge on the accuracy of the output results of the student network. This method can be used alone to train a neural network, or it can be generally combined with other distillation methods to improve the output accuracy of the student network trained by existing distillation technology.

[0078] For ease of understanding, the following describes in detail how to train the teacher network in combination with actual application scenarios. Figure 5 The above is a flow chart of a teacher network training method in an actual application scenario provided by an embodiment of the present invention. The teacher network in the method is an image recognition neural network. Through the neural network, target recognition can be performed on the image to be recognized to obtain an image with a target frame. The method includes:

[0079] S502: Split the original teacher network into four teacher sub-networks in the channel dimension.

[0080] In this step, the original teacher network is ResNet20×4, which is split into 4 teacher sub-networks with different numbers of channels in the channel dimension, namely ResNet20×1, ResNet20×2, ResNet20×3 and ResNet20×4. It should be noted that the splitting of the original teacher network in the embodiment of the present invention is performed under the mechanism of parameter sharing, that is, ResNet20×2 contains all the parameters of the ResNet20×1 network, ResNet20×3 contains all the parameters of the ResNet20×2 network, and ResNet20×4 contains all the parameters of the ResNet20×3 network.

[0081] S504: Input the sample image into the four teacher sub-networks to obtain the features corresponding to each teacher sub-network;

[0082] That is, the first feature corresponding to the ResNet20×4 teacher sub-network, the second feature corresponding to the ResNet20×3 teacher sub-network, the third feature corresponding to the ResNet20×2 teacher sub-network, and the fourth feature corresponding to the ResNet20×1 teacher sub-network are obtained.

[0083] S506: directly use the labels contained in the sample images to train the ResNet20×4 teacher sub-network.

[0084] S508: Determine the network loss value corresponding to the ResNet20×3 teacher sub-network.

[0085] The network loss value corresponding to the ResNet20×3 teacher sub-network is determined by the label loss value and the KL divergence loss value. The label loss value is determined by inputting the sample image into the ResNet20×3 teacher sub-network and using the label and the second eigenvalue, which is represented by Label1.

[0086] The above KL divergence loss value is the KL divergence of the first feature output by the ResNet20×4 teacher subnetwork and the second feature output by the ResNet20×3 teacher subnetwork, denoted by KL1.

[0087] The network loss value corresponding to the ResNet20×3 teacher sub-network is Loss1=Label1+KL1.

[0088] S510: Determine the network loss value corresponding to the ResNet20×2 teacher sub-network.

[0089] The network loss value corresponding to the ResNet20×2 teacher sub-network is also determined by the label loss value and the KL divergence loss value. The specific determination method is the same as the step in S608 above, which will not be repeated here.

[0090] S512: Determine the network loss value corresponding to the ResNet20×1 teacher sub-network.

[0091] The network loss value corresponding to the ResNet20×1 teacher sub-network is also determined by the label loss value and the KL divergence loss value. The specific determination method is the same as the step in S608 above, which will not be repeated here.

[0092] S514: According to the gradients of the ResNet20×4 teacher sub-network, the ResNet20×3 teacher sub-network, the ResNet20×2 teacher sub-network, and the ResNet20×1 teacher sub-network, each teacher sub-network is trained to obtain a teacher network.

[0093] According to the network loss values ​​corresponding to each teacher sub-network obtained above, the gradient of each teacher sub-network is determined, and each gradient is added to obtain the cumulative gradient. The cumulative gradient is used to update the parameters of each teacher sub-network until the preset network convergence condition is met.

[0094] Figure 6 A neural network training method is provided for an embodiment of the present invention. In this embodiment, the target task is to perform object recognition on an image. Therefore, the sample data of the student network is an image to be recognized containing a target object, and the output is a coordinate frame of the target object. In this method, the teacher network trained by the above method is used to perform distillation training on the student network of ResNet20 on the classification data set CIFAR-100. The method includes the following steps:

[0095] S602: Construct an initial student network whose size is ResNet20.

[0096] S604: In the first training stage, the initial student network is trained using the ResNet20×1 teacher sub-network. When the initial student network converges, the student network RN1 corresponding to the first training stage is obtained.

[0097] In this training phase, a linear attenuation strategy is used to train the initial student network.

[0098] S606: In the second training stage, the student network RN1 is trained using the ResNet20×2 teacher sub-network. When the student network RN1 converges, the student network RN2 corresponding to the second training stage is obtained.

[0099] In this training phase, the student network RN1 is trained using the same linear attenuation strategy as in the first training phase.

[0100] S608: In the third training stage, the student network RN2 is trained using the ResNet20×3 teacher sub-network. When the student network RN2 converges, the student network RN3 corresponding to the third training stage is obtained.

[0101] In this training phase, the student network RN2 is trained using the same linear attenuation strategy as in the first training phase.

[0102] S610: In the fourth training stage, the student network RN3 is trained using the ResNet20×4 teacher sub-network. When the student network RN3 converges, a student network RN4 corresponding to the fourth training stage is obtained.

[0103] In this training phase, the student network RN3 is trained using the same linear attenuation strategy as in the first training phase.

[0104] S612: Determine the student network RN4 as the target student network.

[0105] Figure 7 A flow chart of a target recognition method provided by an embodiment of the present invention is provided. The target recognition method is applied to an electronic device. A trained student network is pre-stored on the electronic device. The student network can be trained using the neural network training method provided by any embodiment of the present application. Figure 7 As shown, the method includes:

[0106] S702: Obtaining data to be identified:

[0107] S704: Perform target recognition on the data to be recognized through the target student network to obtain a recognition result with the target object.

[0108] In actual application scenarios, the data to be identified may be images to be identified, or video data to be identified, etc. The target recognition method provided in the embodiment of the present invention may be used to process target recognition tasks, such as identifying specific objects in an image, identifying different objects in a voice file, or identifying specified objects from a video frame sequence, etc.

[0109] Based on the above method embodiment, the present invention also provides a neural network training device, see Figure 8 As shown, the device comprises:

[0110] The teacher network acquisition module 802 is used to acquire a pre-trained teacher network, where the teacher network includes multiple teacher sub-networks, where the multiple teacher sub-networks have the same number of layers but different numbers of channels;

[0111] The training module 804 is used to apply the teacher sub-networks in the teacher network in the order of the number of channels from small to large, and perform distillation training on the initial student network in sequence to obtain the target student network.

[0112] The neural network training device provided by the embodiment of the present invention obtains a pre-trained teacher network, the teacher network includes multiple teacher sub-networks, the multiple teacher sub-networks have the same number of layers and different number of channels; in the order of the number of channels from small to large, the teacher sub-networks in the teacher network are applied to perform distillation training on the initial student network in turn to obtain the target student network. Through the neural network training technology provided by the embodiment of the present invention, the training of the student network by the teacher network is divided into multiple training cycles, so that the student network can extract knowledge step by step, which can effectively improve the training efficiency of the student network, and then improve the prediction performance and recognition accuracy of the student network.

[0113] In any two adjacent teacher sub-networks of the above teacher network, the teacher sub-network with more channels contains all the network parameters of the teacher sub-network with fewer channels.

[0114] The above-mentioned training module 804 is also used to apply the teacher sub-network in the teacher network in the order of the number of channels from small to large, and perform distillation training for a preset number of stages on the initial student network in sequence to obtain a target student network, wherein the preset number of stages is equal to the total number of teacher sub-networks.

[0115] The training module 804 is also used to select teacher sub-networks from the teacher network in order of the number of channels from small to large as the training network of the current stage. For each training network, the following operations are performed: the training network is applied to perform distillation training on the initial student network to obtain the initial student network trained in the current stage; the initial student network trained in the current stage is used as the initial student network for the next stage of training, and the training is continued until the training corresponding to all teacher sub-networks is completed to obtain the target student network.

[0116] During the distillation training of the initial student network, the learning rate decay strategy of the student network remains unchanged as the linear decay strategy or the cosine decay strategy.

[0117] The above-mentioned teacher network acquisition module 802 is also used to construct a teacher network including multiple teacher sub-networks, wherein the multiple teacher sub-networks have the same number of layers and different numbers of channels; multiple teacher sub-networks are trained according to sample data to obtain a teacher network, wherein the sample data contains corresponding labels.

[0118] The above process of training multiple teacher sub-networks according to sample data includes: training the largest teacher sub-network according to the sample data, wherein the largest teacher sub-network is the teacher sub-network with the largest number of channels in the teacher network; training multiple smaller teacher sub-networks according to the sample data and the largest teacher sub-network, wherein the smaller teacher sub-networks are other teacher sub-networks in the teacher network except the largest teacher sub-network.

[0119] The above process of training a smaller teacher sub-network based on sample data and the maximum teacher sub-network includes: inputting the sample data into the maximum teacher sub-network to obtain a first feature; inputting the sample data into the smaller teacher sub-network to obtain a second feature output by the smaller teacher sub-network; and training the smaller teacher sub-network based on the label, the first feature and the second feature.

[0120] The above-mentioned step of training the smaller teacher sub-network according to the label, the first feature and the second feature includes: determining the label loss value according to the label and the second feature; calculating the KL divergence of the first feature and the second feature, and determining the KL divergence as the KL divergence loss value; determining the network loss value corresponding to the smaller teacher sub-network according to the label loss value and the KL divergence loss value; and training the smaller teacher sub-network using the network loss value corresponding to the smaller teacher sub-network.

[0121] The embodiment of the present invention also provides a target recognition device, such as Fig. 9 As shown, the device pre-stores a target student network trained by the neural network training device provided by an embodiment of the present invention, and the device includes:

[0122] The data acquisition module 902 is used to acquire the data to be identified;

[0123] The recognition module 904 is used to perform target recognition on the data to be recognized through the target student network to obtain a recognition result with a target object.

[0124] The neural network training device and target recognition device provided in the embodiments of the present invention have the same implementation principles and technical effects as those of the aforementioned method embodiments. For the sake of brief description, for parts not mentioned in the embodiments of the aforementioned devices, reference may be made to the corresponding contents in the aforementioned neural network training method and target recognition method embodiments.

[0125] The embodiment of the present invention further provides an electronic device, such as Fig.10 As shown, it is a schematic diagram of the structure of the electronic device, wherein the electronic device includes a processor 1001 and a memory 1002, the memory 1002 stores computer executable instructions that can be executed by the processor 1001, and the processor 1001 executes the computer executable instructions to implement the above-mentioned neural network training method and target recognition method.

[0126] exist Fig.10 In the illustrated embodiment, the electronic device further includes a bus 1003 and a communication interface 1004 , wherein the processor 1001 , the communication interface 1004 and the memory 1002 are connected via the bus 1003 .

[0127] Among them, the memory 1002 may include a high-speed random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 1004 (which can be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. can be used. The bus 1003 can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. The bus 1003 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig.10 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0128] The processor 1001 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 1001. The above processor 1001 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor. The steps of the method disclosed in the embodiment of the present invention can be directly embodied as a hardware decoding processor to execute, or the hardware and software modules in the decoding processor can be executed. The software module can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor 1001 reads the information in the memory and combines its hardware to complete the steps of the neural network training method and the target recognition method of the aforementioned embodiment.

[0129] An embodiment of the present invention further provides a computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement the above-mentioned neural network training method and target recognition method. The specific implementation can be found in the aforementioned method embodiment, which will not be repeated here.

[0130] The neural network training method, device, electronic device, and computer program product of the target recognition method, device, and electronic device provided in the embodiments of the present invention include a computer-readable storage medium storing program code, and the instructions included in the program code can be used to execute the methods described in the previous method embodiments. The specific implementation can be found in the method embodiments, which will not be repeated here.

[0131] Unless otherwise specifically stated, the relative steps, numerical expressions and values ​​of the components and steps set forth in these embodiments do not limit the scope of the present invention.

[0132] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0133] In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicating the orientation or positional relationship, are based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first", "second", and "third" are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance.

[0134] Finally, it should be noted that the above-described embodiments are only specific implementations of the present invention, which are used to illustrate the technical solutions of the present invention, rather than to limit them. The protection scope of the present invention is not limited thereto. Although the present invention is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed by the present invention, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims

1. A neural network training method, characterized in that: The method comprises: Obtain a pre-trained teacher network, wherein the teacher network includes multiple teacher sub-networks, wherein the multiple teacher sub-networks have the same number of layers and different numbers of channels; in any two adjacent teacher sub-networks of the teacher network, the teacher sub-network with more channels contains all network parameters of the teacher sub-network with fewer channels; In order of the number of channels from small to large, the teacher sub-networks in the teacher network are applied to perform distillation training on the initial student network in sequence to obtain a target student network.

2. The method according to claim 1, characterized in that: The step of applying the teacher sub-network in the teacher network to perform distillation training on the initial student network in order of the number of channels from small to large to obtain the target student network comprises: In order of the number of channels from small to large, the teacher sub-network in the teacher network is applied to perform distillation training for a preset number of stages on the initial student network in sequence to obtain a target student network, wherein the preset number of stages is equal to the total number of the teacher sub-networks.

3. The method according to claim 1, characterized in that The step of applying the teacher sub-network in the teacher network to perform distillation training on the initial student network in order of the number of channels from small to large to obtain the target student network comprises: In order of the number of channels from small to large, teacher sub-networks are selected from the teacher network as the training network of the current stage. For each of the training networks, the following operations are performed: Applying the training network to perform distillation training on the initial student network to obtain an initial student network that has completed training in the current stage; The initial student network trained in the current stage is used as the initial student network for the next stage of training, and training continues until the training corresponding to all teacher sub-networks is completed to obtain the target student network.

4. The method according to any one of claims 1 to 3, characterized in that: During the distillation training of the initial student network, the learning rate decay strategy of the student network remains unchanged as a linear decay strategy or a cosine decay strategy.

5. The method according to claim 1, characterized in that The steps to obtain a pre-trained teacher network include: Constructing a teacher network comprising a plurality of teacher sub-networks, wherein the plurality of teacher sub-networks have the same number of layers and different numbers of channels; The plurality of teacher sub-networks are trained according to sample data to obtain the teacher network, wherein the sample data includes corresponding labels.

6. The method according to claim 5, characterized in that The step of training the multiple teacher sub-networks according to the sample data comprises: Training a maximum teacher sub-network according to the sample data, wherein the maximum teacher sub-network is a teacher sub-network with the largest number of channels in the teacher network; According to the sample data and the largest teacher sub-network, a plurality of smaller teacher sub-networks are trained, wherein the smaller teacher sub-networks are the other teacher sub-networks in the teacher network except the largest teacher sub-network.

7. The method according to claim 6, characterized in that The step of training the smaller teacher sub-network according to the sample data and the largest teacher sub-network comprises: Inputting the sample data into the maximum teacher sub-network to obtain a first feature; Inputting the sample data into the smaller teacher sub-network to obtain a second feature output by the smaller teacher sub-network; The smaller teacher sub-network is trained according to the label, the first feature and the second feature.

8. The method according to claim 7, characterized in that The step of training the smaller teacher sub-network according to the label, the first feature and the second feature comprises: Determine a label loss value according to the label and the second feature; Calculating a KL divergence between the first feature and the second feature, and determining the KL divergence as a KL divergence loss value; Determine the network loss value corresponding to the smaller teacher sub-network according to the label loss value and the KL divergence loss value; The smaller teacher sub-network is trained using the network loss value corresponding to the smaller teacher sub-network.

9. A target recognition method, characterized in that: The method is applied to an electronic device, wherein the electronic device pre-stores a target student network trained using the method according to any one of claims 1 to 8, and the method comprises: Obtaining data to be identified; The target student network is used to perform target recognition on the data to be recognized, and a recognition result with a target object is obtained.

10. A neural network training device, characterized in that: The device comprises: A teacher network acquisition module is used to acquire a pre-trained teacher network, wherein the teacher network includes multiple teacher sub-networks, wherein the multiple teacher sub-networks have the same number of layers and different numbers of channels; among any two adjacent teacher sub-networks of the teacher network, the teacher sub-network with more channels contains all network parameters of the teacher sub-network with fewer channels; The training module is used to apply the teacher sub-networks in the teacher network in the order of the number of channels from small to large, and perform distillation training on the initial student network in sequence to obtain the target student network.

11. A target recognition device, characterized in that: The device pre-stores a target student network trained using the method described in any one of claims 1 to 8, and the device comprises: A data acquisition module, used to acquire data to be identified; The recognition module is used to perform target recognition on the data to be recognized through the target student network to obtain a recognition result with a target object.

12. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores computer executable instructions that can be executed by the processor, and the processor executes the computer executable instructions to implement the method according to any one of claims 1 to 9.

13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement the method according to any one of claims 1 to 9.