Feature-enhanced collaborative relational knowledge distillation method for skin tumor image classification
Through the methods of feature enhancement, online inter-class sample feature relationship distillation and adaptive distillation, the student network model is directly trained, which solves the problems of computational complexity and storage occupation in skin tumor image classification in the existing technology, and achieves efficient skin tumor image classification. Identify and classify, reducing costs and storage requirements.
Patent Information
- Application Number
- CN202410559104.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-08
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2044-05-08
AI Technical Summary
Existing skin tumor image classification methods rely on deep neural networks with complex calculations and large storage footprints, which are difficult to use effectively in practical applications. Moreover, traditional knowledge distillation methods require pre-training teacher models, which increases training time and computing costs.
A feature-enhanced collaborative relationship knowledge distillation method for skin tumor image classification is proposed. By constructing two student convolutional neural network models, feature enhancement, online inter-class sample feature relationship distillation and adaptive distillation are performed, and the student network model is directly trained. The step of pre-training teachers is avoided.
It saves the time, computing and storage costs of knowledge distillation, improves the effect of skin tumor image recognition and classification, reduces storage space requirements, improves medical standards and relieves the pressure on dermatologists.
Smart Images

Figure CN118350460B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image recognition, and in particular to a feature-enhanced collaborative relationship knowledge distillation method for skin tumor image classification. Background Art
[0002] Skin tumor detection and classification Skin tumors have made significant progress, but the classification of skin tumors is still a difficult task, and the ability to diagnose skin tumors needs to be improved. This is because the distinction of skin tumors includes contrast changes, color, shape, and size of skin tumors, which makes the diagnosis of skin tumors difficult. In addition, existing methods rely on large models that are computationally complex and occupy a lot of storage space, making them difficult to apply in practice. Knowledge distillation can alleviate these problems by developing compact models while maintaining performance.
[0003] In deep learning, deep neural networks consisting of millions of parameters require a lot of computing and storage resources to ensure high performance, which limits their application in real industries. Knowledge distillation alleviates this situation by transferring knowledge from complex, high-performance teacher models to student models with smaller network sizes, improving the performance of smaller student models and applying student models to real devices. The basic principle of knowledge distillation is to use additional supervision from the teacher model during the training of the student model. Compared with the true label, the final prediction output of the teacher network for the sample data contains latent information, and this latent information helps improve the generalization ability of the small model.
[0004] However, traditional knowledge distillation methods require pre-training teachers first, and then the pre-trained teachers guide students to imitate their meaningful knowledge to improve the performance of small models. This method of pre-training teachers takes longer training time and requires additional computational costs.
[0005] To this end, we propose a feature-enhanced collaborative relational knowledge distillation method for skin tumor image classification to solve the above problems. Summary of the invention
[0006] The purpose of this section is to summarize some aspects of embodiments of the present invention and briefly introduce some preferred embodiments. Some simplifications or omissions may be made in this section and the specification abstract and the invention title of this application to avoid blurring the purpose of this section, the specification abstract and the invention title, and such simplifications or omissions cannot be used to limit the scope of the present invention.
[0007] In view of the above problems existing in the prior art, the present invention is proposed.
[0008] In order to solve the above technical problems, the present invention provides the following technical solutions:
[0009] Step 1: Obtain image sample data and label data;
[0010] Step 2: construct a knowledge distillation network model; wherein the knowledge distillation network model includes two student network models, and both student network models adopt convolutional neural networks;
[0011] Step 3: Construct a sample feature extraction module; the preprocessed skin tumor image is input into the convolutional neural network, and the student convolutional neural network outputs the features and logits of the last layer;
[0012] Step 4: Construct enhanced features; enhance the last layer features of each student network;
[0013] Step 5: Construct online inter-class sample feature relationship distillation;
[0014] Step 6: Build adaptive distillation;
[0015] Step 7: Construct the total loss function; the total loss includes the cross entropy loss between the prediction results of all student network models and the real label data, the online inter-class sample feature relationship distillation loss and the adaptive distillation loss;
[0016] Step 8: Train the student network model; that is, use the total loss function calculated in step 7 to train the student network model, and back propagate to update the parameters of the student network model to obtain the trained student network model;
[0017] Step nine: Real-time classification of skin tumor images; obtain real-time skin tumor images, and input the skin tumor images into the student network model, and the student network model outputs the classification results.
[0018] As a preferred solution of the feature-enhanced collaborative relationship knowledge distillation method for skin tumor image classification described in the present invention, in which: during the step one, the acquired skin tumor image sample data is preprocessed, and the preprocessing includes cropping, scaling and rotation.
[0019] As a preferred solution of the feature-enhanced collaborative relationship knowledge distillation method for skin tumor image classification described in the present invention, wherein: in the step three, the preprocessed skin tumor image is input into the convolutional neural network, and the student convolutional neural network outputs the features and logits of the last layer.
[0020] As a preferred solution of the feature-enhanced collaborative relationship knowledge distillation method for skin tumor image classification of the present invention, in which: in the process of step 4, the specific construction process is as follows:
[0021] S1: Aggregate the global context information of each channel from a global perspective;
[0022] Let f be the feature obtained in the last layer of the student network, f = [f 1 , ..., f C ], the subscript represents the current channel, C represents the total number of channels, the global context is aggregated for each channel, and the feature global context information of the cth channel for:
[0023]
[0024] Among them, c represents the current channel, H and W represent the height and width respectively, and a c is a learnable parameter, initialized to 1;
[0025] S2: After aggregating the global context information of each channel, normalization is performed on each channel. Normalization reduces computation and memory consumption and makes the model more stable during training. Normalization of the cth channel for:
[0026]
[0027] Where c represents the current channel, β c is a learnable parameter, initialized to 0;
[0028] S3: The normalized information is combined with the global context information and fused into the initial features to achieve the final feature enhancement. Here, the activation function tanh function is used to combine the normalized information with the global context information. The final enhanced feature f' is:
[0029] f'=f+f·tanh(f g f n +γ c );
[0030] Among them, f g 、f n Represent the global context information and channel normalization information respectively, γ c is a learnable parameter, initialized to 0; if the entire feature enhancement process is represented by F, the final enhanced feature f' can be expressed as:
[0031] f'=F(f).
[0032] As a preferred solution of the feature enhancement collaborative relationship knowledge distillation method for skin tumor image classification of the present invention, wherein: in the step 5, the method for constructing online inter-class sample feature relationship distillation is:
[0033] S1: For input to the student network Samples of different classes are randomly selected from the last layer of features enhanced by each student network, and the feature relationship of randomly selected samples of different classes is calculated in each student network;
[0034] S2: Use the L2 norm to calculate the feature relationship between samples of different classes. Suppose the selected samples of different classes are x i , x j , the feature relationship between samples in the k-th network It can be expressed as:
[0035]
[0036] Among them, S k represents the k-th student network, and F represents the entire feature enhancement operation;
[0037] S3: Use KL divergence to calculate the similarity of feature relationships between different student networks, transfer this feature relationship knowledge to different networks, so that student networks can learn from each other about the feature relationship knowledge of inter-class samples. The total relationship distillation loss of all student networks is L RML for:
[0038]
[0039] Among them, i, j represent the index of the network, L KL The relational distillation loss calculated for KL divergence, Indicates S i The knowledge of the relationship between sample features between classes within the network R i After the softmax function and the result softened by temperature T, the gradient generated by the relational knowledge is 1 / T 2 Scaling,To ensure that the relative contribution of the relation distillation loss remains roughly the same, we use T 2 Scaling the relation distillation loss.
[0040] As a preferred solution of the feature-enhanced collaborative relationship knowledge distillation method for skin tumor image classification of the present invention, wherein: in the step 6, the method for constructing the adaptive distillation is:
[0041] S1: First, calculate the weight of the sum of the losses of each student network and all other student networks distilled from each other. Based on the traditional online mutual distillation, according to the cross entropy loss between the true label and the predicted output of each student network, use the softmax function to assign weights to the distillation loss of each student network between the logits of the student networks. Suppose the total number of online distilled student networks is m, then the weight w of the i-th student network is i Calculated as:
[0042]
[0043] in, is the cross entropy loss calculated by the predicted probability of the i-th student network and the true label, The cross entropy loss calculated to represent the predicted probability and the true label of the j-th student network;
[0044] S2: Calculate the sum of the losses of each student network and all other student networks using KL divergence distillation; where the sum of the losses of the i-th student network and all other student networks using KL divergence distillation for:
[0045]
[0046] in, It represents the result of calculating the predicted value logits of the i-th student network through the softmax function and temperature T. Similarly, the gradient due to soft prediction is 1 / T 2 Scaling, in order to ensure that the relative contribution of distillation loss remains roughly constant, with T 2 Scaling of distillation losses;
[0047] S3: Use the weights calculated in the first step as the hyperparameters for mutual distillation learning between student networks, and adaptively obtain the logits mutual distillation loss. The learning loss L for mutual distillation of all student networks AD for:
[0048]
[0049] Among them, w i is the weight of the ith student network, It is the sum of the losses of the ith student network and all other student networks distilled from each other using KL divergence.
[0050] As a preferred solution of the feature enhancement collaborative relationship knowledge distillation method for skin tumor image classification of the present invention, wherein: in the step 7, the method for constructing the total loss function is:
[0051] The overall loss function includes the cross entropy loss function, the online inter-class sample feature relationship distillation loss function, and the adaptive distillation loss function. The overall loss function of online distillation training is:
[0052] L total =α 3 L CE +β 3 L RML +γ 3 L AD ;
[0053] Among them, L CE is the total cross entropy loss between the prediction results of all student models and the true labels; L RML is the online inter-class sample feature relationship distillation loss, L AD is the adaptive logits distillation loss, α 3 , β 3 , γ 3 L CE , L RML , L AD The hyperparameters are used to balance the cross entropy loss, feature relationship distillation loss and adaptive distillation loss.
[0054] As a preferred solution of the feature-enhanced collaborative relationship knowledge distillation method for skin tumor image classification of the present invention, in which: during the step eight, when updating the parameters of the student network model, the specific method is:
[0055] Use the total loss function in step 7 to train the student network model, back propagate to calculate the gradient, and update the network parameters. The parameters are:
[0056]
[0057] Among them, θ s represents the parameters of the student network model, γ represents the learning rate, Represents the total loss function L total Compute the gradients of the student network parameters.
[0058] The knowledge distillation system for the feature-enhanced collaborative relationship knowledge distillation method for skin tumor image classification mentioned above includes:
[0059] A skin tumor image sample data acquisition module is used to acquire skin tumor image sample data and label data;
[0060] The knowledge distillation network model construction module is used to construct the knowledge distillation network model. The knowledge distillation network model includes two student network models, and both student network models use convolutional neural networks.
[0061] Sample feature extraction module, the preprocessed skin tumor image is input into the convolutional neural network, and the student convolutional neural network outputs the features and logits (prediction values) of the last layer;
[0062] The feature enhancement building module inputs the sample into the student convolutional neural network and enhances the features of the last layer of each student network. Specifically, the feature enhancement is achieved by aggregating the global context information of each channel from a global perspective, using normalization to normalize the channel, and combining the normalized information with the global context information and fusing it into the initial features, thereby enriching the features;
[0063] The online inter-class sample feature relationship distillation construction module randomly selects samples of different classes from the last layer of enhanced features of each student network, uses the L2 norm to calculate the feature relationship between samples of different classes within each student network, and then calculates the similarity of the feature relationship of all student networks through KL divergence to perform mutual distillation of inter-class sample feature relationships between student networks;
[0064] Adaptive distillation building module, based on the cross entropy loss of the true label and the predicted output of the student network, uses the softmax function (normalized exponential function) to assign weights to the distillation loss of each student network in the mutual distillation of the student network logits, based on the classic online distillation. The weight calculated by the softmax function is used as a hyperparameter of the sum of the losses of each student network and all other student networks distilled from each other. The student networks learn the prediction probability knowledge from each other and adaptively obtain the distillation loss;
[0065] The total loss function construction module is used to construct the total loss function, which includes the cross entropy loss function between the prediction results of all student network models and the label data, the online inter-class sample feature relationship distillation loss function and the adaptive distillation loss function of softened logits;
[0066] The student network model training module is used to train the student network model using the total loss function, and back-propagate to update the parameters of the student network model to obtain the trained student network model;
[0067] The skin tumor image real-time classification module is used to obtain real-time skin tumor images and input the skin tumor images into the student network model, and the student network model outputs the classification results.
[0068] Beneficial effects of the present invention:
[0069] 1. The present invention is applied to skin tumor image recognition and classification. It does not require a pre-trained teacher and uses an online student network for training, saving distillation time, computation and storage costs.
[0070] 2. The entire method framework of the present invention is conducive to the overall learning of the model, improving the effect of skin tumor image recognition and classification, while increasing the running speed and requiring less storage space, which is of great significance to improving the current medical level and alleviating the pressure on dermatologists. BRIEF DESCRIPTION OF THE DRAWINGS
[0071] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for describing the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. Among them:
[0072] Figure 1 This is a schematic diagram of the process flow of the feature-enhanced collaborative relationship knowledge distillation method for skin tumor image classification proposed in the present invention. DETAILED DESCRIPTION
[0073] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are described in detail below in conjunction with the accompanying drawings.
[0074] In the following description, many specific details are set forth to facilitate a full understanding of the present invention, but the present invention may also be implemented in other ways different from those described herein, and those skilled in the art may make similar generalizations without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.
[0075] Secondly, the term "one embodiment" or "embodiment" as used herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The term "in one embodiment" that appears in different places in this specification does not necessarily refer to the same embodiment, nor does it refer to a separate or selective embodiment that is mutually exclusive with other embodiments.
[0076] Reference Figure 1 , as an embodiment of the present invention, provides a feature-enhanced collaborative relationship knowledge distillation method for skin tumor image classification, the method comprising the following steps:
[0077] Step 1: Obtain image sample data and label data, and preprocess the acquired skin tumor image sample data, including cropping, scaling and rotation;
[0078] Step 2: construct a knowledge distillation network model; wherein the knowledge distillation network model includes two student network models, and both student network models adopt convolutional neural networks;
[0079] Step 3: Construct a sample feature extraction module; the preprocessed skin tumor image is input into the convolutional neural network, and the student convolutional neural network outputs the features and logits of the last layer; the preprocessed skin tumor image is input into the convolutional neural network, and the student convolutional neural network outputs the features and logits of the last layer;
[0080] Assuming there are m student networks in total, the logits generated by the online trained student network can be expressed as z = [z 1 , z 2 , ..., z m ], pass logits through the softmax layer to get the final prediction probability p = [p 1 , p 2 , ..., p m ], the student S i The generated logits are denoted as z i , z i The predicted probability p is obtained through the softmax layer i , the soft prediction probability of the i-th student network in the c-th class through the softmax layer Calculated as:
[0081]
[0082] Among them, c represents the current class, C represents the total number of classes of image samples, Represents the logit of the i-th student network in class c. T is the hyperparameter temperature. The temperature T is used in knowledge distillation to make the output probability softer and obtain dark knowledge. Dark knowledge is conducive to the distillation learning of convolutional neural networks.
[0083] Step 4: Construct enhanced features; enhance the last layer features of each student network. The specific construction process is as follows:
[0084] S1: Aggregate the global context information of each channel from a global perspective;
[0085] Let f be the feature obtained in the last layer of the student network, f = [f 1 , ..., f C ], the subscript represents the current channel, C represents the total number of channels, the global context is aggregated for each channel, and the feature global context information of the cth channel for:
[0086]
[0087] Among them, c represents the current channel, H and W represent the height and width respectively, and a c is a learnable parameter, initialized to 1;
[0088] S2: After aggregating the global context information of each channel, normalization is performed on each channel. Normalization reduces computation and memory consumption and makes the model more stable during training. Normalization of the cth channel for:
[0089]
[0090] Where c represents the current channel, β c It is a learnable parameter, initialized to 0, and the symbol “-” here means averaging;
[0091] S3: The normalized information is combined with the global context information and fused into the initial features to achieve the final feature enhancement. Here, the activation function tanh function is used to combine the normalized information with the global context information. The final enhanced feature f' is:
[0092] f'=f+f·tanh(f g f n +γ c );
[0093] Among them, f g 、f n Represent the global context information and channel normalization information respectively, γ c is a learnable parameter, initialized to 0; if the entire feature enhancement process is represented by F, the final enhanced feature f' can be expressed as:
[0094] f' = F(f);
[0095] Step 5: Construct online inter-class sample feature relationship distillation. The construction process is:
[0096] S1: For input to the student network Samples of different classes are randomly selected from the last layer of features enhanced by each student network, and the feature relationship of randomly selected samples of different classes is calculated in each student network;
[0097] S2: Use the L2 norm to calculate the feature relationship between samples of different classes. Suppose the selected samples of different classes are x i , x j , the feature relationship between samples in the k-th network It can be expressed as:
[0098]
[0099] Among them, S k represents the k-th student network, and F represents the entire feature enhancement operation;
[0100] S3: Use KL divergence to calculate the similarity of feature relationships between different student networks, transfer this feature relationship knowledge to different networks, so that student networks can learn from each other about the feature relationship knowledge of inter-class samples. The total relationship distillation loss of all student networks is L RML for:
[0101]
[0102] Among them, i, j represent the index of the network, L KL The relational distillation loss calculated for KL divergence, Indicates S i The knowledge of the relationship between sample features between classes within the network R i After the softmax function and the result softened by temperature T, the gradient generated by the relational knowledge is 1 / T 2 Scaling,To ensure that the relative contribution of the relation distillation loss remains roughly the same, we use T 2 Scaling the relation distillation loss; and similar to For example, if the softmax function is represented by σ, then R i It is expressed as:
[0103] Step 6: Build adaptive distillation. The construction process is:
[0104] The method to construct adaptive distillation is:
[0105] S1: First, the weight of the sum of the losses of each student network and all other student networks distilled from each other is calculated. Based on the traditional online mutual distillation, according to the cross entropy loss between the true label and the predicted output of each student network, a softmax function is used to assign weights to the distillation loss of each student network where the logits are distilled from each other between the student networks. The larger the cross entropy loss, the smaller the weight.
[0106] Assume that the total number of student networks for online distillation is m, then the weight of the i-th student network is w i Calculated as:
[0107]
[0108] in, is the cross entropy loss calculated by the predicted probability of the i-th student network and the true label, The cross entropy loss calculated to represent the predicted probability and the true label of the j-th student network;
[0109] S2: Calculate the sum of the losses of each student network and all other student networks using KL divergence distillation; where the sum of the losses of the i-th student network and all other student networks using KL divergence distillation for:
[0110]
[0111] in, It represents the result of calculating the predicted value logits of the i-th student network through the softmax function and temperature T. Similarly, the gradient due to soft prediction is 1 / T 2 Scaling, in order to ensure that the relative contribution of distillation loss remains roughly constant, with T 2 Scaling of distillation losses;
[0112] S3: Use the weights calculated in the first step as the hyperparameters for mutual distillation learning between student networks, and adaptively obtain the logits mutual distillation loss. The learning loss L for mutual distillation of all student networks AD for:
[0113]
[0114] Among them, w i is the weight of the ith student network, It is the sum of the losses of the ith student network and all other student networks distilled from each other using KL divergence.
[0115] Step 7: Construct the total loss function; the total loss includes the cross entropy loss between the prediction results of all student network models and the real label data, the online inter-class sample feature relationship distillation loss and the adaptive distillation loss;
[0116] That is, the construction method is: the overall loss function includes the cross entropy loss function, the online inter-class sample feature relationship distillation loss function and the adaptive distillation loss function. The overall loss function of online distillation training is:
[0117] L total =α 3 L CE +β 3 L RML +γ 3 L AD ;
[0118] Among them, L CE is the total cross entropy loss between the prediction results of all student models and the true labels; L RML is the online inter-class sample feature relationship distillation loss, L AD is the adaptive logits distillation loss; α3 , β 3 , γ 3 L CE , L RML , L AD The hyperparameters are used to balance the cross entropy loss, feature relationship distillation loss and adaptive distillation loss.
[0119] Step 8: Train the student network model; that is, use the total loss function calculated in step 7 to train the student network model, and back propagate to update the parameters of the student network model to obtain the trained student network model. When updating the parameters of the student network model, the specific method is:
[0120] Use the total loss function in step 7 to train the student network model, back propagate to calculate the gradient, and update the network parameters. The parameters are:
[0121]
[0122] Among them, θ s represents the parameters of the student network model, γ represents the learning rate, Represents the total loss function L total Calculate the gradient of the student network parameters;
[0123] Step nine: Real-time classification of skin tumor images; obtain real-time skin tumor images, and input the skin tumor images into the student network model, and the student network model outputs the classification results.
[0124] In addition, the knowledge distillation system applied to the above-mentioned feature-enhanced collaborative relationship knowledge distillation method for skin tumor image classification is characterized in that the system includes:
[0125] A skin tumor image sample data acquisition module is used to acquire skin tumor image sample data and label data;
[0126] The knowledge distillation network model construction module is used to construct the knowledge distillation network model. The knowledge distillation network model includes two student network models, and both student network models use convolutional neural networks.
[0127] Sample feature extraction module, the preprocessed skin tumor image is input into the convolutional neural network, and the student convolutional neural network outputs the features and logits (prediction values) of the last layer;
[0128] The feature enhancement building module inputs the samples into the student convolutional neural network and enhances the features of the last layer of each student network. Specifically, the feature enhancement and enrichment are achieved by aggregating the global context information of each channel from a global perspective, using normalization to normalize the channel, and combining the normalized information with the global context information and fusing it into the initial features.
[0129] The online inter-class sample feature relationship distillation construction module randomly selects samples of different classes from the last layer of enhanced features of each student network, uses the L2 norm to calculate the feature relationship between samples of different classes within each student network, and then calculates the similarity of the feature relationship of all student networks through KL divergence to perform mutual distillation of inter-class sample feature relationships between student networks;
[0130] Adaptive distillation building module, based on the cross entropy loss of the true label and the predicted output of the student network, uses the softmax function (normalized exponential function) to assign weights to the distillation loss of each student network in the mutual distillation of the student network logits, based on the classic online distillation. The weight calculated by the softmax function is used as a hyperparameter of the sum of the losses of each student network and all other student networks distilled from each other. The student networks learn the prediction probability knowledge from each other and adaptively obtain the distillation loss;
[0131] The total loss function construction module is used to construct the total loss function, which includes the cross entropy loss function between the prediction results of all student network models and the label data, the online inter-class sample feature relationship distillation loss function and the adaptive distillation loss function of softened logits;
[0132] The student network model training module is used to train the student network model using the total loss function, and back-propagate to update the parameters of the student network model to obtain the trained student network model;
[0133] The skin tumor image real-time classification module is used to obtain real-time skin tumor images and input the skin tumor images into the student network model, which outputs the classification results.
[0134] In summary, the present invention is applied to skin tumor image recognition and classification, does not require pre-trained teachers, uses online student networks for training, and saves time, calculation and storage costs for distillation. Existing online distillation methods focus on prediction probability knowledge and feature knowledge, ignoring the relationship information hidden in the features, while relationship knowledge contains rich and useful information that feature knowledge does not have. Starting from relationship knowledge, the present invention designs feature enhancement, online inter-class sample feature relationship distillation and adaptive distillation. First, the features are enhanced by focusing on the context of the last layer of features of each student network to enrich the features, and more useful feature relationship information can be obtained by selecting samples from the enhanced features; then, samples of different classes are randomly selected from the last layer of features enhanced by each student network, and the feature relationship of randomly selected samples of different classes is calculated in each student network, the feature relationship similarity of different student networks is calculated, and the inter-class sample feature relationship is mutually distilled between different student networks; finally, on the basis of traditional online mutual distillation, according to the cross entropy loss of each student network, a softmax function is used to assign weights to the sum of the losses of each student and all other student networks mutually distilled. The entire framework is conducive to the overall learning of the model, improving the recognition and classification of skin tumor images, while increasing the running speed and requiring less storage space. It is of great significance to improving the current medical level and alleviating the pressure on dermatologists.
[0135] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present invention, which should all be included in the scope of the claims of the present invention.
Claims
1. Feature-enhanced collaborative relationship knowledge distillation method for skin tumor image classification, characterized by: The method comprises the following steps: Step 1: Obtain image sample data and label data; Step 2: construct a knowledge distillation network model; wherein the knowledge distillation network model includes two student network models, and both student network models adopt convolutional neural networks; Step 3: Construct a sample feature extraction module; the preprocessed skin tumor image is input into the convolutional neural network, and the student convolutional neural network outputs the features and logits of the last layer; Step 4: Construct enhanced features; enhance the last layer features of each student network; Step 5: Construct online inter-class sample feature relationship distillation, the construction method is: S51: For input to the student network Samples of different classes are randomly selected from the last layer of features enhanced by each student network, and the feature relationship of randomly selected samples of different classes is calculated in each student network; S52: Use the L2 norm to calculate the feature relationship between samples of different classes. Suppose the selected samples of different classes are x i , x j, The relationship between sample features between classes within the kth network , which can be expressed as: = in, represents the k-th student network, and F represents the entire feature enhancement operation; S53: Use KL divergence to calculate the similarity of feature relationships of different student networks, transfer this feature relationship knowledge to different networks, so that student networks can learn from each other about the feature relationship knowledge of inter-class samples, and the total relationship distillation loss of all student networks for: ; Among them, i, j represent the index of the network, The relation distillation loss calculated for KL divergence, express Knowledge of inter-class sample feature relationships within the network After the softmax function and the result softened by temperature T, the gradient generated by the relational knowledge is Scaling, in order to ensure that the relative contribution of the relation distillation loss remains roughly the same, Scaling the relation distillation loss; Step 6: Construct adaptive distillation; the construction method is: S61: First, calculate the weight of the sum of the losses of each student network and all other student networks distilled from each other; according to the cross entropy loss between the true label and the predicted output of each student network, use the softmax function to assign weights to the distillation loss of each student network whose logits are distilled from each other between student networks. Suppose the total number of student networks distilled online is m, then the weight of the i-th student network is Calculated as: ; in, is the cross entropy loss calculated by the predicted probability of the i-th student network and the true label, The cross entropy loss calculated to represent the predicted probability and the true label of the j-th student network; S62: Calculate the sum of the losses of each student network and all other student networks using KL divergence distillation; where the sum of the losses of the i-th student network and all other student networks using KL divergence distillation for: = ; in, It represents the result of calculating the predicted value logits of the i-th student network through the softmax function and temperature T. Similarly, the gradient generated by soft prediction is Scaling, in order to ensure that the relative contribution of distillation loss remains roughly constant, Scaling of distillation losses; S63: The weights calculated in the first step above are used as hyperparameters for mutual distillation learning between student networks, and the logits mutual distillation loss is adaptively obtained; the learning loss of all student networks mutual distillation is for: ; in, is the weight of the ith student network, It is the sum of the losses of the i-th student network and all other student networks distilled from each other using KL divergence; Step 7: Construct the total loss function; the total loss includes the cross entropy loss between the prediction results of all student network models and the real label data, the online inter-class sample feature relationship distillation loss and the adaptive distillation loss; Step 8: Train the student network model; that is, use the total loss function calculated in step 7 to train the student network model, and back propagate to update the parameters of the student network model to obtain the trained student network model; Step nine: Real-time classification of skin tumor images; obtain real-time skin tumor images, and input the skin tumor images into the student network model, and the student network model outputs the classification results.
2. The feature-enhanced collaborative relationship knowledge distillation method for skin tumor image classification according to claim 1 is characterized by: In the process of step 1, the acquired skin tumor image sample data is preprocessed, and the preprocessing includes cropping, scaling and rotation.
3. The feature-enhanced collaborative relationship knowledge distillation method for skin tumor image classification according to claim 2 is characterized by: During step three, the preprocessed skin tumor image is input into the convolutional neural network, and the student convolutional neural network outputs the features and logits of the last layer.
4. The feature-enhanced collaborative relationship knowledge distillation method for skin tumor image classification according to claim 3 is characterized by: During step 4, the specific construction process is as follows: S1: Aggregate the global context information of each channel from a global perspective; Let f be the feature obtained in the last layer of the student network, =[ , ..., ], the subscript represents the current channel, C represents the total number of channels, the global context is aggregated for each channel, and the feature global context information of the cth channel for: = ; Among them, c represents the current channel, H and W represent the height and width respectively. is a learnable parameter, initialized to 1; S2: After aggregating the global context information of each channel, normalize each channel. Normalization reduces the computation and memory consumption and makes the model more stable during the training process. Normalization of the cth channel for: = ; Where c represents the current channel, is a learnable parameter, initialized to 0, where the symbol " ” To seek average; S3: The normalized information is combined with the global context information and fused into the initial features to achieve the final feature enhancement. Here, the activation function tanh function is used to combine the normalized information with the global context information. The final enhanced feature is for: fishy ; in, Represent the global context information and channel normalization information respectively, is a learnable parameter, initialized to 0; if the entire feature enhancement process is represented as F, then the final enhanced feature It can be expressed as:
5. The feature-enhanced collaborative relationship knowledge distillation method for skin tumor image classification according to claim 4 is characterized in that: In step 7, the method for constructing the total loss function is: The overall loss function includes the cross entropy loss function, the online inter-class sample feature relationship distillation loss function, and the adaptive distillation loss function; the overall loss function of online distillation training is: ; Among them, among them, is the total cross entropy loss between the predictions of all student models and the true labels; is the online inter-class sample feature relationship distillation loss, is the adaptive logits distillation loss, , , They are , , The hyperparameters are used to balance the cross entropy loss, feature relationship distillation loss and adaptive distillation loss.
6. The feature-enhanced collaborative relationship knowledge distillation method for skin tumor image classification according to claim 5, characterized in that: In the process of step eight, when updating the parameters of the student network model, the specific method is: Use the total loss function in step 7 to train the student network model, back propagate to calculate the gradient, and update the network parameters. The parameters are: = ; in, represents the parameters of the student network model, represents the learning rate, Represents the total loss function Compute the gradients of the student network parameters.
7. The knowledge distillation system according to any one of claims 1 to 6, characterized in that: The system includes: A skin tumor image sample data acquisition module is used to acquire skin tumor image sample data and label data; The knowledge distillation network model construction module is used to construct the knowledge distillation network model. The knowledge distillation network model includes two student network models, and both student network models use convolutional neural networks. Sample feature extraction module, the preprocessed skin tumor image is input into the convolutional neural network, and the student convolutional neural network outputs the features and logits of the last layer; The feature enhancement building module inputs the samples into the student convolutional neural network and enhances the features of the last layer of each student network. The features are enhanced by aggregating the global context information of each channel from a global perspective, normalizing the channels using normalization, and combining the normalized information with the global context information and fusing them into the initial features, thereby enriching the features. The online inter-class sample feature relationship distillation construction module randomly selects samples of different classes from the last layer of enhanced features of each student network, uses the L2 norm to calculate the feature relationship between samples of different classes within each student network, and then calculates the similarity of the feature relationship of all student networks through KL divergence to perform mutual distillation of inter-class sample feature relationships between student networks; Adaptive distillation building module, based on the cross entropy loss of the true label and the predicted output of the student network, uses the softmax function to assign weights to the distillation loss of each student network in the mutual distillation of the student network logits, based on the classic online distillation. The weight calculated by the softmax function is used as the hyperparameter of the sum of the losses of each student network and all other student networks distilled from each other. The student networks learn the prediction probability knowledge from each other and adaptively obtain the distillation loss. The total loss function construction module is used to construct the total loss function, which includes the cross entropy loss function between the prediction results of all student network models and the label data, the online inter-class sample feature relationship distillation loss function and the adaptive distillation loss function of softened logits; The student network model training module is used to train the student network model using the total loss function, and back-propagate to update the parameters of the student network model to obtain the trained student network model; The skin tumor image real-time classification module is used to obtain real-time skin tumor images and input the skin tumor images into the student network model, and the student network model outputs the classification results.
