CN109165738B - Neural network model optimization method and device, electronic device and storage medium - Google Patents

Neural network model optimization method and device, electronic device and storage medium Download PDF

Info

Publication number
CN109165738B
CN109165738B CN201811093361.XA CN201811093361A CN109165738B CN 109165738 B CN109165738 B CN 109165738B CN 201811093361 A CN201811093361 A CN 201811093361A CN 109165738 B CN109165738 B CN 109165738B
Authority
CN
China
Prior art keywords
output
model
layer
student model
feature extraction
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201811093361.XA
Other languages
Chinese (zh)
Other versions
CN109165738A (en
Inventor
罗棕太
张学森
伊帅
闫俊杰
王晓刚
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Sensetime Technology Development Co Ltd
Original Assignee
Beijing Sensetime Technology Development Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Sensetime Technology Development Co Ltd filed Critical Beijing Sensetime Technology Development Co Ltd
Priority to CN201811093361.XA priority Critical patent/CN109165738B/en
Publication of CN109165738A publication Critical patent/CN109165738A/en
Application granted granted Critical
Publication of CN109165738B publication Critical patent/CN109165738B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods

Abstract

The disclosure relates to a neural network model optimization method and apparatus, an electronic device, and a storage medium. The method comprises the following steps: selecting part of neurons from a full connection layer in front of an output layer of the student model; respectively inputting input data into a student model and a teacher model, and obtaining the output of the student model based on part of neurons selected from a fully connected layer before an output layer of the student model; obtaining the output of the teacher model based on all neurons in a fully connected layer before the output layer of the teacher model; the student model is optimized based on the output of the student model and the output of the teacher model. The embodiment of the disclosure can stably improve the accuracy of the neural network model on the premise of not increasing the total amount of training data and not needing retraining, and can enhance the generalization capability of the neural network model.

Description

Neural network model optimization method and device, electronic device and storage medium
Technical Field
The present disclosure relates to the field of deep learning technologies, and in particular, to a method and an apparatus for optimizing a neural network model, an electronic device, and a storage medium.
Background
At present, neural network models are applied to various aspects such as computer vision and natural language processing (such as pedestrian retrieval and face recognition), and achieve better effects. After the neural network model training is completed, the accuracy of the test often limits the upper limit of the accuracy of the neural network model.
In the related art, the accuracy of the neural network model is generally improved by increasing the total amount of training data, changing the structure of the neural network model, or performing fine adjustment and retraining on the model. These methods all place very high demands on the data volume. Increasing the total amount of training data and fine tuning may not necessarily improve the accuracy of the neural network model, possibly due to the difficulty in training the neural network model due to the uneven quality of the data. Changing the structure of the neural network model does not usually have a definite standard, and therefore the accuracy of the trained neural network model cannot be guaranteed.
Disclosure of Invention
The present disclosure provides an optimization technical scheme of a neural network model.
According to an aspect of the present disclosure, there is provided a method for optimizing a neural network model, including:
selecting part of neurons from a full connection layer in front of an output layer of the student model;
inputting input data into the student model and the teacher model respectively, and obtaining the output of the student model based on part of neurons selected from a fully connected layer before an output layer of the student model;
obtaining an output of the teacher model based on all neurons in a fully connected layer before an output layer of the teacher model;
optimizing the student model based on the output of the student model and the output of the teacher model.
In one possible implementation, selecting a portion of neurons from a fully connected layer before an output layer of a student model includes:
and selecting partial neurons from the last fully connected layer before the output layer of the student model.
In one possible implementation, selecting a portion of neurons from a fully connected layer before an output layer of a student model includes:
generating a random number in a first interval respectively for each neuron in a first full-connection layer, wherein the first full-connection layer represents a full-connection layer for selecting neurons before an output layer of the student model;
and if the random number corresponding to the first neuron in the first full connection layer belongs to a second interval, selecting the first neuron from the first full connection layer, wherein the second interval is a subset of the first interval, and the second interval is not equal to the first interval.
In one possible implementation, optimizing the student model based on the output of the student model and the output of the teacher model includes:
determining a mean square error between an output of the student model and an output of the teacher model;
obtaining a first loss function based on the mean square error;
optimizing the student model using the first loss function.
In one possible implementation, optimizing the student model based on the output of the student model and the output of the teacher model includes:
determining a relative entropy of an output of the student model relative to an output of the teacher model;
obtaining a second loss function based on the relative entropy;
optimizing the student model using the second loss function.
In one possible implementation, deriving a second loss function based on the relative entropy includes:
determining an adjusting coefficient corresponding to the relative entropy;
determining a product of the relative entropy and the adjustment coefficient as a second loss function.
In one possible implementation, the output is a logarithmized log of a logarithmized tier output.
According to an aspect of the present disclosure, there is provided an apparatus for optimizing a neural network model, including:
the selection module is used for selecting part of neurons from a full connection layer in front of an output layer of the student model;
the first determining module is used for respectively inputting input data into the student model and the teacher model and obtaining the output of the student model based on part of neurons selected from a full-connection layer before an output layer of the student model;
a second determination module, configured to obtain an output of the teacher model based on all neurons in a fully connected layer before an output layer of the teacher model;
an optimization module to optimize the student model based on the output of the student model and the output of the teacher model.
In a possible implementation manner, the selecting module is configured to:
and selecting partial neurons from the last fully connected layer before the output layer of the student model.
In a possible implementation manner, the selecting module includes:
the generation submodule is used for generating a random number in a first interval respectively for each neuron in a first full-connection layer, wherein the first full-connection layer represents a full-connection layer for selecting the neuron before an output layer of the student model;
and the selecting submodule is used for selecting the first neuron from the first full connection layer if the random number corresponding to the first neuron in the first full connection layer belongs to a second interval, wherein the second interval is a subset of the first interval, and the second interval is not equal to the first interval.
In one possible implementation, the optimization module includes:
a first determination sub-module for determining a mean square error between the output of the student model and the output of the teacher model;
a second determining submodule, configured to obtain a first loss function based on the mean square error;
a first optimization submodule for optimizing the student model using the first loss function.
In one possible implementation, the optimization module includes:
a third determination submodule for determining a relative entropy of an output of the student model relative to an output of the teacher model;
a fourth determining submodule, configured to obtain a second loss function based on the relative entropy;
a second optimization submodule for optimizing the student model using the second loss function.
In one possible implementation, the fourth determining sub-module includes:
a first determining unit, configured to determine an adjustment coefficient corresponding to the relative entropy;
a second determining unit for determining a product of the relative entropy and the adjustment coefficient as a second loss function.
In one possible implementation, the output is a logarithmized log of a logarithmized tier output.
According to an aspect of the present disclosure, there is provided an electronic device including:
a processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to: and executing the optimization method of the neural network model.
According to an aspect of the present disclosure, there is provided a computer readable storage medium having stored thereon computer program instructions which, when executed by a processor, implement the above-described method of optimization of a neural network model.
In the embodiment of the disclosure, the output of the student model is obtained based on the part of neurons selected from the fully connected layer before the output layer of the student model, the output of the teacher model is obtained based on all the neurons in the fully connected layer before the output layer of the teacher model, and the student model is optimized based on the output of the student model and the output of the teacher model, so that the accuracy of the neural network model can be stably improved on the premise of not increasing the total amount of training data and needing no retraining, and the method is generally applicable to most of neural network models and data, and the output of the student model can be effectively fitted by selecting the part of neurons of the fully connected layer before the output layer of the student model, so that the overfitting of the neural network model can be effectively reduced, and the generalization capability of the neural network model can be enhanced.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Other features and aspects of the present disclosure will become apparent from the following detailed description of exemplary embodiments, which proceeds with reference to the accompanying drawings.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the disclosure.
Fig. 1 shows a flow chart of a method of optimization of a neural network model according to an embodiment of the present disclosure.
Fig. 2 shows an exemplary flowchart of the optimization method step S11 of the neural network model according to the embodiment of the present disclosure.
Fig. 3 shows an exemplary flowchart of the optimization method step S14 of the neural network model according to the embodiment of the present disclosure.
Fig. 4 shows another exemplary flowchart of the optimization method step S14 of the neural network model according to an embodiment of the present disclosure.
Fig. 5 shows an exemplary flowchart of the step S145 of the optimization method of the neural network model according to the embodiment of the present disclosure.
Fig. 6 shows a block diagram of an optimization apparatus of a neural network model according to an embodiment of the present disclosure.
Fig. 7 illustrates an exemplary block diagram of an optimization apparatus of a neural network model according to an embodiment of the present disclosure.
Fig. 8 is a block diagram illustrating an electronic device 800 in accordance with an example embodiment.
Fig. 9 is a block diagram illustrating an electronic device 1900 in accordance with an example embodiment.
Detailed Description
Various exemplary embodiments, features and aspects of the present disclosure will be described in detail below with reference to the accompanying drawings. In the drawings, like reference numbers can indicate functionally identical or similar elements. While the various aspects of the embodiments are presented in drawings, the drawings are not necessarily drawn to scale unless specifically indicated.
The word "exemplary" is used exclusively herein to mean "serving as an example, embodiment, or illustration. Any embodiment described herein as "exemplary" is not necessarily to be construed as preferred or advantageous over other embodiments.
The term "and/or" herein is merely an association describing an associated object, meaning that three relationships may exist, e.g., a and/or B, may mean: a exists alone, A and B exist simultaneously, and B exists alone. In addition, the term "at least one" herein means any one of a plurality or any combination of at least two of a plurality, for example, including at least one of A, B, C, and may mean including any one or more elements selected from the group consisting of A, B and C.
Furthermore, in the following detailed description, numerous specific details are set forth in order to provide a better understanding of the present disclosure. It will be understood by those skilled in the art that the present disclosure may be practiced without some of these specific details. In some instances, methods, means, elements and circuits that are well known to those skilled in the art have not been described in detail so as not to obscure the present disclosure.
Fig. 1 shows a flow chart of a method of optimization of a neural network model according to an embodiment of the present disclosure. The execution subject of the optimization method of the neural network model may be an optimization device of the neural network model. For example, the optimization method of the neural network model may be performed by a terminal device or a server or other processing device. The terminal device may be a User Equipment (UE), a mobile device, a User terminal, a cellular phone, a cordless phone, a Personal Digital Assistant (PDA), a handheld device, a computing device, a vehicle-mounted device, or a wearable device. The neural network model in the embodiment of the disclosure can be applied to the fields of intelligent video analysis, security monitoring or face recognition and the like. In some possible implementations, the optimization method of the neural network model may be implemented by a processor calling computer-readable instructions stored in a memory. As shown in fig. 1, the method includes steps S11 through S14.
In step S11, a part of neurons is selected from the fully connected layer before the output layer of the student model.
In the disclosed embodiment, the student model and the teacher model are both neural network models. The student model and the teacher model can be the same neural network model or different neural network models. The student model in the disclosed embodiment can be used for processing tasks such as feature extraction and/or object recognition. The object recognition may be human recognition or object recognition. For example, the person recognition may be face recognition or pedestrian re-recognition; the object identification may be vehicle identification or the like. The teacher model in the disclosed embodiments may also be used to handle tasks such as feature extraction and/or object recognition.
In one possible implementation, some of the neurons may be randomly selected from a fully connected layer before the output layer of the student model.
In one possible implementation, selecting a portion of neurons from a fully connected layer before an output layer of a student model includes: and selecting partial neurons from the last fully connected layer before the output layer of the student model.
As an example of this implementation, a portion of the neurons may be randomly chosen from the last fully-connected layer before the output layer of the student model.
In one possible implementation, selecting a portion of neurons from a fully connected layer before an output layer of a student model includes: selecting at least N neurons from a first full connection layer, wherein the first full connection layer represents a full connection layer in which neuron selection is performed before an output layer of a student model, the number of the selected neurons in the first full connection layer is smaller than the total number of the neurons in the first full connection layer, N is equal to the product of the total number of the neurons in the first full connection layer and a first threshold, and the first threshold is larger than 0 and smaller than 1. For example, if the fully connected layer for neuron selection before the output layer of the student model is the last fully connected layer before the output layer of the student model, the first fully connected layer is the last fully connected layer before the output layer of the student model. For example, the first threshold is equal to 0.7.
In this implementation, at least N neurons are selected from the first fully-connected layer, so that too few neurons can be avoided being selected, and thereby the situation that the difficulty of training the student model is greatly increased and/or the student model cannot be converged due to too few neurons being selected can be avoided.
In step S12, the input data is input into the student model and the teacher model, respectively, and the output of the student model is obtained based on a part of neurons selected from the fully connected layer preceding the output layer of the student model.
In embodiments of the present disclosure, the input data may be training data. For example, when training a student model using a pedestrian re-recognition task, the input data may be an image of a pedestrian.
In one possible implementation, the output is the logarithms of the logarithmically layered output. The logarithms output by the logarithms layer refers to logits output by the logarithms layer.
In another possible implementation, the output is the final output of the neural network model. For example, the output is that of the softmax layer.
In the embodiment of the disclosure, part of the neurons are selected from the fully connected layer before the output layer of the student model, and the output of the student model is obtained based on the part of the neurons selected from the fully connected layer before the output layer of the student model, so that the fitting degree of the student model can be reduced, overfitting of the student model is avoided, and the generalization capability of the student model can be enhanced.
In step S13, the output of the teacher model is obtained based on all neurons in the fully-connected layer preceding the output layer of the teacher model.
In the embodiment of the present disclosure, the neurons of the fully connected layer of the teacher model are not selected, and the output of the teacher model is obtained based on all the neurons of the teacher model.
In step S14, the student model is optimized based on the output of the student model and the output of the teacher model.
In one possible implementation, the loss function corresponding to the student model may be determined based on the output of the student model and the output of the teacher model, and the student model may be optimized using the loss function corresponding to the student model. In this implementation, a loss function corresponding to the student model may be employed and the student model may be optimized based on a back propagation algorithm.
In the embodiment of the disclosure, the output of the student model is obtained based on the part of neurons selected from the fully connected layer before the output layer of the student model, the output of the teacher model is obtained based on all the neurons in the fully connected layer before the output layer of the teacher model, and the student model is optimized based on the output of the student model and the output of the teacher model, so that the accuracy of the neural network model can be stably improved on the premise of not increasing the total amount of training data and needing no retraining, and the method is generally applicable to most of neural network models and data, and the output of the student model can be effectively fitted by selecting the part of neurons of the fully connected layer before the output layer of the student model, so that the overfitting of the neural network model can be effectively reduced, and the generalization capability of the neural network model can be enhanced.
Fig. 2 shows an exemplary flowchart of the optimization method step S11 of the neural network model according to the embodiment of the present disclosure. As shown in fig. 2, step S111 may include step S112.
In step S111, a random number is generated in a first interval for each neuron in a first fully-connected layer, where the first fully-connected layer represents a fully-connected layer before an output layer of the student model for neuron selection.
For example, the first interval is [0,1 ].
In step S112, if the random number corresponding to the first neuron in the first full-link layer belongs to a second interval, the first neuron is selected from the first full-link layer, where the second interval is a subset of the first interval, and the second interval is not equal to the first interval.
For example, the second interval is [0,0.7 ].
In the embodiment of the present disclosure, whether each neuron in the first fully-connected layer is selected is determined according to whether the random number corresponding to each neuron in the first fully-connected layer belongs to the second interval. For example, if the random number corresponding to a certain neuron in the first full connection layer belongs to the second interval, the neuron is selected; and if the random number corresponding to a certain neuron in the first full connection layer does not belong to the second interval, not selecting the neuron. The effect of randomly selecting part of neurons in the first full-connection layer can be achieved by generating a random number in the first interval for each neuron in the first full-connection layer, selecting the first neuron from the first full-connection layer if the random number corresponding to the first neuron in the first full-connection layer belongs to the second interval, and not selecting the first neuron from the first full-connection layer if the random number corresponding to the first neuron in the first full-connection layer does not belong to the second interval.
Fig. 3 shows an exemplary flowchart of the optimization method step S14 of the neural network model according to the embodiment of the present disclosure. As shown in fig. 3, step S14 may include steps S141 to S143.
In step S141, the mean square error between the output of the student model and the output of the teacher model is determined.
In the embodiment of the present disclosure, the mean square error between the output of the student model and the output of the teacher model may be determined by using a related art method, which is not described herein again.
In step S142, a first loss function is obtained based on the mean square error.
In one possible implementation, the mean square error may be taken as the first loss function.
In another possible implementation, the product of the mean square error and the first coefficient may be used as the first loss function.
It should be noted that, although the manner of obtaining the first loss function is described above in the above implementation manner, those skilled in the art can understand that the disclosure should not be limited thereto. Those skilled in the art can flexibly set a specific implementation manner of obtaining the first loss function according to actual application scene requirements and/or personal preferences, as long as the first loss function is obtained based on the mean square error.
In step S143, the student model is optimized using the first loss function.
In one possible implementation, a student model may be optimized using a first loss function and a first learning rate.
Fig. 4 shows another exemplary flowchart of the optimization method step S14 of the neural network model according to an embodiment of the present disclosure. As shown in fig. 4, step S14 may include steps S144 to S146.
In step S144, the relative entropy of the output of the student model relative to the output of the teacher model is determined.
In the embodiment of the present disclosure, the relative entropy of the output of the student model with respect to the output of the teacher model may be determined by using related art means, which is not described herein again.
In step S145, a second loss function is obtained based on the relative entropy.
In one possible implementation, the product of the relative entropy and the adjustment coefficient may be used as the second loss function.
In another possible implementation, the relative entropy may be taken as a second loss function.
It should be noted that, although the manner of obtaining the second loss function is described above in the above implementation manner, those skilled in the art can understand that the disclosure should not be limited thereto. Those skilled in the art can flexibly set a specific implementation manner of obtaining the second loss function according to the actual application scenario requirements and/or personal preferences, as long as the second loss function is obtained based on the relative entropy.
In step S146, the student model is optimized using the second loss function.
In one possible implementation, the student model may be optimized using a second loss function and a second learning rate. Wherein the second learning rate is less than the first learning rate.
Fig. 5 shows an exemplary flowchart of the step S145 of the optimization method of the neural network model according to the embodiment of the present disclosure. As shown in fig. 5, step S145 may include step S1451 and step S1452.
In step S1451, an adjustment coefficient corresponding to the relative entropy is determined.
In one possible implementation, the relative entropy corresponds to an adjustment factor greater than 1.
In step S1452, a product of the relative entropy and the adjustment coefficient is determined as a second loss function.
By determining the product of the relative entropy and the adjustment coefficient as the second loss function, the failure of the student model training due to the overlarge gradient in the back propagation process can be avoided.
It should be noted that, although the manner of obtaining the second loss function based on the relative entropy is described above by taking the determination of the product of the relative entropy and the adjustment coefficient as the second loss function as an example, it can be understood by those skilled in the art that the present disclosure should not be limited thereto. The specific implementation manner of obtaining the second loss function based on the relative entropy can be flexibly set by those skilled in the art according to the requirements of the actual application scenario and/or personal preference. For example, a ratio of the relative entropy to an adjustment coefficient may be determined as the second loss function, wherein the adjustment coefficient is less than 1.
In the embodiment of the present disclosure, the parameters of the teacher model are fixed, and the parameters of the student model are not fixed, that is, the student models are in an optimizable state, and the parameters of the student model are optimized along with the training. During the training process, the hyper-parameters in the student model can be adjusted manually. After training, the student model may be applied to other tasks than the training task.
In the embodiment of the present disclosure, the student model and the teacher model may be the same, in other words, the student model with high performance does not need to be used for supervised learning, and the student model in the embodiment of the present disclosure may improve accuracy by a knowledge distillation method, and perform stably.
The embodiment of the disclosure does not need to add extra data, has low requirements on the calculation amount and the calculation time, and can rapidly and effectively improve the performance of the student model under the condition of less calculation resources.
It is understood that the above-mentioned method embodiments of the present disclosure can be combined with each other to form a combined embodiment without departing from the logic of the principle, which is limited by the space, and the detailed description of the present disclosure is omitted.
It will be understood by those skilled in the art that in the method of the present invention, the order of writing the steps does not imply a strict order of execution and any limitations on the implementation, and the specific order of execution of the steps should be determined by their function and possible inherent logic.
In addition, the present disclosure also provides an optimization apparatus of a neural network model, an electronic device, a computer-readable storage medium, and a program, which can all be used to implement any one of the optimization methods of a neural network model provided by the present disclosure, and the corresponding technical solutions and descriptions and corresponding descriptions in the methods section are not repeated.
Fig. 6 shows a block diagram of an optimization apparatus of a neural network model according to an embodiment of the present disclosure. As shown in fig. 6, the neural network model optimization apparatus includes: the selection module 61 is used for selecting part of neurons from a full connection layer in front of an output layer of the student model; a first determining module 62, configured to input data into the student model and the teacher model respectively, and obtain an output of the student model based on a part of neurons selected from a fully connected layer before an output layer of the student model; a second determining module 63, configured to obtain an output of the teacher model based on all neurons in a fully connected layer before an output layer of the teacher model; an optimization module 64 for optimizing the student model based on the output of the student model and the output of the teacher model.
In one possible implementation, the selecting module 61 is configured to: and selecting partial neurons from the last fully connected layer before the output layer of the student model.
Fig. 7 illustrates an exemplary block diagram of an optimization apparatus of a neural network model according to an embodiment of the present disclosure. As shown in fig. 7:
in one possible implementation, the selecting module 61 includes: the generation submodule 611 is configured to generate a random number in a first interval for each neuron in a first full connection layer, where the first full connection layer represents a full connection layer in which neuron selection is performed before an output layer of the student model; the selecting submodule 612 is configured to select a first neuron from the first full-link layer if the random number corresponding to the first neuron in the first full-link layer belongs to a second interval, where the second interval is a subset of the first interval, and the second interval is not equal to the first interval.
In one possible implementation, the optimization module 64 includes: a first determining sub-module 641 for determining a mean square error between the output of the student model and the output of the teacher model; a second determining submodule 642, configured to obtain a first loss function based on the mean square error; a first optimization submodule 643, configured to optimize the student model using a first loss function.
In one possible implementation, the optimization module 64 includes: a third determining submodule 644 for determining the relative entropy of the output of the student model with respect to the output of the teacher model; a fourth determining sub-module 645, configured to obtain a second loss function based on the relative entropy; a second optimization submodule 646 for optimizing the student model using a second loss function.
In one possible implementation, the fourth determining sub-module 645 includes: a first determining unit, configured to determine an adjustment coefficient corresponding to the relative entropy; a second determining unit for determining a product of the relative entropy and the adjustment coefficient as a second loss function.
In one possible implementation, the output is the logarithms of the logarithmically layered output.
In the embodiment of the disclosure, the output of the student model is obtained based on the part of neurons selected from the fully connected layer before the output layer of the student model, the output of the teacher model is obtained based on all the neurons in the fully connected layer before the output layer of the teacher model, and the student model is optimized based on the output of the student model and the output of the teacher model, so that the accuracy of the neural network model can be stably improved on the premise of not increasing the total amount of training data and needing no retraining, and the method is generally applicable to most of neural network models and data, and the output of the student model can be effectively fitted by selecting the part of neurons of the fully connected layer before the output layer of the student model, so that the overfitting of the neural network model can be effectively reduced, and the generalization capability of the neural network model can be enhanced.
In some embodiments, functions of or modules included in the apparatus provided in the embodiments of the present disclosure may be used to execute the method described in the above method embodiments, and specific implementation thereof may refer to the description of the above method embodiments, and for brevity, will not be described again here.
Embodiments of the present disclosure also provide a computer-readable storage medium having stored thereon computer program instructions, which when executed by a processor, implement the above-mentioned method. The computer readable storage medium may be a non-volatile computer readable storage medium.
An embodiment of the present disclosure further provides an electronic device, including: a processor; a memory for storing processor-executable instructions; wherein the processor is configured as the above method.
The electronic device may be provided as a terminal, server, or other form of device.
Fig. 8 is a block diagram illustrating an electronic device 800 in accordance with an example embodiment. For example, the electronic device 800 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, or the like terminal.
Referring to fig. 8, electronic device 800 may include one or more of the following components: processing component 802, memory 804, power component 806, multimedia component 808, audio component 810, input/output (I/O) interface 812, sensor component 814, and communication component 816.
The processing component 802 generally controls overall operation of the electronic device 800, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing components 802 may include one or more processors 820 to execute instructions to perform all or a portion of the steps of the methods described above. Further, the processing component 802 can include one or more modules that facilitate interaction between the processing component 802 and other components. For example, the processing component 802 can include a multimedia module to facilitate interaction between the multimedia component 808 and the processing component 802.
The memory 804 is configured to store various types of data to support operations at the electronic device 800. Examples of such data include instructions for any application or method operating on the electronic device 800, contact data, phonebook data, messages, pictures, videos, and so forth. The memory 804 may be implemented by any type or combination of volatile or non-volatile memory devices such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disks.
The power supply component 806 provides power to the various components of the electronic device 800. The power components 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the electronic device 800.
The multimedia component 808 includes a screen that provides an output interface between the electronic device 800 and a user. In some embodiments, the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive an input signal from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front facing camera and/or a rear facing camera. The front camera and/or the rear camera may receive external multimedia data when the electronic device 800 is in an operation mode, such as a shooting mode or a video mode. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
The audio component 810 is configured to output and/or input audio signals. For example, the audio component 810 includes a Microphone (MIC) configured to receive external audio signals when the electronic device 800 is in an operational mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals may further be stored in the memory 804 or transmitted via the communication component 816. In some embodiments, audio component 810 also includes a speaker for outputting audio signals.
The I/O interface 812 provides an interface between the processing component 802 and peripheral interface modules, which may be keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to: a home button, a volume button, a start button, and a lock button.
The sensor assembly 814 includes one or more sensors for providing various aspects of state assessment for the electronic device 800. For example, the sensor assembly 814 may detect an open/closed state of the electronic device 800, the relative positioning of components, such as a display and keypad of the electronic device 800, the sensor assembly 814 may also detect a change in the position of the electronic device 800 or a component of the electronic device 800, the presence or absence of user contact with the electronic device 800, orientation or acceleration/deceleration of the electronic device 800, and a change in the temperature of the electronic device 800. Sensor assembly 814 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 814 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
The communication component 816 is configured to facilitate wired or wireless communication between the electronic device 800 and other devices. The electronic device 800 may access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 816 receives a broadcast signal or broadcast related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 further includes a Near Field Communication (NFC) module to facilitate short-range communications. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, Ultra Wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
In an exemplary embodiment, the electronic device 800 may be implemented by one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, micro-controllers, microprocessors or other electronic components for performing the above-described methods.
In an exemplary embodiment, a non-transitory computer-readable storage medium, such as the memory 804, is also provided that includes computer program instructions executable by the processor 820 of the electronic device 800 to perform the above-described methods.
Fig. 9 is a block diagram illustrating an electronic device 1900 in accordance with an example embodiment. For example, the electronic device 1900 may be provided as a server. Referring to fig. 9, electronic device 1900 includes a processing component 1922 further including one or more processors and memory resources, represented by memory 1932, for storing instructions, e.g., applications, executable by processing component 1922. The application programs stored in memory 1932 may include one or more modules that each correspond to a set of instructions. Further, the processing component 1922 is configured to execute instructions to perform the above-described method.
The electronic device 1900 may also include a power component 1926 configured to perform power management of the electronic device 1900, a wired or wireless network interface 1950 configured to connect the electronic device 1900 to a network, and an input/output (I/O) interface 1958. The electronic device 1900 may operate based on an operating system stored in memory 1932, such as Windows Server, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, or the like.
In an exemplary embodiment, a non-transitory computer readable storage medium, such as the memory 1932, is also provided that includes computer program instructions executable by the processing component 1922 of the electronic device 1900 to perform the above-described methods.
The present disclosure may be systems, methods, and/or computer program products. The computer program product may include a computer-readable storage medium having computer-readable program instructions embodied thereon for causing a processor to implement various aspects of the present disclosure.
The computer readable storage medium may be a tangible device that can hold and store the instructions for use by the instruction execution device. The computer readable storage medium may be, for example, but not limited to, an electronic memory device, a magnetic memory device, an optical memory device, an electromagnetic memory device, a semiconductor memory device, or any suitable combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a Static Random Access Memory (SRAM), a portable compact disc read-only memory (CD-ROM), a Digital Versatile Disc (DVD), a memory stick, a floppy disk, a mechanical coding device, such as punch cards or in-groove projection structures having instructions stored thereon, and any suitable combination of the foregoing. Computer-readable storage media as used herein is not to be construed as transitory signals per se, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through a waveguide or other transmission medium (e.g., optical pulses through a fiber optic cable), or electrical signals transmitted through electrical wires.
The computer-readable program instructions described herein may be downloaded from a computer-readable storage medium to a respective computing/processing device, or to an external computer or external storage device via a network, such as the internet, a local area network, a wide area network, and/or a wireless network. The network may include copper transmission cables, fiber optic transmission, wireless transmission, routers, firewalls, switches, gateway computers and/or edge servers. The network adapter card or network interface in each computing/processing device receives computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in a computer-readable storage medium in the respective computing/processing device.
The computer program instructions for carrying out operations of the present disclosure may be assembler instructions, Instruction Set Architecture (ISA) instructions, machine-related instructions, microcode, firmware instructions, state setting data, or source or object code written in any combination of one or more programming languages, including an object oriented programming language such as Smalltalk, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The computer-readable program instructions may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider). In some embodiments, the electronic circuitry that can execute the computer-readable program instructions implements aspects of the present disclosure by utilizing the state information of the computer-readable program instructions to personalize the electronic circuitry, such as a programmable logic circuit, a Field Programmable Gate Array (FPGA), or a Programmable Logic Array (PLA).
Various aspects of the present disclosure are described herein with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the disclosure. It will be understood that each block of the flowchart illustrations and/or block diagrams, and combinations of blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer-readable program instructions.
These computer-readable program instructions may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions/acts specified in the flowchart and/or block diagram block or blocks. These computer-readable program instructions may also be stored in a computer-readable storage medium that can direct a computer, programmable data processing apparatus, and/or other devices to function in a particular manner, such that the computer-readable medium storing the instructions comprises an article of manufacture including instructions which implement the function/act specified in the flowchart and/or block diagram block or blocks.
The computer readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other devices to cause a series of operational steps to be performed on the computer, other programmable apparatus or other devices to produce a computer implemented process such that the instructions which execute on the computer, other programmable apparatus or other devices implement the functions/acts specified in the flowchart and/or block diagram block or blocks.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of instructions, which comprises one or more executable instructions for implementing the specified logical function(s). In some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
Having described embodiments of the present disclosure, the foregoing description is intended to be exemplary, not exhaustive, and not limited to the disclosed embodiments. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The terms used herein were chosen in order to best explain the principles of the embodiments, the practical application, or technical improvements to the techniques in the marketplace, or to enable others of ordinary skill in the art to understand the embodiments disclosed herein.

Claims (16)

1. A method for optimizing a neural network model, comprising:
selecting part of neurons from a full connection layer in front of an output layer of the student model;
respectively inputting images into the student model and the teacher model, fitting the output of the student model based on part of neurons selected from a fully connected layer before an output layer of the student model, and obtaining a feature extraction result and/or an object recognition result output by the student model and aiming at the images;
obtaining a feature extraction result and/or an object recognition result for the image output by the teacher model based on all neurons in a fully connected layer before an output layer of the teacher model;
and optimizing the student model based on the feature extraction result and/or the object recognition result output by the student model and the feature extraction result and/or the object recognition result output by the teacher model and aiming at the image, so as to adopt the optimized student model to perform feature extraction and/or object recognition on the image.
2. The method of claim 1, wherein selecting a portion of neurons from a fully connected layer before an output layer of the student model comprises:
and selecting partial neurons from the last fully connected layer before the output layer of the student model.
3. The method of claim 1 or 2, wherein selecting a portion of neurons from a fully connected layer before an output layer of the student model comprises:
generating a random number in a first interval respectively for each neuron in a first full-connection layer, wherein the first full-connection layer represents a full-connection layer for selecting neurons before an output layer of the student model;
and if the random number corresponding to the first neuron in the first full connection layer belongs to a second interval, selecting the first neuron from the first full connection layer, wherein the second interval is a subset of the first interval, and the second interval is not equal to the first interval.
4. The method according to claim 1 or 2, wherein optimizing the student model based on the feature extraction result and/or object recognition result for the image output by the student model and the feature extraction result and/or object recognition result for the image output by the teacher model comprises:
determining a mean square error between the feature extraction result and/or the object recognition result for the image output by the student model and the feature extraction result and/or the object recognition result for the image output by the teacher model;
obtaining a first loss function based on the mean square error;
optimizing the student model using the first loss function.
5. The method according to claim 1 or 2, wherein optimizing the student model based on the feature extraction result and/or object recognition result for the image output by the student model and the feature extraction result and/or object recognition result for the image output by the teacher model comprises:
determining a relative entropy of feature extraction results and/or object recognition results for the image output by the student model relative to feature extraction results and/or object recognition results for the image output by the teacher model;
obtaining a second loss function based on the relative entropy;
optimizing the student model using the second loss function.
6. The method of claim 5, wherein deriving a second loss function based on the relative entropy comprises:
determining an adjusting coefficient corresponding to the relative entropy;
determining a product of the relative entropy and the adjustment coefficient as a second loss function.
7. The method according to claim 1 or 2, wherein the feature extraction result and/or the object recognition result for the image is a logarithm of a logarithm layer output, wherein the logarithm layer refers to a logits layer, and the logarithm of the logarithm layer output refers to a logits of the logits layer output.
8. An apparatus for optimizing a neural network model, comprising:
the selection module is used for selecting part of neurons from a full connection layer in front of an output layer of the student model;
the first determination module is used for respectively inputting images into the student model and the teacher model, fitting the output of the student model based on part of neurons selected from a fully-connected layer before an output layer of the student model, and obtaining a feature extraction result and/or an object recognition result which are output by the student model and aim at the images;
a second determination module, configured to obtain a feature extraction result and/or an object recognition result for the image, which is output by the teacher model, based on all neurons in a fully connected layer before an output layer of the teacher model;
and the optimization module is used for optimizing the student model based on the feature extraction result and/or the object recognition result output by the student model and the feature extraction result and/or the object recognition result output by the teacher model and aiming at the image so as to perform feature extraction and/or object recognition on the image by adopting the optimized student model.
9. The apparatus of claim 8, wherein the selection module is configured to:
and selecting partial neurons from the last fully connected layer before the output layer of the student model.
10. The apparatus according to claim 8 or 9, wherein the selecting module comprises:
the generation submodule is used for generating a random number in a first interval respectively for each neuron in a first full-connection layer, wherein the first full-connection layer represents a full-connection layer for selecting the neuron before an output layer of the student model;
and the selecting submodule is used for selecting the first neuron from the first full connection layer if the random number corresponding to the first neuron in the first full connection layer belongs to a second interval, wherein the second interval is a subset of the first interval, and the second interval is not equal to the first interval.
11. The apparatus of claim 8 or 9, wherein the optimization module comprises:
a first determining sub-module, configured to determine a mean square error between the feature extraction result and/or the object recognition result for the image output by the student model and the feature extraction result and/or the object recognition result for the image output by the teacher model;
a second determining submodule, configured to obtain a first loss function based on the mean square error;
a first optimization submodule for optimizing the student model using the first loss function.
12. The apparatus of claim 8 or 9, wherein the optimization module comprises:
a third determining sub-module, configured to determine a relative entropy of the feature extraction result and/or the object recognition result for the image output by the student model with respect to the feature extraction result and/or the object recognition result for the image output by the teacher model;
a fourth determining submodule, configured to obtain a second loss function based on the relative entropy;
a second optimization submodule for optimizing the student model using the second loss function.
13. The apparatus of claim 12, wherein the fourth determination submodule comprises:
a first determining unit, configured to determine an adjustment coefficient corresponding to the relative entropy;
a second determining unit for determining a product of the relative entropy and the adjustment coefficient as a second loss function.
14. The apparatus according to claim 8 or 9, wherein the feature extraction result and/or the object recognition result for the image is a logarithm of a logarithm layer output, wherein the logarithm layer refers to a logits layer, and the logarithm of the logarithm layer output refers to a logits of the logits layer output.
15. An electronic device, comprising:
a processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to: performing the method of any one of claims 1 to 7.
16. A computer readable storage medium having computer program instructions stored thereon, which when executed by a processor implement the method of any one of claims 1 to 7.
CN201811093361.XA 2018-09-19 2018-09-19 Neural network model optimization method and device, electronic device and storage medium Active CN109165738B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811093361.XA CN109165738B (en) 2018-09-19 2018-09-19 Neural network model optimization method and device, electronic device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811093361.XA CN109165738B (en) 2018-09-19 2018-09-19 Neural network model optimization method and device, electronic device and storage medium

Publications (2)

Publication Number Publication Date
CN109165738A CN109165738A (en) 2019-01-08
CN109165738B true CN109165738B (en) 2021-09-14

Family

ID=64879584

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811093361.XA Active CN109165738B (en) 2018-09-19 2018-09-19 Neural network model optimization method and device, electronic device and storage medium

Country Status (1)

Country Link
CN (1) CN109165738B (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110009052B (en) * 2019-04-11 2022-11-18 腾讯科技(深圳)有限公司 Image recognition method, image recognition model training method and device
CN110222705B (en) * 2019-04-23 2023-10-24 华为技术有限公司 Training method of network model and related device
CN112487182B (en) * 2019-09-12 2024-04-12 华为技术有限公司 Training method of text processing model, text processing method and device
CN110807434B (en) * 2019-11-06 2023-08-15 威海若维信息科技有限公司 Pedestrian re-recognition system and method based on human body analysis coarse-fine granularity combination
CN112825143A (en) * 2019-11-20 2021-05-21 北京眼神智能科技有限公司 Deep convolutional neural network compression method, device, storage medium and equipment
US20220076136A1 (en) * 2020-09-09 2022-03-10 Peyman PASSBAN Method and system for training a neural network model using knowledge distillation

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106548190A (en) * 2015-09-18 2017-03-29 三星电子株式会社 Model training method and equipment and data identification method
CN106991440A (en) * 2017-03-29 2017-07-28 湖北工业大学 A kind of image classification algorithms of the convolutional neural networks based on spatial pyramid
CN107341541A (en) * 2016-04-29 2017-11-10 北京中科寒武纪科技有限公司 A kind of apparatus and method for performing full articulamentum neural metwork training
CN108122003A (en) * 2017-12-19 2018-06-05 西北工业大学 A kind of Weak target recognition methods based on deep neural network

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7062476B2 (en) * 2002-06-17 2006-06-13 The Boeing Company Student neural network
WO2017166155A1 (en) * 2016-03-31 2017-10-05 富士通株式会社 Method and device for training neural network model, and electronic device
CN106709565A (en) * 2016-11-16 2017-05-24 广州视源电子科技股份有限公司 Optimization method and device for neural network
US20180197425A1 (en) * 2017-01-06 2018-07-12 Washington State University Self-monitoring analysis and reporting technologies
CN107273976A (en) * 2017-06-29 2017-10-20 广州日滨科技发展有限公司 A kind of optimization method of neutral net, device, computer and storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106548190A (en) * 2015-09-18 2017-03-29 三星电子株式会社 Model training method and equipment and data identification method
CN107341541A (en) * 2016-04-29 2017-11-10 北京中科寒武纪科技有限公司 A kind of apparatus and method for performing full articulamentum neural metwork training
CN106991440A (en) * 2017-03-29 2017-07-28 湖北工业大学 A kind of image classification algorithms of the convolutional neural networks based on spatial pyramid
CN108122003A (en) * 2017-12-19 2018-06-05 西北工业大学 A kind of Weak target recognition methods based on deep neural network

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
"A Gift from Knowledge Distillation: Fast Optimization, Network Minimization and Transfer Learning";Junho Yim等;《2017 IEEE Conference on Computer Vision and Pattern Recognition (CVPR)》;20171109;第4133-4141页 *
"Knowledge Distillation for Small-footprint Highway Networks";Liang Lu等;《https://arxiv.org/abs/1608.00892》;20161222;全文 *
"Quantization Mimic: Towards Very Tiny CNN for Object Detection";Yi Wei等;《https://arxiv.org/abs/1805.02152v3》;20180914;第1-17页 *
"基于增强监督知识蒸馏的交通标识分类";赵胜伟等;《中国科技论文》;20171031;第12卷(第20期);第2355-2360页 *

Also Published As

Publication number Publication date
CN109165738A (en) 2019-01-08

Similar Documents

Publication Publication Date Title
CN109800737B (en) Face recognition method and device, electronic equipment and storage medium
CN109165738B (en) Neural network model optimization method and device, electronic device and storage medium
CN110837761B (en) Multi-model knowledge distillation method and device, electronic equipment and storage medium
CN110390394B (en) Batch normalization data processing method and device, electronic equipment and storage medium
CN107944409B (en) Video analysis method and device capable of distinguishing key actions
CN110598504B (en) Image recognition method and device, electronic equipment and storage medium
CN109919300B (en) Neural network training method and device and image processing method and device
CN110909815B (en) Neural network training method, neural network training device, neural network processing device, neural network training device, image processing device and electronic equipment
CN109934275B (en) Image processing method and device, electronic equipment and storage medium
CN110458218B (en) Image classification method and device and classification network training method and device
CN111242303B (en) Network training method and device, and image processing method and device
CN109145970B (en) Image-based question and answer processing method and device, electronic equipment and storage medium
CN110659690B (en) Neural network construction method and device, electronic equipment and storage medium
CN109543537B (en) Re-recognition model increment training method and device, electronic equipment and storage medium
CN109858614B (en) Neural network training method and device, electronic equipment and storage medium
CN107341509B (en) Convolutional neural network training method and device and readable storage medium
CN110909861B (en) Neural network optimization method and device, electronic equipment and storage medium
CN109920016B (en) Image generation method and device, electronic equipment and storage medium
CN112001364A (en) Image recognition method and device, electronic equipment and storage medium
CN111259967B (en) Image classification and neural network training method, device, equipment and storage medium
CN110532956B (en) Image processing method and device, electronic equipment and storage medium
CN110188865B (en) Information processing method and device, electronic equipment and storage medium
CN109685041B (en) Image analysis method and device, electronic equipment and storage medium
CN110633470A (en) Named entity recognition method, device and storage medium
CN109447258B (en) Neural network model optimization method and device, electronic device and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant