Knowledge distillation method, device and medium based on multi-stage feature fusion
Through the multi-stage feature fusion framework and feature comparison loss function, the problem that the student network is difficult to learn the characteristics of the teacher network is solved, the cross-stage transfer of feature knowledge is realized, and the recognition accuracy and generalization of the student network are improved.
Patent Information
- Application Number
- CN202311370731.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-20
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2043-10-20
AI Technical Summary
Due to the difference in feature distribution between the teacher network and the student network, it is difficult for the student network to fully learn the implicit knowledge of features in the middle layer of the teacher network, which in turn affects its recognition capabilities in image classification and recognition, target detection, target segmentation and visual tasks.
A multi-stage feature fusion framework is adopted, combined with the cross-stage feature fusion attention module and the same-stage fusion feature comparison loss function, to freeze the pre-training weights of the teacher network and train the student network model to achieve cross-stage transfer and comparison of feature knowledge and enhance student Network generalization and learning capabilities.
Through the multi-stage feature fusion method, the student network can learn the feature knowledge of the teacher network more effectively, thereby improving its performance and generalization ability in image recognition tasks, and significantly improving the recognition accuracy and generalization of the student model.
Smart Images

Figure CN117610608B
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of computer technology, and in particular, relates to a knowledge distillation method, device and medium based on multi-stage feature fusion. Background Art
[0002] In recent years, convolutional neural networks in the field of deep learning have greatly promoted the development of computer vision and have been widely used in classification, recognition, target detection, and target segmentation. However, due to the computing power constraints and video memory limitations of edge computing devices, large convolutional network models are difficult to deploy and apply. How to balance computing overhead and model performance is still a very challenging problem, and knowledge distillation is an effective solution. Knowledge distillation transfers implicit knowledge from the teacher network large model to the student network small model in the form of teachers teaching students, thereby greatly improving the performance of the student model. This method is simple and effective and is widely used in convolutional networks and visual tasks.
[0003] Common knowledge distillation methods are generally divided into two categories. One is based on soft label classification knowledge. This method uses different temperatures to soften the classification labels output by the teacher network and the student network, thereby reducing the final classification knowledge difference between the softened labels of the two to improve the recognition accuracy of the student network. The other is based on the intermediate layer features. Generally speaking, the structure and learning process of the teacher network and the student network have certain similarities. The student network can learn the knowledge implicit in the teacher network in the intermediate feature layer, achieve a better learning process, and achieve its own accuracy improvement effect.
[0004] There are often significant differences in the feature distribution between the teacher network and the student network at the same stage, and the feature distribution of the same network at different stages also has different emphases. Deep features focus on conceptual information, while shallow features focus on texture information. This brings about the problem of differences in feature knowledge distribution, making it difficult for the student network to directly learn the implicit feature knowledge of the teacher network. Summary of the invention
[0005] The technical problem solved by the present invention is to provide a knowledge distillation method, device and medium based on multi-stage feature fusion to solve the problem that in the process of image classification and recognition, target detection, target segmentation and visual tasks, due to the difference in feature distribution between the teacher network and the student network, the student network is difficult to fully learn the implicit knowledge of the intermediate layer features of the teacher network and the student network has low recognition ability of image data.
[0006] The basic solution provided by the present invention: a knowledge distillation method based on multi-stage feature fusion, comprising:
[0007] S1: Obtain an original image dataset and preprocess the original image dataset;
[0008] S2: Use the original image dataset to train the teacher network model and obtain the trained teacher network model;
[0009] S3: Freeze the pre-trained weights of the trained teacher network model, train the student network model using the multi-stage feature fusion framework, the cross-stage feature fusion attention module, and the same-stage fusion feature contrast loss function to generate a trained student network model;
[0010] S4: Run the trained student network model to recognize image data, and only keep the student network architecture in the inference stage.
[0011] Further, the S3 includes:
[0012] S3-1: Freeze the pre-trained weights of the trained teacher network model;
[0013] S3-2: Use the multi-stage feature fusion framework for both the teacher network model and the student network model, and construct the student network feature fusion and the teacher network feature fusion;
[0014] S3-3: Train the student network model through the cross-stage feature fusion attention module;
[0015] S3-4: Construct a feature comparison loss function for the same stage fusion to verify the loss of the student network model trained in S3-3.
[0016] Further, the S3-2 is specifically:
[0017] Define the teacher network model as T and the student network model as S. Both the teacher network model T and the student network model S include n feature output stages and n corresponding fusion modules FFA i , i∈n, and the corresponding i-th layer features are T i and S i ;
[0018] Assume that the first fusion module has one input entry, the rest have two input entry, and the last fusion module has one output exit, the rest have two output exits. The fusion output feature of the i-th layer is and
[0019] Construct student network feature fusion and teacher network feature fusion, and the student network feature fusion calculation formula is:
[0020]
[0021] The calculation formula for the teacher network feature fusion is:
[0022]
[0023] Further, the S3-3 is specifically:
[0024] The cross-stage feature fusion attention module includes two different stage features I 1 and I 2 , and I 1 and I 2 The size and number of channels are different;
[0025] The input feature I is transformed into 1 The size and number of channels are adjusted to match the input feature I 2 are consistent, and are added together to obtain the preliminary fusion feature I;
[0026] Through the parallel channel attention mechanism Ac and spatial attention mechanism As, the parallel results are added to obtain the fusion feature F;
[0027] Then, through convolution and normalization, two output features F with different sizes and number of channels are generated respectively. 1 and F 2 , and fusion feature module FFA 1 The input feature is only I 1 , fusion feature module FFA n The output feature is only F 1 .
[0028] Furthermore, the expression formula of the cross-stage feature fusion attention module is:
[0029] (F 1 ,F 2 )=As(S(I 1 )+I 2 )+Ac(S(I 1 )+I 2 ).
[0030] Further, the S3-4 is specifically:
[0031] Construct the feature contrast loss function of the same stage fusion;
[0032] The i-th stage fusion features of the teacher network model and the student network model are respectively converted into Corresponding TF i and SF i Follow the preset processing to do L mse Similarity matching;
[0033] Combine the cross entropy loss function of the true label and the student classification result, as well as the weight adjustment hyperparameters, to construct a complete loss function and perform loss verification on the student network model;
[0034] The processing according to the preset is specifically as follows:
[0035] No processing, keep TF i and SF i ;
[0036] Without changing the feature space size, compression is performed on the channel to obtain and
[0037] Without changing the number of channels, we can compress the space to get TF. i 2 and SF i 2 , combined with the weight adjustment hyperparameter λ, constitutes the n-stage fusion feature comparison function.
[0038] Furthermore, the calculation formula of the feature contrast loss function of the same stage fusion is:
[0039] L scm =L mse (TF i ,SF i )+λL mse (TF i 1 ,SF i 1 )+λL mse (TF i 2 ,SF i 2 )
[0040] Among them, L scm represents the feature contrast loss function of the same stage fusion, and λ represents the weight adjustment hyperparameter;
[0041] The calculation formula of the complete loss function is:
[0042] L total =L ce +αL scm
[0043] Among them, L total represents the complete loss function, L ce represents the cross entropy loss function, and α represents the weight adjustment hyperparameter corresponding to the complete loss function.
[0044] Furthermore, in S4, only the student network architecture is retained in the reasoning stage. Specifically, in the student network model reasoning stage, the teacher network model and the multi-stage feature fusion framework are cut off, and only the student network architecture part is retained.
[0045] An electronic device includes a processor and a memory, wherein the memory stores programs or instructions, and the processor executes the knowledge distillation method based on multi-stage feature fusion as described above by calling the programs or instructions stored in the memory.
[0046] A computer-readable storage medium stores a program or instruction, which enables a computer to execute the knowledge distillation method based on multi-stage feature fusion as described above.
[0047] The principle and advantage of the present invention are: in this application, through a multi-stage feature fusion framework, cross-stage knowledge transfer from shallow to deep layers of feature knowledge is realized in the teacher network and the student network respectively, so that the single stage of the student network can learn the implicit knowledge of features from different stages of the teacher, and enhance the generalization and learning ability of the student model. The cross-stage feature fusion attention module can realize the organic fusion and beneficial knowledge enhancement between the features of adjacent stages, and then match the space and channel comparison loss function between the fused features of the same stage, so that the student network can learn the features of the teacher network from the two perspectives of channel and space and compare the feature differences between the two, so as to achieve further improvement of the effect of the student model and enhance its model generalization. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1 is a flowchart of an embodiment of the present invention;
[0049] Figure 2 It is a structural diagram of the overall knowledge distillation method of an embodiment of the present invention;
[0050] Figure 3 This is a structural diagram of a cross-stage feature fusion attention module according to an embodiment of the present invention;
[0051] Figure 4 This is a structural diagram of the feature contrast loss function of the same stage fusion in an embodiment of the present invention;
[0052] Figure 5 It is a comparison diagram of different phase combinations of the framework of the embodiment of the present invention;
[0053] Figure 6 A comparison diagram of the framework and module ablation experiments of an embodiment of the present invention;
[0054] Figure 7 The figure is a schematic diagram of the structure of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0055] The following is further described in detail through specific implementation methods:
[0056] The symbols in the drawings of the specification include: electronic device 400 , processor 401 , memory 402 , input device 403 , and output device 404 .
[0057] The embodiment is basically as shown in the attached Figure 1 Shown: Knowledge distillation method based on multi-stage feature fusion, including:
[0058] S1: Obtain the original data set and preprocess the original data set;
[0059] In this embodiment, the original data set obtained is the CIFAR100 data set, the initial image size of which is 32, and the preprocessing includes random shearing with an image size parameter of 32 and a padding parameter of 4, as well as random horizontal flipping and image normalization.
[0060] S2: Use the original data set to train the teacher network model and obtain the trained teacher network model; in this embodiment, the teacher network models include resnet56, resnet110, resnet32×4, vgg13, WRN-40-2, and ResNet50. In the strategy used to train the teacher network model, BatchSize is 64 and Epoch is 240. The initial learning rate used to train the teacher network model is 0.05, and the gradient learning rate method is used, multiplied by 0.1 in 150, 180 and 210 rounds. The optimizer uses the stochastic gradient descent method, the weight decay is 5e-4, and the momentum is 0.9. Assume that the trained teacher network model is T.
[0061] S3: Freeze the pre-trained weights of the trained teacher network model, use the multi-stage feature fusion framework, the cross-stage feature fusion attention module and the same-stage fusion feature comparison loss function to train the student network model, and generate a trained student network model; among them, the student network models include resnet, VGG, WRN, ShuffleNet and MobileNet. In the parameter settings used to train the student network model, the initial learning rate of ShuffleNet and MobileNet is 0.01, and the initial learning rate used for other models is 0.05. The other parameter settings are the same as those for training the teacher network model. Assume that the trained student network model is S.
[0062] S3 includes:
[0063] S3-1: Freeze the pre-trained weights of the trained teacher network model;
[0064] S3-2: Use the multi-stage feature fusion framework for both the teacher network model and the student network model, and construct the student network feature fusion and the teacher network feature fusion;
[0065] S3-3: Train the student network model through the cross-stage feature fusion attention module;
[0066] S3-4: Construct a feature comparison loss function for the same stage fusion to verify the loss of the student network model trained in S3-3.
[0067] Specifically, first, during the training of the student network model, the pre-trained weights of the teacher network model T obtained by S2 are frozen to ensure that the pre-trained weights of the teacher network model do not change during the training process.
[0068] Secondly, if Figure 2 As shown in Figure 2, in the process of training the student network model, both the teacher network model and the student network model use a multi-stage feature fusion framework to achieve a symmetrical network architecture. Both the teacher network model T and the student network model S include n feature output stages and n corresponding fusion modules FFA. i , i∈n, and the corresponding i-th layer features are T i and S i ;
[0069] Assume that the first fusion module has one input entry, the rest have two input entry, and the last fusion module has one output exit, the rest have two output exits. The fusion output feature of the i-th layer is and
[0070] Construct student network feature fusion and teacher network feature fusion, and the student network feature fusion calculation formula is:
[0071]
[0072] The calculation formula for the teacher network feature fusion is:
[0073]
[0074] Therefore, in this application, the organic fusion of deep features and shallow features is realized through a multi-stage feature fusion framework, and a symmetrical knowledge transfer structure is adopted to realize the effective knowledge transfer between the fusion features of the same stage of the teacher network model and the student network model, which can effectively improve the student network model's ability to learn the beneficial feature knowledge of the teacher network model and its ability to recognize the original images.
[0075] For example Figure 3 As shown, in the cross-stage feature fusion attention module, two different stage features I1 and I 2 , and I 1 and I 2 The size and number of channels are different;
[0076] The input feature I is transformed into 1 The size and number of channels are adjusted to match the input feature I 2 are consistent, and are added together to obtain the preliminary fusion feature I;
[0077] Through the parallel channel attention mechanism Ac and spatial attention mechanism As, the parallel results are added to obtain the fusion feature F;
[0078] Then, through convolution and normalization, two output features F with different sizes and number of channels are generated respectively. 1 and F 2 , and fusion feature module FFA 1 The input feature is only I 1 , fusion feature module FFA n The output feature is only F 1 The expression formula of the cross-stage feature fusion attention module is:
[0079] (F 1 ,F 2 )=As(S(I 1 )+I 2 )+Ac(S(I 1 )+I 2 ).
[0080] Therefore, the cross-stage feature fusion attention module realizes the organic fusion between adjacent features with different sizes and numbers of channels and the effective enhancement of the knowledge of the fused features. The scale of the input features is achieved through the convolutional network, and the features of two different sizes are fused by the residual idea to achieve the fusion of adjacent features. After combining with the multi-stage feature fusion framework, the layer-by-layer transmission of feature knowledge from shallow to deep layers is realized, and the system and method for the student network model to learn knowledge effectively are obtained. In addition, for the fused features, the parallel spatial attention mechanism and channel attention mechanism are used to enhance the fused features, which can further strengthen the organic fusion of the input features, and let the fused features strengthen the spatial information and channel information, further improving the learning ability of the student network model.
[0081] And again Figure 4 As shown in the figure, the feature contrast loss function of the same stage fusion is constructed to verify the loss of the student network model trained by S3-3. Specifically:
[0082] Construct the feature contrast loss function of the same stage fusion;
[0083] The i-th stage fusion features of the teacher network model and the student network model are respectively converted into Corresponding TF i and SF i Follow the preset processing to do L mse Similarity matching; the specific processing according to the preset is: first, no processing is performed, and TF is retained i and SF i ; Second, without changing the feature space size, compression processing is performed on the channel to obtain and The third is to keep the number of channels unchanged and compress the space to get TF. i 2 and SF i 2 , combined with the weight adjustment hyperparameter λ, constitutes the n-stage fusion feature comparison function. The calculation formula of the fusion feature comparison loss function in the same stage is:
[0084] L scm =L mse (TF i ,SF i )+λL mse (TF i 1 ,SF i 1 )+λL mse (TF i 2 ,SF i 2 )
[0085] Among them, L scm represents the feature contrast loss function of the same stage fusion, and λ represents the weight adjustment hyperparameter;
[0086] In addition, the cross entropy loss function of the true label and the student classification result, as well as the weight adjustment hyperparameters, is combined to construct a complete loss function to verify the loss of the student network model; the calculation formula of the complete loss function is:
[0087] L total =L ce +αL scm
[0088] Among them, L total represents the complete loss function, L ce represents the cross entropy loss function, and α represents the weight adjustment hyperparameter corresponding to the complete loss function.
[0089] Therefore, the structure of the spatial and channel contrast loss function corresponds to the spatial and channel attention mechanism of the feature fusion attention module. Using similar learning methods and effect verification methods, the feasibility of the learned knowledge can be effectively tested, and the learning ability of the student network model can be further enhanced and the learning direction of the student network model can be further reduced, thus comprehensively realizing an effective knowledge distillation learning method for the student network model.
[0090] In this regard, this application records the experimental results of the multi-stage feature fusion framework using different stage combinations in Table 1. Here, the fusion module of the student network is basically retained, and only the learning stage of the teacher network is adjusted. Figure 5 As shown, it can be seen that the feature fusion learning framework provided by this experiment is significantly effective compared with other stage-by-stage combinations.
[0091] Table 1 Experimental data under different stage combinations
[0092]
[0093] Then, this application compares the framework and module ablation experiments of the multi-stage feature fusion knowledge distillation method through Table 2. The structural changes are as follows: Figure 6 As shown, MS represents multi-stage direct comparison without using a fusion framework, MSF represents multi-stage direct comparison using a fusion framework, FFA represents the use of a cross-stage fusion feature attention module, and SCM represents the use of the spatial and channel contrast loss function of the same stage. The experiment proves the effectiveness of the framework itself and the combination of modules, which can effectively improve the recognition effect of the student model, and the ablation experiments of the present invention have achieved experimental results of improved accuracy, proving the feasibility of the present invention.
[0094] Table 2 Framework and module ablation experiment data table
[0095]
[0096]
[0097] S4: Run the trained student network model and only keep the student network architecture in the inference stage. In this application, in the inference stage, the teacher network and the multi-stage feature fusion framework are cut off, and only the student network architecture is kept to ensure that the recognition accuracy of the student network is improved without adding additional parameters or changing its own structure. The experimental results in Tables 3 and 4 show that the multi-stage feature fusion knowledge distillation method MSFF of the present invention has a wide range of applications and has achieved competitive accuracy improvement effects on a variety of lightweight network models, allowing the student network to learn a lot of effective knowledge from the teacher network. The experimental results show that the present invention is basically at the same level as CRD and OFD, and slightly lower than the SOTA result of ReviewKD.
[0098] Table 3 Distillation effect of the same type of model on the CIFAR100 dataset
[0099]
[0100] Table 4 Distillation effects of different types of models on the CIFAR100 dataset
[0101]
[0102]
[0103] The following table 5 further verifies the practicality and versatility of the present invention. The experiment recorded in this table is on CIFAR100. When the teacher network is WRN-40-2, different knowledge distillation methods are used to train the student network WRN-40-1, and the obtained different WRN-40-1 models are migrated to the STL-10 and TinyImageNet datasets to check the accuracy. It can be observed from the data in the table that compared with the benchmark accuracy and other knowledge distillation methods, the knowledge distillation method provided by the present invention has achieved valuable accuracy improvement effects, further verifying the effectiveness and generalization of the method.
[0104] Table 5 The effect of the transfer experiment when the teacher and student combination is WRN-40-2 and WRN-40-1
[0105]
[0106] In addition, an electronic device such as Figure 7 As shown, the electronic device 400 includes one or more processors 401 and a memory 402 .
[0107] The processor 401 may be a central processing unit (CPU) or other forms of processing units having data processing capabilities and / or instruction execution capabilities, and may control other components in the electronic device 400 to perform desired functions.
[0108] The memory 402 may include one or more computer program products, which may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may include, for example, random access memory (RAM) and / or cache memory (cache), etc. The 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 processor 401 may run the program instructions to implement the knowledge distillation method based on multi-stage feature fusion and / or other desired functions of any embodiment of the present invention described above. Various contents such as initial external parameters, thresholds, etc. may also be stored in the computer-readable storage medium.
[0109] In one example, the electronic device 400 may further include: an input device 403 and an output device 404, which are interconnected via a bus system and / or other forms of connection mechanisms (not shown). The input device 403 may include, for example, a keyboard, a mouse, etc. The output device 404 may output various information to the outside, including early warning information, braking force, etc. The output device 404 may include, for example, a display, a speaker, a printer, a communication network and a remote output device connected thereto, etc.
[0110] Of course, to simplify, Figure 7 Only some of the components related to the present invention in the electronic device 400 are shown, and components such as a bus, an input / output interface, etc. are omitted. In addition, according to specific application conditions, the electronic device 400 may also include any other appropriate components.
[0111] In addition to the above-mentioned methods and devices, an embodiment of the present invention may also be a computer program product, which includes computer program instructions, which, when executed by a processor, enable the processor to execute the steps of the knowledge distillation method based on multi-stage feature fusion provided by any embodiment of the present invention.
[0112] The computer program product may be written in any combination of one or more programming languages to write program code for performing the operations of the embodiments of the present invention, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0113] In addition, an embodiment of the present invention may also be a computer-readable storage medium having computer program instructions stored thereon, which, when executed by a processor, enables the processor to execute the steps of the knowledge distillation method based on multi-stage feature fusion provided in any embodiment of the present invention.
[0114] The computer readable storage medium can adopt any combination of one or more readable media. The readable medium can be a readable signal medium or a readable storage medium. The readable storage medium can include, for example, but is not limited to, a system, device or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0115] The above are only embodiments of the present invention. Common knowledge such as the known specific structures and characteristics in the scheme is not described in detail here. Ordinary technicians in the relevant field know all the common technical knowledge in the technical field to which the invention belongs before the application date or priority date, can obtain all the existing technologies in the field, and have the ability to apply conventional experimental means before that date. Ordinary technicians in the relevant field can improve and implement this scheme in combination with their own abilities under the enlightenment given by this application. Some typical known structures or known methods should not become obstacles for ordinary technicians in the relevant field to implement this application. It should be pointed out that for those skilled in the art, without departing from the structure of the present invention, several deformations and improvements can be made, which should also be regarded as the scope of protection of the present invention, and these will not affect the effect of the implementation of the present invention and the practicality of the patent. The scope of protection required by this application shall be based on the content of its claims, and the specific implementation methods and other records in the specification can be used to interpret the content of the claims.
Claims
1. A knowledge distillation method based on multi-stage feature fusion, characterized by: include: S1: Obtain an original image dataset and preprocess the original image dataset; S2: Use the original image dataset to train the teacher network model and obtain the trained teacher network model; S3: Freeze the pre-trained weights of the trained teacher network model, train the student network model using the multi-stage feature fusion framework, the cross-stage feature fusion attention module, and the same-stage fusion feature contrast loss function to generate a trained student network model; S4: Run the trained student network model to recognize image data, and only keep the student network architecture in the inference stage; The S3 includes: S3-1: Freeze the pre-trained weights of the trained teacher network model; S3-2: Use the multi-stage feature fusion framework for both the teacher network model and the student network model, and construct the student network feature fusion and the teacher network feature fusion; S3-3: Train the student network model through the cross-stage feature fusion attention module; S3-4: Construct the fusion feature comparison loss function at the same stage to verify the loss of the student network model trained in S3-3; The S3-2 is specifically: Define the teacher network model as T and the student network model as S. Both the teacher network model T and the student network model S include n feature output stages and n corresponding fusion modules FFA i , i∈n, and the corresponding i-th layer features are T i and S i ; Assume that the first fusion module has one input entry, the rest have two input entry, and the last fusion module has one output exit, the rest have two output exits. The fusion output feature of the i-th layer is denoted as F i 1 and F i 2 ; Construct student network feature fusion and teacher network feature fusion, and the student network feature fusion calculation formula is: The calculation formula for the teacher network feature fusion is: The S3-3 is specifically: The cross-stage feature fusion attention module includes two different stage features I1 and I2, and the size and number of channels of I1 and I2 are different; Through convolution and normalization, the size and number of channels of input feature I1 are adjusted to be consistent with input feature I2, and the initial fusion feature I is obtained by adding them together; Through the parallel channel attention mechanism Ac and spatial attention mechanism As, the parallel results are added to obtain the fusion feature F; Then, through convolution and normalization, two output features F with different sizes and number of channels are generated respectively. 1 and F 2 , and the input feature of the fusion feature module FFA1 is only I1, the fusion feature module FFA n The output feature is only F1; The expression formula of the cross-stage feature fusion attention module is: (F 1 ,F 2 )=As(S(I1)+I2)+Ac(S(I1)+I2) The S3-4 is specifically: Construct the feature contrast loss function of the same stage fusion; The i-th stage fusion feature F of the teacher network model and the student network model are respectively converted into i 2 Corresponding TF i and SF i Follow the preset processing to do L mse Similarity matching; Combine the cross entropy loss function of the true label and the student classification result, as well as the weight adjustment hyperparameters, to construct a complete loss function and perform loss verification on the student network model; The processing according to the preset is specifically as follows: No processing, keep TF i and SF i ; Without changing the feature space size, compression is performed on the channel to obtain TF i 1 and SF i 1 ; Without changing the number of channels, we can compress the space to get TF. i 2 and SF i 2 , combined with the weight adjustment hyperparameter λ, constitutes the n-stage fusion feature comparison function; The calculation formula of the feature contrast loss function of the same stage fusion is: L scm =L mse (TF i ,SF i )+λL mse (TF i 1 ,SF i 1 )+λL mse (TF i 2 ,SF i 2 ) Among them, L scm represents the feature contrast loss function of the same stage fusion, and λ represents the weight adjustment hyperparameter; The calculation formula of the complete loss function is: L total =L ce +αL scm Among them, L total represents the complete loss function, L ce represents the cross entropy loss function, and α represents the weight adjustment hyperparameter corresponding to the complete loss function.
2. The knowledge distillation method based on multi-stage feature fusion according to claim 1, characterized in that: Specifically, in S4, only the student network architecture is retained during the inference stage: during the student network model inference stage, the teacher network model and the multi-stage feature fusion framework are cut off, and only the student network architecture part is retained.
3. An electronic device, characterized in that: It includes a processor and a memory, wherein the memory stores programs or instructions, and the processor executes the knowledge distillation method based on multi-stage feature fusion as described in any one of claims 1-2 by calling the programs or instructions stored in the memory.
4. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a program or instruction, which enables a computer to execute the knowledge distillation method based on multi-stage feature fusion as described in any one of claims 1-2 above.
Citation Information
Patent Citations
Image classification method based on double-specialty teacher model knowledge fusion and storage medium
CN112801209A
Neural network training methods, devices, and storage media based on knowledge distillation
CN114936605A
Knowledge distillation-based YOLOv5s lightweight sheep variety identification method and system
CN116052211A
Knowledge distillation method and device for generative adversarial network, equipment and storage medium
CN116383639A
Knowledge distillation-based lightweight remote sensing image semantic segmentation method and device
CN116740344A
