Domain increment method based on meta learningTechnical Field
The invention relates to the technical field of computers, in particular to a field increment method based on meta learning.
Background
With the rise of deep learning, the object classification method based on the convolutional neural network is rapidly developed, and the recognition accuracy is greatly improved. However, convolutional neural network-based approaches also have drawbacks: when the tested picture data distribution is inconsistent with the training picture data distribution, such as illumination, background, gesture and the like, the accuracy of the model is reduced. Therefore, when new domain data, i.e., data inconsistent with the original training data distribution, appears, it is necessary that the model be able to learn new domain classifications incrementally, i.e., learn new domain knowledge classifications while remembering classifications of old domain data.
At present, the most intuitive field increment learning method is to continue training a model by using data in a new field, but the method often has the condition that the precision cannot meet the requirement: if the training is insufficient, the data accuracy rate for the new field is not high; if training is excessive, the accuracy of the data for the old domain is reduced, and the data are difficult to reconcile. If the old domain data and the new domain data are directly mixed and retrained into the convolutional neural network, the cost of data storage and training time is huge, and particularly, the cost is larger and larger as the new domain data are larger and larger in practice. Therefore, it is particularly important to find a domain increment recognition method that can obtain high-precision performance at low overhead cost.
Disclosure of Invention
In order to solve the problems, the invention provides a field increment method based on meta learning.
The invention adopts the following technical scheme:
a domain increment method based on meta learning comprises the following steps:
s1, constructing a pre-training model: selecting a plurality of public data sets as metadata by using a meta learning method iTAML, constructing a meta task and learning a pre-training model to obtain parameters phi of the pre-training model, wherein the pre-training model is a convolutional neural classification network;
s2, training an old model by using the pre-training model: constructing a classification model of the same type as the pre-training model as an old model, importing parameters phi of the pre-training model into the old model, and guiding old image data D by using a cross entropy loss functionold Training the old model, and randomly sampling and retaining 5% of old image data D after training is finishedold As the memory image data Dmemory ;
S3, training a new model: using the memory image data Dmemory And new image data Dnew Training the old model together in a hybrid manner for new image data Dnew Guiding model learning using cross entropy loss function for memorizing image data Dmemory Model learning is guided jointly by using the cross entropy loss function and the knowledge distillation loss function, thereby obtainingTo the new model.
Further, the convolutional neural classification network is one of VGG, resNet, mobileNet, denseNet or SENet.
Further, in step S1, the training process of the meta learning method iTAML is incremental, T stages are trained altogether, T is the total task number, and T represents the T-th task;
when t=1, the data of task 1 is normally trained by using a cross entropy loss formula, and a pre-training model parameter phi is obtained1 The cross entropy loss formula is as follows:
wherein D ist Representing a data set belonging to a t-th task, a total of N samples, xi One of them, pi Representation model pair xi Predicted value of yi Representing a true tag value;
when t is more than or equal to 2, initializing the parameter to be the trained parameter phi in the previous stagebase =φt-1 Respectively taking out task 1, task 2, … and task t, and taking out t task data to obtain phibase Updating and optimizing the initial parameters by using cross entropy loss to obtain temporary parameters phi of the corresponding tasks1 ,φ2 ,…φt Then update phibase Obtaining the final result parameter phi at this stage when the loss does not dropt =φbase The update phibase The following formula is adopted:
finally, to obtain phiT As parameters of the pre-training model.
Further, in step S3, the model learning is guided by combining the cross entropy loss function and the knowledge distillation loss function, and the formula is as follows: loss=loss_ce+loss_distil, where loss_ce represents cross entropy Loss, loss_distil represents knowledge distillation Loss,
and the solution formula for loss_ce is as follows:
wherein x isi ∈Dmemory ∪Dnew Samples representing memory image data or new image data, N in total, pi Representation model pair xi Predicted value of yi Representing a true tag value;
and the solution formula of loss_distill is as follows:
wherein x isi ∈Dmemory A total of N, q samples representing the memory image datai Is the old model about data xi Predicted value of pi Is a model pair x in trainingi Is a predicted value of (a).
After the technical scheme is adopted, compared with the background technology, the invention has the following advantages:
1. unlike conventional pre-training models using large public data sets, meta-learning pre-training models have the advantage of fast learning new task data, and can train target task data in less time;
2. metadata of the pre-training model does not need to be stored, so that training time is not increased along with the increase of new image data;
3. the new model is trained by adopting 5% of memory image data and new image data which are randomly reserved in a mixed fine tuning mode, and simultaneously, the learning of the new model is guided by adopting a cross entropy loss function and a knowledge distillation loss function in a combined mode, so that the classification knowledge of the data in the new field is learned while the classification knowledge in the old field is remembered, the expenditure of data storage and training time is greatly reduced, and meanwhile, the accuracy of the model after the new field increment is introduced is ensured.
Drawings
FIG. 1 is a schematic flow chart of the method of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the drawings and examples, in order to make the objects, technical solutions and advantages of the present invention more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the invention.
Examples
In the present embodiment, a batch of old image data D is givenold ,Dold Consists of Mobye and gold wool and a new image data Dnew ,Dnew The method consists of a small Huang Che and a Husky, and the aim of the embodiment is to achieve higher accuracy for both new and old image data. As shown in fig. 1, the method of this embodiment is as follows:
s1, constructing a pre-training model: the meta-learning method iTAML is utilized, a plurality of disclosed data sets are selected as metadata, meta-tasks are constructed, a pre-training model is learned, such as selecting an airplane and a bird in the cifar10 data set (task 1), driving a truck and a deer (task 2), and an automobile and a horse (task 3), the classification model structure selects mobilenet v2, and parameters phi of the pre-training model are obtained, the pre-training model is a convolutional neural classification network, and it is pointed out that iTAML is independent of the model, and any convolutional neural classification network such as VGG, resNet, mobileNet, denseNet or SENet can be selected.
In step S1, the training process of the meta learning method iTAML is incremental, T stages are trained altogether, T is the total task number, T represents the T-th task, and in this embodiment, 3 tasks are taken as an example:
when t=1, the data of task 1 is normally trained by using a cross entropy loss formula, and a pre-training model parameter phi is obtained1 The cross entropy loss formula is as follows:
wherein D ist Representing a data set belonging to a t-th task, a total of N samples, xi One of them, pi Representation model pair xi Predicted value of yi Representing a true tag value;
when t is more than or equal to 2, initializing the parameter to be the trained parameter phi in the previous stagebase =φt-1 Respectively taking out task 1, task 2, … and task t, and taking out t task data to obtain phibase Updating and optimizing the initial parameters by using cross entropy loss to obtain temporary parameters phi of the corresponding tasks1 ,φ2 ,…φt Then update phibase Obtaining the final result parameter phi at this stage when the loss does not dropt =φbase The update phibase The following formula is adopted:
finally, to obtain phi3 As parameters of the pre-training model.
S2, training an old model by using the pre-training model: constructing a classification model of the same type as the pre-training model as an old model, importing parameters phi of a feature extraction layer in the pre-training model into the old model, and guiding old image data D by using a cross entropy loss functionold Training the old model, and randomly sampling and retaining 5% of old image data D after training is finishedold As the memory image data Dmemory ;
Through this step, the old model is applied to the old image data Dold The distributed data has better classification accuracy, but for unknown data which is not distributed in accordance with the data, the accuracy cannot be ensured.
S3, training a new model: using the memory image data Dmemory And new image data Dnew Training the old model together in a hybrid manner for new image data Dnew Guiding model learning using cross entropy loss function for memorizing image data Dmemory And using the cross entropy loss function and the knowledge distillation loss function to jointly guide model learning, thereby obtaining a new model.
In the step S3, the integral loss is adopted when the model learning is guided by combining the cross entropy loss function and the knowledge distillation loss function, and the formula is as follows: loss=loss_ce+loss_distil, where loss_ce represents cross entropy Loss, loss_distil represents knowledge distillation Loss,
and the solution formula for loss_ce is as follows:
wherein x isi ∈Dmemory ∪Dnew Samples representing memory image data or new image data, N in total, pi Representation model pair xi Predicted value of yi Representing a true tag value;
and the solution formula of loss_distill is as follows:
wherein x isi ∈Dmemory A total of N, q samples representing the memory image datai Is the old model about data xi Predicted value of pi Is a model pair x in trainingi Is a predicted value of (a).
The new model is trained by adopting 5% of memory image data and new image data which are randomly reserved in a mixed fine tuning mode, and simultaneously, the learning of the new model is guided by adopting a cross entropy loss function and a knowledge distillation loss function in a combined mode, so that the classification knowledge of the old field is remembered, the classification knowledge of the new field data is learned, the expenditure of data storage and training time is greatly reduced, and meanwhile, the accuracy of the model after the new field increment is introduced is ensured.
The present invention is not limited to the above-mentioned embodiments, and any changes or substitutions that can be easily understood by those skilled in the art within the technical scope of the present invention are intended to be included in the scope of the present invention. Therefore, the protection scope of the present invention should be subject to the protection scope of the claims.