An alternating training method based on model fusion

By using an alternating training method that combines model fusion and momentum contrast in the image classification task, the problem of insufficient number of negative samples is solved, the generalization ability and classification performance of the convolutional neural network are improved, and better feature representation learning is achieved.

CN115035337BInactive Publication Date: 2024-09-06JINAN UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210652398.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-08
Publication Date
2024-09-06
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

In image classification tasks, it is difficult for existing technologies to effectively increase the number of negative samples, resulting in limited performance in feature representation learning, especially when the memory library and batch size are limited by GPU memory, resulting in insufficient model generalization capabilities.

Method used

Using an alternating training method based on model fusion, by constructing two convolutional neural classification networks with the same structure and parameters, combined with self-supervised learning and multi-task learning of momentum contrast, attention mechanism and dynamic dictionary are used to increase the number of negative samples. And optimize the model by alternating training stages and fusion training stages.

Benefits of technology

It improves the generalization ability and classification performance of the fused convolutional neural network, enhances the number of negative samples and the stability of feature representation of the model, and improves the performance of the model in classification tasks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115035337B
    Figure CN115035337B
Patent Text Reader

Abstract

The present invention discloses an alternating training method based on model fusion, comprising the following steps: a model fusion step; initialization of the alternating training method; an alternating training step, which includes alternating training of multiple fused convolutional neural network classifiers, and each alternating training of the fused convolutional neural network classifier includes two stages, namely, a learning stage with the aid of auxiliary tasks and a fused convolutional neural network overall training stage. The present invention utilizes the advantages of the model fusion technology combined with the existing momentum contrast self-supervised learning technology, and the fused convolutional neural network classifier increases the number of negative samples during training compared to the existing technology algorithm during alternating training, effectively improving the generalization ability of the model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image processing, and in particular to an alternating training method based on model fusion. Background Art

[0002] Deep learning is taking the core position in the rapidly developing field of machine learning and artificial intelligence, and has achieved outstanding performance in various image classification tasks. In classification tasks, we usually care about the performance indicators of classification tasks, such as precision and accuracy. And through precise parameter adjustment, the model performance is continuously improved. Although we can get a model with better performance indicators by doing this, we may ignore some information that helps us train the classification task in some way. We can add task-related supervision data by introducing related tasks. This method is called learning with auxiliary tasks, which is one of the manifestations of multi-task learning.

[0003] In self-supervised learning, a common method is to use unsupervised learning to let the model learn the high-dimensional feature representation of the data, so that the model can be well applied to downstream tasks. Similarly, with the help of auxiliary task learning, we can introduce related tasks of feature representation, that is, while learning the classification task, we hope that the convolutional neural network can learn a good high-dimensional feature representation of the sample. In this way, the generalization performance of the model can be improved. Usually, an output can be added to the convolutional neural network to specifically learn the feature representation of the sample, and then a multi-task learning loss function can be introduced to train the network. The loss function can be divided into a multi-task loss function with artificially set weights and a self-learning multi-task loss function. However, in feature representation learning, the number of negative samples is an important factor affecting the final performance of the model. We can use the memory bank or different samples in a batch during training as negative samples. For the first method, the rapid change of the model will lead to inconsistent feature representations of the previous and next samples. For the second method, the batch size is limited by the GPU memory. Different from other feature representation learning in multi-task learning, we increase the number of negative samples in feature representation learning by introducing the idea of ​​dynamic dictionary and momentum update of MomentumContrast (MoCo). Summary of the invention

[0004] This patent aims to combine the self-supervised learning technology of momentum contrast with multi-task learning on the basis of model fusion of the first convolutional neural classification network and the second convolutional neural classification network with the same structure and parameters, and provide a training mode, namely, an alternating training method, to improve the generalization ability of the fused convolutional neural network classifier. Without using the alternating training method, the fused convolutional neural network classifier has a stronger classification ability than the original first convolutional neural classification network. When the fused convolutional neural network classifier uses the alternating training method, it can enable the fused convolutional neural network classifier to better complete the training of the classification task and improve the generalization ability of the fused convolutional neural network classifier.

[0005] The purpose of the present invention can be achieved by adopting the following technical solutions:

[0006] An alternating training method based on model fusion, the alternating training method comprising the following steps:

[0007] S1. Construct a first convolutional neural classification network and a second convolutional neural classification network with the same structure and parameters, use the attention mechanism to fuse the models of the first convolutional neural classification network and the second convolutional neural classification network to obtain a fused convolutional neural network classifier, retain the linear classification layer of the first convolutional neural classification network in the fusion process, remove the linear classification layer of the second convolutional neural classification network, and add feature representation linear layers to the first convolutional neural classification network and the second convolutional neural classification network respectively;

[0008] S2, initializing the alternating training method, initializing the training parameters in the alternating training method;

[0009] S3. Perform multiple alternating trainings, each alternating training includes two stages, namely, an auxiliary task learning stage and a fused convolutional neural network overall training stage; the fused convolutional neural network classifier is alternately trained by using the auxiliary task learning stage and the fused convolutional neural network overall training stage to obtain a fused convolutional neural network classifier after alternating training.

[0010] Furthermore, the process of step S1 is as follows:

[0011] Construct two first convolutional neural classification networks and second convolutional neural classification networks with the same structure and parameters, and perform model fusion technology on the first convolutional neural classification network and the second convolutional neural classification network to obtain a fused convolutional neural network classifier. The first convolutional neural classification network is referred to as M in the following. 0 , the second convolutional neural classification network is referred to as M 1 , the fused convolutional neural network classifier is referred to as EM;

[0012] To M 0 and M1 The structure is divided into 0 and M 1 The structure generally includes convolutional layers, pooling layers and linear classification layers. In addition to the linear classification layer, M 0 The structure of is divided into an input convolution layer and several convolution modules. The input convolution layer and the convolution module include a convolution layer and a batch normalization layer. The number of convolution modules is defined as N. conv , M 1 The division of the structure and M 0 Same, M 0 and M 1 The convolution module of is used to form the convolution module of EM;

[0013] Through model fusion technology, M 0 and M 1 The feature map output of each convolution module of EM is fused using the attention mechanism. The i-th convolution module of EM consists of M 0 The i-th convolutional module and M 1 The i-th convolutional module is composed of, where i = 1, 2, ..., N conv , the input of the i-th convolutional module of EM is defined as inp i , the output is defined as oup i , the output of the jth convolutional module of EM is used as the input of the j+1th convolutional module of EM, where j = 1, 2, ..., N conv -1, calculate oup by the following formula i :

[0014]

[0015] Among them, λ is the hyperparameter of the attention mechanism, and M 0 The forward propagation function of the i-th convolution module and M 1 The forward propagation function of the i-th convolution module;

[0016] The linear classification layer of EM retains M 0 The linear classification layer of M 1 The linear classification layer in EM is 0 and M 1 Add a feature representation linear layer R respectively 0 and R 1 , in preparation for the learning phase with the help of auxiliary tasks. At the same time, due to the back propagation principle of the model, M 1 The input convolutional layer parameters are similar to M 0 The input convolutional layer parameters take the form of parameter sharing.

[0017] Furthermore, the process of step S2 is as follows:

[0018] Initialize the number of alternating trainings of EM N Al ;

[0019] Initialize the counter n in the alternating training, set n = 0, and perform the auxiliary task learning phase with an epoch of iterations or the fused convolutional neural network overall training phase with an epoch of iterations, set n = n + 1. The counter is used to determine whether the auxiliary task learning phase and the fused convolutional neural network overall training phase are alternated and whether the alternating training of EM is completed;

[0020] Initialize the number of epochs of the auxiliary task learning phase in each EM alternating training as P, and the number of epochs of the overall training phase of the fused convolutional neural network as T;

[0021] Initialize the dynamic dictionary D y , where y = 0 and the dynamic dictionary is updated once, y = y + 1, y represents the yth dynamic update number, due to the auxiliary task learning stage M 1 The parameters change slowly, which makes the feature representations in the dynamic dictionary change slowly, so the size of the dynamic dictionary is P times the total number of samples in the data set.

[0022] Furthermore, in step S3, the training adopts a batch training scheme, the batch size is defined as BS, and the input data of each training is defined as I BS , to I BS Perform two different data enhancements to obtain two data enhancements for this batch and Iterate the auxiliary task learning phase for P epochs, iterate the overall training phase of the fused convolutional neural network for T epochs, and then iterate in sequence until the number of EM alternating training reaches N. Al ,The fusion model shows better generalization performance by alternating the auxiliary task learning phase and the overall training phase of the fused convolutional neural network.

[0023] Furthermore, the forward propagation process of the auxiliary task learning stage is as follows:

[0024] The input in one batch is two data augmented data and The output is the classification prediction result pred classification , positive sample feature representation And positive sample feature representation In the auxiliary task learning phase, M 0The parameters are set to have a gradient, and M 1 The parameters are set to have no gradient, so that M 0 The parameters of M are updated according to back propagation, and 1 The parameters of M 0 The parameters are updated, which makes the feature representation in the dynamic dictionary change slowly;

[0025] Will Input to EM, through forward propagation from EM's linear classification layer and M 0 The feature representation of the linear layer R 0 Get the classification prediction result pred classification And positive sample feature representation

[0026]

[0027]

[0028]

[0029] Among them, f EM (·) is N of EM conv The forward propagation function of the convolution module, is the Nth conv The output of the convolutional module, f EM,Linear (·) is the forward propagation function of the linear classification layer of EM, M 0 The feature representation of the linear layer R 0 The forward propagation function of

[0030] Will Input to M 1 In the forward propagation from M 1 The feature representation of the linear layer R 1 Get the positive sample feature representation

[0031]

[0032] in, M 1 N conv The forward propagation function of the convolution module, M 1 The feature representation of the linear layer R 1 The forward propagation function of .

[0033] Furthermore, the back propagation process of the auxiliary task learning stage is as follows:

[0034] Through the current dynamic dictionary Dy , positive sample feature representation and Calculate the loss function L of the auxiliary task auxiliary , the loss function L auxiliary For InfoNCE:

[0035]

[0036] Where τ is the temperature hyperparameter, is the dynamic dictionary size, D y,q D is a dynamic dictionary y The qth negative sample feature representation is obtained by optimizing InfoNCE. The optimal effect after EM training is that when the input is two pictures obtained by two different data augmentations of the same picture, the distance between the two feature representations obtained by inputting the two pictures into EM is the smallest, and when the input is two different pictures, the distance between the two feature representations obtained by inputting the two pictures into EM is the largest.

[0037] Prediction results by classification classification And label information to calculate the classification loss function L classification , the loss function L classification is the cross entropy loss function, and the loss function L of the auxiliary task is auxiliary And the classification loss function L classification Fusion into multi-task learning loss function L MTL :

[0038] L MTL =γ c ×L classification +γ a ×L auxiliary

[0039] Among them, γ c and γ a L classification and L auxiliary The weight of the multi-task learning loss function is adjusted by γ c and γ a This makes EM's learning tendency towards different tasks different during the learning process;

[0040] Through multi-task learning loss function L MTL To M 0 Perform back propagation to update M 0 The parameter θ 0 , M 1 The parameter θ 1 Updated by momentum following, the update formula is as follows, m is the momentum factor:

[0041] θ 1=m×θ 1 +(1-m)×θ 0 .

[0042] Furthermore, the dynamic dictionary updating process in the auxiliary task learning phase is as follows:

[0043] Remove the initial negative sample feature representation and convert M 1 The generated positive sample feature representation R 1 + Add to the current dynamic dictionary D y In the above example, a dynamic dictionary D is generated. y+1 , due to M 1 The parameter θ 1 Updated by momentum following, the dynamic dictionary D y The feature representation in changes slowly, thus ensuring the optimization effect of InfoNCE in the auxiliary task learning stage.

[0044] Furthermore, the forward propagation process of the overall training phase of the fused convolutional neural network is as follows:

[0045] The input in one batch is two data augmented data and The output is the classification prediction result pred classification And positive sample feature representation In the overall training phase of the fused convolutional neural network, M 0 Parameters and M 1 The parameters of M are set to have gradients, which is convenient for 0 Parameters and M 1 The parameters of are updated by back propagation;

[0046] Will Input into EM, and obtain the classification prediction result pred from the linear classification layer of EM through forward propagation classification :

[0047]

[0048]

[0049] Among them, f EM (·) is N of EM conv The forward propagation function of the convolution module, is the Nth conv The output of the convolutional module, f EM,Linear (·) is the forward propagation function of the linear classification layer of EM;

[0050] Will Input to M through forward propagation1 The feature representation of the linear layer R 1 Get the positive sample feature representation

[0051]

[0052] in, M 1 N conv The forward propagation function of the convolution module, M 1 The feature representation of the linear layer R 1 The forward propagation function of .

[0053] Furthermore, the back propagation process of the overall training phase of the fused convolutional neural network is as follows:

[0054] Prediction results by classification classification And label information to calculate the classification loss function L classification , back-propagate EM to update M 0 The parameter θ 0 and M 1 The parameter θ 1 , which effectively improves the classification performance of EM.

[0055] Furthermore, the dynamic dictionary update process of the fused convolutional neural network overall training phase is as follows:

[0056] Remove the initial negative sample feature representation and convert M 1 The generated positive sample feature representation Add to the current dynamic dictionary D y In the above example, a dynamic dictionary D is generated. y+1 Although the dynamic dictionary D is not used in the overall training phase of the fused convolutional neural network y , However, keeping the dynamic dictionary updated can keep the changes between two adjacent feature representations of the dynamic dictionary small, preparing for the learning stage with the help of auxiliary tasks.

[0057] Compared with the prior art, the present invention has the following advantages and effects:

[0058] The present invention constructs two M with the same structure and parameters. 0 and M 1, forming EM through the attention mechanism. While performing the classification task, EM learns a good sample feature representation. In the learning phase with the help of auxiliary tasks in alternating training, the distance between EM positive samples and negative samples is maximized. In the overall training phase of the fused convolutional neural network in alternating training, the dynamic dictionary is kept updated. Through multiple alternating trainings, the number of negative samples is increased during the fusion model training, and the classification performance can be improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0059] Figure 1 It is a process step diagram of an alternating training method based on model fusion disclosed by the present invention;

[0060] Figure 2 It is a network structure diagram of EM169 of the fusion model step in a specific implementation of an alternating training method based on model fusion disclosed by the present invention;

[0061] Figure 3 It is a flow chart of the learning phase with the aid of auxiliary tasks in an alternating training method based on model fusion disclosed in the present invention;

[0062] Figure 4 It is a process step diagram of the overall training phase of a fused convolutional neural network in an alternating training method based on model fusion disclosed by the present invention. DETAILED DESCRIPTION

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

[0064] Example 1

[0065] As attached Figure 1 As shown, this embodiment discloses an alternating training method based on model fusion. This embodiment will use the COVID-CT dataset as experimental data, with the goal of training a classifier that can accurately classify COVID-19 and NonCOVID-19 at the same time.

[0066] The experimental environment of the embodiment is as follows: the server processor is 32 Intel (R) Xeon (R) CPU E5-2620v4 @ 2.10GHz, 8GB running memory (RAM), NVIDIA Tesla P4 GPU, PyTorch framework.

[0067] The present embodiment discloses an alternating training method based on model fusion, comprising the following steps:

[0068] T1. Model fusion step: The convolutional neural network classification network uses DenseNet169, and two first DenseNet169 and second DenseNet169 with the same structure and parameters are constructed. The first DenseNet169 and the second DenseNet169 are subjected to model fusion technology to obtain a fused convolutional neural network classifier. The first DenseNet169 is referred to as M in the following. 0 , the second DenseNet169 is referred to as M 1 , the fused convolutional neural network classifier is referred to as EM169. According to the pytorch framework code, the structure of DenseNet169 is as follows: input convolution layer, DenseBlock c +Transition c , Relu activation function, torch.nn.functional.adaptive_avg_pool2d, Flatten layer, linear classification layer. Among them, c = 0, 1, 2, 3. The input convolution layer of DenseNet169 includes convolution layer, batch normalization layer, Relu activation function and maximum pooling layer. The convolution kernel size of the input convolution layer of DenseNet169 is 7, and the stride is 2. The maximum pooling layer kernel size of the input convolution layer of DenseNet169 is 3, and the stride is 2;

[0069] In addition to the linear classification layer, each DenseBlock in DenseNet169 c And each Transition c , defined as a convolutional module, where c = 0, 1, 2, 3. 0 For example, there are 8 convolution modules in total. 1 For example, there are 8 convolution modules in total;

[0070] M 0 and M 1 The feature map output of each convolution module of EM169 is fused using the attention mechanism. 0 The i-th convolutional module and M 1 The i-th convolutional module of EM169 is composed of 8 convolutional modules, where i = 1, 2, ..., 7, 8. For EM169, there are 8 convolutional modules in total. The input of the i-th convolutional module of EM169 is defined as inp i , the output is defined as oup iThe output of the jth convolution module of EM169 is used as the input of the j+1th convolution module of EM169, where j = 1, 2, ..., 6, 7. oup is calculated by the following formula i :

[0071]

[0072] Among them, λ is the hyperparameter of the attention mechanism. and M 0 The forward propagation function of the i-th convolution module and M 1 The forward propagation function of the i-th convolution module;

[0073] The linear classification layer of EM169 retains M 0 The linear classification layer of M 1 The linear classification layer of EM169 has an input of the output of the 8th convolutional module of EM169;

[0074] In EM169, for M 0 and M 1 Add a feature representation linear layer R respectively 0 and R 1 , in preparation for the learning phase with the help of auxiliary tasks, the feature representation linear layer R 0 and R 1 The output dimension is 128.

[0075] M 1 The input convolutional layer parameters are similar to M 0 The input convolutional layer parameters are shared. Finally, the network structure of EM169 is as follows: Figure 2 As shown;

[0076] T2, initialization of the alternating training method, the details are as follows:

[0077] T21, initialize the total number of iterations of EM169 to 100;

[0078] T22, initialize the alternating training method counter n, set n = 0, perform the auxiliary task learning phase with each iteration epoch or perform the fusion convolutional neural network overall training phase with each iteration epoch, set n = n + 1;

[0079] T23, initialize the number of iterations of the auxiliary task learning phase in each EM169 alternating training to P, the number of iterations of the overall training phase of the fused convolutional neural network to T = 1, and the number of alternating training is

[0080] T24. Initialize dynamic dictionary D y , where y=0 and each time the dynamic dictionary is updated, y=y+1. The size of the dynamic dictionary is P times the number of samples in the dataset.

[0081] T3, alternating training steps, training adopts batch training scheme, the batch size is defined as BS, and the input data of each training is defined as I BS , to I BS Perform two different data enhancements to obtain two enhanced data in one batch and The alternating training steps defined in S3 are performed in N Al The alternating training is repeated for P epochs, and each alternating training consists of two stages: the auxiliary task learning stage and the fused convolutional neural network overall training stage. The alternating training steps are as follows: iterate the auxiliary task learning stage for P epochs, iterate the fused convolutional neural network overall training stage for T epochs, and repeat until the number of alternating trainings of EM169 reaches N. Al , the details of the alternating training steps are as follows:

[0082] With the help of auxiliary tasks, the flow chart of the learning phase is as follows Figure 3 As shown, the input in one batch is two data augmented data and The output is the classification prediction result pred classification , positive sample feature representation And positive sample feature representation This stage M 0 The parameters are set to have a gradient, and M 1 The parameters of are set to have no gradient. Classification prediction result pred classification The dimension is (BS,2). Positive sample feature representation And the positive sample feature representation R 1 + The dimension is (BS, 128). The details of the learning stages with the help of auxiliary tasks are T31, T32, T33, T34 and T35;

[0083] T31, will Input to EM169, through forward propagation from the linear classification layer of EM169 and M 0 The feature representation of the linear layer R 0 Get the classification prediction result pred classification And positive sample feature representation

[0084]

[0085] predclassification =f EM169,Linear (oup 8 )

[0086]

[0087] Among them, f EM169 (·) is the forward propagation function of the 8 convolution modules of EM169, oup 8 is the output of the 8th convolutional module of EM169, f EM169,Linear (·) is the forward propagation function of the linear classification layer of EM169, M 0 The feature representation of the linear layer R 0 The forward propagation function of

[0088] T32, Input to M 1 In the forward propagation from M 1 The feature representation of the linear layer R 1 Get the positive sample feature representation

[0089]

[0090] in, M 1 The forward propagation function of the 8th convolution module is: M 1 The feature representation of the linear layer R 1 The forward propagation function of

[0091] T33, through the current dynamic dictionary D y , positive sample feature representation and Calculate the loss L of the auxiliary task auxiliary , the loss function is InfoNCE:

[0092]

[0093] Among them, τ is the temperature hyperparameter, which is set to 0.07 in this experiment. is the dynamic dictionary size, D y,q D is a dynamic dictionary y The qth negative sample feature representation;

[0094] Prediction results by classification classification And label information to calculate the classification loss function L classification , the loss function is the cross entropy loss function, and the loss function L of the auxiliary task is auxiliary And the classification loss function L classificationFusion into multi-task learning loss function L MTL :

[0095] L MTL =γ c ×L classification +γ a ×L auxiliary

[0096] Among them, γ c and γ a L classification and L auxiliary The weights of the multi-task learning loss function;

[0097] T34. Learning loss function L through multi-task MTL To M 0 Perform back propagation to update M 0 The parameter θ 0 , M 1 The parameter θ 1 Update by momentum following (m is the momentum factor):

[0098] θ 1 =m×θ 1 +(1-m)×θ 0

[0099] T35. For the current dynamic dictionary D y Update: Remove the initial negative sample feature representation and add M 1 The generated positive sample feature representation R 1 + Add to the current dynamic dictionary D y In the above example, a dynamic dictionary D is generated. y+1 ;

[0100] T36, the input of a batch in the overall training phase of the fused convolutional neural network is two data augmented data and The output is the classification prediction result pred classification And positive sample feature representation This stage M 0 Parameters and M 1 The parameters of are all set to have gradients. The details of the auxiliary task learning stages are T38, T39, T310 and T311;

[0101] T37, will Input into EM169, and obtain the classification prediction result pred from the linear classification layer of EM169 through forward propagation classification :

[0102]

[0103] pred classification =f EM169,Linear (oup 8 )

[0104] Among them, f EM169 (·) is the forward propagation function of the 8 convolution modules of EM169, oup 8 is the output of the 8th convolutional module of EM169, f EM169,Linear (·) is the forward propagation function of the linear classification layer of EM169;

[0105] T38, predict the result through classification pred classification And label information to calculate the classification loss function L classification , back propagate EM to update the parameters θ 0 and θ 1 ;

[0106] T39, for Will Input to M 1 In the forward propagation from M 1 The feature representation of the linear layer R 1 Get the positive sample feature representation

[0107]

[0108] T310, for the current dynamic dictionary D y Update: Remove the initial negative sample feature representation and add M 1 The generated positive sample feature representation Add to the current dynamic dictionary D y In the above example, a dynamic dictionary D is generated. y+1 .

[0109] In this example, M 0 and M 1 The optimizer is Adam optimizer, the learning rate is 0.0001, the exponential decay rate of the first-order moment estimate of Adam optimizer is 0.9, the exponential decay rate of the second-order moment estimate is 0.999, the batch size BS is 16, and the learning rate strategy adopts pytorch's torch.optim.lr_scheduler.CosineAnnealingLR, T_max=10. γ c =1. a The hyperparameters λ and γ of the attention mechanism are used for experiments. aThe values ​​are 0.01, 0.1, 0.2, 0.3, 0.4, 0.5 and 0.6 respectively, the hyperparameter λ of the attention mechanism is 0.5, 0.6, 0.7, 0.8, 0.9, 0.95 respectively, and the number of iterations P in the auxiliary task learning phase is 1, 2, 3, 4, 5, 6, 7 respectively, for comparative experiments;

[0110] In this example, the evaluation indicators of the fused convolutional neural network classifier used include precision, recall, F1 score, accuracy, and AUC. The calculation method is as follows:

[0111]

[0112]

[0113]

[0114]

[0115] Among them, FP is the number of samples whose labels are positive samples and predicted to be positive samples, FN is the number of samples whose labels are positive samples and predicted to be negative samples, TN is the number of samples whose labels are negative samples and predicted to be negative samples, FP is the number of samples whose labels are negative samples and predicted to be positive samples, and AUC is the area under the receiver operating characteristic curve.

[0116] Example 2

[0117] Based on the alternating training method based on model fusion disclosed in Example 1, this example uses the alternating training method disclosed in the present invention on the COVID-CT test set to compare the changes in various evaluation indicators when the alternating training method is not used.

[0118] Table 1 shows the experimental results of VEM169 using the alternating training method on the COVID-CT test set and the changes in various evaluation indicators when EM169 uses the alternating training method and does not use the alternating training method:

[0119] Table 1. Experimental results and improvement comparison table of EM169 using alternating training method

[0120]

[0121] When the hyperparameter λ of the attention mechanism is different, the experimental results are as follows: the number of iterations P of the auxiliary task learning phase is 1, 2, 3, 4, 5, 6, 7 and the loss function L of the auxiliary task are respectively auxiliary The weight of γ aThe best results were obtained from multiple sets of experiments with values ​​of 0.01, 0.1, 0.2, 0.3, 0.4, 0.5 and 0.6. The results showed that the generalization performance of the model was improved after EM169 used the alternating training method.

[0122] In summary, this embodiment utilizes model fusion technology and combines the advantages of momentum contrast self-supervised learning technology to optimize the overfitting problem of convolutional neural network classifiers on small data sets, and obtains good experimental results on the COVID-CT data set. The alternating training method enables the fused convolutional neural network classifier to effectively increase the number of negative samples during the training process, and ultimately improves the classification performance of the fused convolutional neural network classifier. The hyperparameter λ of the attention mechanism affects the performance of the fused convolutional neural network classifier, and the factors that affect the alternating training method are mainly the number of iterations P and L in the auxiliary task learning phase. auxiliary The weight γ in the multi-task learning loss function a In this embodiment, as shown in Table 1, the alternating training method improves the classification performance of the fused convolutional neural network classifier.

[0123] The above embodiments are preferred implementation modes of the present invention, but the implementation modes of the present invention are not limited to the above embodiments. Any other changes, modifications, substitutions, combinations, and simplifications that do not deviate from the spirit and principles of the present invention should be equivalent replacement methods and are included in the protection scope of the present invention.

Claims

1. An alternating training method based on model fusion, characterized in that: The alternating training method comprises the following steps: S1. Construct a first convolutional neural classification network and a second convolutional neural classification network with the same structure and parameters, use the attention mechanism to fuse the models of the first convolutional neural classification network and the second convolutional neural classification network to obtain a fused convolutional neural network classifier, retain the linear classification layer of the first convolutional neural classification network in the fusion process, remove the linear classification layer of the second convolutional neural classification network, and add feature representation linear layers to the first convolutional neural classification network and the second convolutional neural classification network respectively; S2, initializing the alternating training method, initializing the training parameters in the alternating training method; S3, performing multiple alternating trainings, each alternating training includes two stages, namely, an auxiliary task learning stage and a fused convolutional neural network overall training stage; the fused convolutional neural network classifier is alternately trained by using the auxiliary task learning stage and the fused convolutional neural network overall training stage to obtain a fused convolutional neural network classifier after alternating training, and the fused convolutional neural network classifier is used for image classification; The process of step S1 is as follows: Constructing a first convolutional neural classification network and a second convolutional neural classification network with the same structure and parameters, performing model fusion technology on the first convolutional neural classification network and the second convolutional neural classification network to obtain a fused convolutional neural network classifier, hereinafter referred to as the first convolutional neural classification network M0, the second convolutional neural classification network M1, and the fused convolutional neural network classifier EM; The M0 and M1 structures are divided. The M0 and M1 structures include convolutional layers, pooling layers, and linear classification layers. In addition to the linear classification layer, the M0 structure is divided into an input convolutional layer and several convolutional modules. The input convolutional layer and the convolutional module include convolutional layers and batch normalization layers. The number of convolutional modules is defined as N. conv , the division of the structure of M1 is the same as that of M0; The feature map output of each convolution module of M0 and M1 is fused using the attention mechanism through the model fusion technology. The i-th convolution module of EM is composed of the i-th convolution module of M0 and the i-th convolution module of M1, where i = 1, 2, ..., N conv , the input of the i-th convolutional module of EM is defined as inp i , the output is defined as oup i , the output of the jth convolutional module of EM is used as the input of the j+1th convolutional module of EM, where j = 1, 2, ..., N conv -1, calculate oup by the following formula i : oup i =λ×f M0 (inp i )+(1-λ)×f M1 (inp i ) Among them, λ is the hyperparameter of the attention mechanism, f M0,i (·) and f M1,i (·) are the forward propagation functions of the i-th convolutional module of M0 and the i-th convolutional module of M1, respectively; The linear classification layer of EM retains the linear classification layer of M0 and removes the linear classification layer of M1. In EM, a feature representation linear layer R0 and R1 are added to M0 and M1 respectively. At the same time, the input convolution layer parameters of M1 and the input convolution layer parameters of M0 are shared.

2. The alternating training method based on model fusion according to claim 1, characterized in that: The process of step S2 is as follows: Initialize the number of alternating trainings of EM N Al ; Initialize the counter n in alternating training, set n = 0, and perform the auxiliary task learning phase with each epoch of iteration or the overall training phase of the fused convolutional neural network with each epoch of iteration, set n = n + 1; Initialize the number of epochs of the auxiliary task learning phase in each EM alternating training as P, and the number of epochs of the overall training phase of the fused convolutional neural network as T; Initialize the dynamic dictionary D y , where y=0 and the dynamic dictionary is updated once, y=y+1, y represents the yth dynamic update number, and the size of the dynamic dictionary is P times the total number of samples in the data set.

3. The alternating training method based on model fusion according to claim 1 or 2, characterized in that: In step S3, the training adopts a batch training scheme, the batch size is defined as BS, and the input data of each training is defined as I BS , to I BS Perform two different data enhancements to obtain two data enhancements for this batch and Iterate the auxiliary task learning phase for P epochs, iterate the overall training phase of the fused convolutional neural network for T epochs, and then iterate in sequence until the number of EM alternating training reaches N. Al .

4. The alternating training method based on model fusion according to claim 3, characterized in that: The forward propagation process of the auxiliary task learning phase is as follows: The input in one batch is two data augmented data and The output is the classification prediction result pred classification , positive sample feature representation And positive sample feature representation In the auxiliary task learning phase, the parameters of M0 are set to have gradients, while the parameters of M1 are set to have no gradients; Will Input into EM, and obtain the classification prediction result pred from the linear classification layer of EM and the feature representation linear layer R0 of M0 through forward propagation. classification And positive sample feature representation Among them, f EM (·) is N of EM conv The forward propagation function of the convolution module, is the Nth conv The output of the convolutional module, f EM,Linear (·) is the forward propagation function of the linear classification layer of EM, The feature representation of M0 is the forward propagation function of the linear layer R0; Will Input into M1, and obtain the positive sample feature representation from the feature representation linear layer R1 of M1 through forward propagation in, N is M1 conv The forward propagation function of the convolution module, The feature representation of M1 is the forward propagation function of the linear layer R1.

5. The alternating training method based on model fusion according to claim 3, characterized in that: The back propagation process of the auxiliary task learning phase is as follows: Through the current dynamic dictionary D y , positive sample feature representation and Calculate the loss function L of the auxiliary task auxiliary , the loss function L auxiliary For InfoNCE: Where τ is the temperature hyperparameter, is the dynamic dictionary size, D y,q D is a dynamic dictionary y The qth negative sample feature representation; Prediction results by classification classification And label information to calculate the classification loss function L classification , the loss function L classification is the cross entropy loss function, and the loss function L of the auxiliary task is auxiliary And the classification loss function L classification Fusion into multi-task learning loss function L MTL : L MTL =c c ×L classification +g a ×L auxiliary Among them, γ c and γ a L classification and L auxiliary The weights of the multi-task learning loss function; Through multi-task learning loss function L MTL Back propagation is performed on M0 to update the parameters θ0 of M0, and the parameters θ1 of M1 are updated through momentum following. The update formula is as follows, where m is the momentum factor: θ1=m×θ1+(1-m)×θ0.

6. The alternating training method based on model fusion according to claim 3, characterized in that: The dynamic dictionary updating process in the auxiliary task learning phase is as follows: Remove the initial negative sample feature representation and represent the positive sample feature generated by M1 in a batch Add to the current dynamic dictionary D y In the above example, a dynamic dictionary D is generated. y+1 .

7. The alternating training method based on model fusion according to claim 3, characterized in that: The forward propagation process of the overall training phase of the fused convolutional neural network is as follows: The input in one batch is two data augmented data and The output is the classification prediction result pred classification And positive sample feature representation In the overall training phase of the fused convolutional neural network, the parameters of M0 and M1 are both set to have gradients; Will Input into EM, and obtain the classification prediction result pred from the linear classification layer of EM through forward propagation classification : Among them, f EM (·) is N of EM conv The forward propagation function of the convolution module, is the Nth conv The output of the convolutional module, f EM,Linear (·) is the forward propagation function of the linear classification layer of EM; Will Input into M1, and obtain the positive sample feature representation from the feature representation linear layer R1 of M1 through forward propagation in, N is M1 conv The forward propagation function of the convolution module, The feature representation of M1 is the forward propagation function of the linear layer R1.

8. The alternating training method based on model fusion according to claim 3, characterized in that: The back propagation process of the overall training phase of the fused convolutional neural network is as follows: Prediction results by classification classification And label information to calculate the classification loss function L classification , back-propagate EM to update the parameters θ0 of M0 and the parameters θ1 of M1.

9. The alternating training method based on model fusion according to claim 3, characterized in that: The dynamic dictionary update process of the overall training phase of the fused convolutional neural network is as follows: Remove the initial negative sample feature representation and represent the positive sample feature generated by M1 in a batch Add to the current dynamic dictionary D y In the above example, a dynamic dictionary D is generated. y+1 .