Machine learning based continuous learning method and apparatus
By combining sample generation and replay with distillation learning, a teacher model is constructed to train the student model, which solves the problem of catastrophic forgetting when the machine learning model learns new tasks and improves learning efficiency and robustness.
Patent Information
- Application Number
- CN202210161710.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-22
- Publication Date
- 2025-10-21
- Estimated Expiration
- 2042-02-22
AI Technical Summary
Existing machine learning models are unable to retain and accumulate old knowledge when learning new tasks, resulting in catastrophic forgetting and failing to demonstrate good robustness and learning efficiency in complex scenarios.
A method combining sample generation and replay with distillation learning is adopted. A teacher model is constructed through a generator, feature extractor and classifier. The teacher model is used to distill and generate samples and train the student model. Combined with the global class center feature constraint, catastrophic forgetting is alleviated.
It improves the continuous learning ability of machine learning models in complex scenarios, reduces model forgetting, and improves learning efficiency and robustness.
Smart Images

Figure CN114722892B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a continuous learning method and device based on machine learning. Background Art
[0002] Machine learning models may surpass humans in performing certain specific tasks. This is the result of massive data sets and powerful computing power. However, such results are seriously "biased". The reason is that traditional machine learning models can only be good at one skill at a time and cannot learn continuously like humans and animals.
[0003] For certain complex information mining, screening, and analysis tasks, artificial neural networks designed using existing technologies can demonstrate good learning capabilities. However, these machine learning models suffer from the problem of catastrophic forgetting: when the model learns a new task, it is unable to retain and accumulate previously learned knowledge, and thus cannot use this knowledge in future learning. If the target task is changed, the model also needs to be retrained from scratch, resulting in poor robustness of existing machine learning models in dealing with complex scenarios and low learning efficiency.
[0004] Therefore, how to improve the continuous learning ability of machine learning models in complex scenarios and thus improve the efficiency of machine learning is an important issue that the industry urgently needs to solve. Summary of the Invention
[0005] The present invention provides a continuous learning method and device based on machine learning, which is used to solve the defect of poor robustness of machine learning models in the prior art when dealing with complex scenarios due to the existence of catastrophic forgetting problems, thereby improving the learning efficiency of the model.
[0006] The present invention provides a continuous learning method based on machine learning, the method comprising:
[0007] Determine to perform at least two training tasks; input the training sets of each task into a pre-stored machine learning model to obtain a generation model and a pseudo sample set corresponding to each task, wherein the generation model includes a generator, a feature extractor and a classifier; use the feature extractor to extract the central features of the corresponding training tasks; input the pseudo sample set corresponding to the current task into the first teacher model for training to obtain a first generation sample; input the pseudo sample set corresponding to the previous training task into the second teacher model for training to obtain a second generation sample; train a student model based on the first generation sample, the second generation sample and the central feature of the current task to obtain a target student model for the current task.
[0008] According to a continuous learning method based on machine learning provided by the present invention, the method further includes:
[0009] The training set T of the kth training task k Input into the pre-stored machine learning model of the corresponding task for training to obtain the generator G corresponding to the current task k , and the training set T of the 0th to kth tasks 0~k Input to the corresponding generator G respectively 0~k To obtain the pseudo sample set T′ of the 0th to kth tasks 0~k ; The training set T k and the pseudo sample set T′ 0~k Input into the machine learning model for training to obtain the feature extractor F of the kth training task k and classifier C k , where k is a natural number greater than 1.
[0010] Freeze the feature extractor corresponding to the current task, and use the frozen feature extractor to extract features of each category sample of the data set corresponding to the current task to obtain multiple category features; standardize and average all the category features to obtain the central feature of the current task.
[0011] The first teacher model is constructed according to the feature extractor and the classifier of the current training task, and the pseudo sample set corresponding to the current task is input into the first teacher model for training to obtain the first prediction label of the pseudo sample set, and then the first generated sample is obtained based on the first prediction label and the pseudo sample set; the second teacher model is constructed according to the feature extractor and the classifier of the previous training task, and the pseudo sample set corresponding to the previous training task is input into the second teacher model for training to obtain the second prediction label of the pseudo sample set, and then the second generated sample is obtained based on the second prediction label and the pseudo sample set.
[0012] The student model is constructed according to the feature extractor and the classifier of the current task; the first generated sample and the second generated sample are input into the student model for iterative training, and the feature extractor of the student model is feature constrained based on the central feature of the current task to obtain the target student model.
[0013] The machine learning model includes at least one of DCGAN, WGAN and ACGAN.
[0014] The average accuracy of the target student model for the training set in each training task is obtained respectively; and a forgetting line graph is drawn according to the average accuracy corresponding to each training task.
[0015] The present invention also provides a continuous learning device based on machine learning, the device comprising:
[0016] A determination module is used to determine the execution of at least two training tasks; a generation replay module is used to input the training sets of each task into a pre-stored machine learning model to obtain a generation model and a pseudo sample set corresponding to each task, wherein the generation model includes a generator, a feature extractor and a classifier; a global class center module is used to use the feature extractor to extract the central features of the corresponding training tasks respectively; a generation distillation module is used to input the pseudo sample set corresponding to the current task into the first teacher model for training to obtain a first generated sample; the pseudo sample set corresponding to the previous training task is input into the second teacher model for training to obtain a second generated sample; a student model is trained based on the first generated sample, the second generated sample and the central feature of the current task to obtain a target student model for the current task.
[0017] The present invention provides a continuous learning device based on machine learning, the device further comprising:
[0018] The testing unit is used to obtain the average accuracy of the target student model for the training set in each training task, and draw a forgetting line chart according to the average accuracy corresponding to each training task.
[0019] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the continuous learning method based on machine learning as described above is implemented.
[0020] The present invention provides a continuous learning method and device based on machine learning, which first determines to execute at least two training tasks; then inputs the training sets of each task into a pre-stored machine learning model to obtain a generation model and a pseudo sample set corresponding to each task; then extracts the central features of the corresponding training tasks according to the feature extractor; finally, inputs the pseudo sample set corresponding to the current task into a first teacher model for training to obtain a first generation sample; inputs the pseudo sample set corresponding to the previous training task into a second teacher model for training to obtain a second generation sample; trains a student model based on the first generation sample, the second generation sample and the central feature of the current task to obtain a target student model for the current task; the method of the present invention adopts a training method that combines sample generation replay with distillation learning to improve the continuous learning ability of the machine learning model in complex scenarios and alleviate the catastrophic forgetting of the model. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions in the present invention or the prior art, a brief introduction is given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0022] Figure 1 Schematic diagram of a continuous learning method based on machine learning provided by an embodiment of the present invention;
[0023] Figure 2 is a flow chart of a method for obtaining a forgetting broken line curve provided by another embodiment of the present invention;
[0024] Figure 3 Schematic diagram of the structure of a continuous learning device based on machine learning provided by an embodiment of the present invention;
[0025] Figure 4 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0026] To make the objectives, technical solutions, and advantages of the present invention more clear, the technical solutions of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the embodiments described are only some of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts shall fall within the scope of protection of the present invention.
[0027] The following combination Figure 1 The continuous learning method based on machine learning provided by an embodiment of the present invention is described, including:
[0028] Step 101: Determine to execute at least two training tasks.
[0029] The existing classic machine learning paradigm is to learn in isolation. Machine learning models have the defect of catastrophic forgetting and cannot learn continuously like humans and animals. As a result, they cannot retain and accumulate learned knowledge when learning new tasks and cannot use this knowledge in future learning. Therefore, when dealing with learning problems in complex scenarios, traditional machine learning models have problems such as poor robustness, generalization, and scalability. This embodiment obtains training samples from an image data acquisition device or other open source database, and divides the training samples into multiple training sets, which are used as input data for different training tasks. This embodiment needs to perform at least 2 training tasks, and the training sets contained in each training task can be any one or more categories of samples in the MNIST dataset, SVHN dataset, CIFAR-10 dataset, or ImageNet-50 dataset. Among them, the ImageNet-50 dataset image size is 32*32 RGB 3D images, the number of categories in the dataset is 50, and the number of samples contained in each category is 1300.
[0030] Step 102: Input the training sets of each task into a pre-stored machine learning model to obtain a generation model and a pseudo sample set corresponding to each task, wherein the generation model includes a generator, a feature extractor, and a classifier.
[0031] It can be understood that this embodiment adopts a sample generation and replay training method to obtain pseudo samples of the input training set for each training task, which are used as model input data for distilling past knowledge in the subsequent process. The machine learning algorithm used to generate samples is mainly a generative adversarial network (GAN). During the training process, the GAN network uses the generator network G to generate real pictures as much as possible to deceive the discriminator network D, while the discriminator network D tries to distinguish the pictures generated by G from the real pictures. In this way, the generator network G and the discriminator network D constitute a dynamic "game process". After the training is completed, the GAN can obtain pseudo images that are more "similar" to the input images. However, since the original GAN network is used in the unsupervised learning process, it does not have the category information of the sample based on the label information of the sample; therefore, this embodiment adopts a generative adversarial network (GAN). In this paper, we use extended models of Generative Adversarial Network (GAN) as the initial machine learning model. These extended models include generator G, feature extractor F, and classifier C to cope with the training sets contained in different training tasks. For example, in a certain training task, the ImageNet-50 dataset contains 10 categories. In this case, additional label information needs to be introduced during model training to achieve controllable generated categories, that is, setting up the ACGAN network to train the ImageNet-50 dataset.
[0032] Step 103: Utilize the feature extractor to extract the central features of the corresponding training tasks.
[0033] Specifically, this embodiment uses the training set T in the kth (k=2, 3, 4, ...) training task k Train the machine learning model to obtain the feature extractor F k , and freeze F k Weight, perform global class center calculation: for T k Each category j in takes M (M>0) samples and uses F k Perform feature extraction on these M samples to obtain the category feature set of the current training task right After normalization, the average value is calculated to obtain the central feature of category j The rest of the categories are calculated in this way to obtain the standard average value of high-dimensional features as the class center. The larger M is, the more accurate the class center is. However, considering the memory overhead and calculation time, a suitable value needs to be taken; j,i The dimension is the feature extractor F in the kth training task k The feature dimension of the last layer is that each class saves a feature center There is no significant storage overhead, and once saved, it remains unchanged and will be used in subsequent training stages. This embodiment can retain the class center as the prototype of each class, and in subsequent processes, constrain the features extracted from the replayed samples to the class center to reduce drift during training.
[0034] Step 104: input the pseudo sample set corresponding to the current task into the first teacher model for training to obtain a first generated sample; input the pseudo sample set corresponding to the previous training task into the second teacher model for training to obtain a second generated sample; train the student model based on the first generated sample, the second generated sample and the central feature of the current task to obtain a target student model for the current task.
[0035] Specifically, this embodiment first obtains the feature extractor F in the kth (k=2, 3, 4, ...) training task k , classifier C k , the generator G in the 0th to kth training tasks 0~k , the central features of the 0th to kth training tasks And the feature extractor F of the previous training task k-1 and classifier C k-1 ; This embodiment uses the dual teacher model distillation method for training in the last training stage, where the first and second teacher models are F k +C k and F k-1 +Ck-1 , respectively contain the optimal solution of the current task and the optimal solution of the past task, which means that the dual-teacher model can simultaneously retain the performance of the past task and the performance of the current task; In this embodiment, F k +C k Initialize to get a student model A k +C Ak , where A k is the feature extractor of the student model in the kth training task, C ak is the classifier of the student model in the kth training task; then the generator G 0~k-1 Generate pseudo sample input F k-1 +C k-1 , G k Generate pseudo sample input F k +C k , all 0~k pseudo samples are mixed and input into A k +C Ak The prediction results of the two teacher models are taken as A k +C Ak The training labels are distilled; then the real labels of 0~k pseudo samples are trained as correction; finally, A k The extracted features z for each category j with the saved global class center By making constraints and iteratively training multiple times, the final target learning model is obtained. This can distill the knowledge of the two teacher models into a student model in a more accurate distillation method, thereby reducing the forgetting of old tasks while learning new tasks.
[0036] The method described in this embodiment uses a training method that combines sample generation and replay with distillation learning to improve the continuous learning ability of the machine learning model in complex scenarios and alleviate the catastrophic forgetting of the model.
[0037] Optionally, the training set T of the kth training task k Input into the pre-stored machine learning model of the corresponding task for training to obtain the generator G corresponding to the current task k , and the training set T of the 0th to kth tasks 0~k Input to the corresponding generator G respectively 0~k To obtain the pseudo sample set T′ of the 0th to kth tasks 0~k ; The training set T k and the pseudo sample set T′ 0~k Input into the machine learning model for training to obtain the feature extractor F of the kth training task k and classifier C k , where k is a natural number greater than 1.
[0038] Specifically, when executing the kth (k=2, 3, 4, ...) training task, the present embodiment first uses the training set T of the task k Train the corresponding machine learning model to obtain the generator G k , freeze and save the model, and then use the saved generator G 0~k Generate pseudo samples T′ 0~k , and the pseudo sample set T′ 0~k and training set T k Mix together to get the mixed training set T m , that is, T m =T′ 0~k =T k ∪T′ 0~k-1 , and finally use T m Train the machine learning model to obtain the feature extractor F for the kth task k and classifier C k ; It should be noted that the F of the kth task k and C k The initial parameter settings are all saved by the feature extractor F in the k-1th task k-1 and classifier C k-1 Initialization and Fine-Tune are performed, wherein the initial parameter settings of the feature extractor and classifier of the first training task of this embodiment are obtained by random initialization of the corresponding machine learning model.
[0039] It should be noted that this embodiment uses DCGAN and ACGAN according to the complexity of the training task. ACGAN uses Wasserstein distance and gradient penalty term to make the model better trained and achieve better results. The implementation process of DCGAN is shown as follows:
[0040]
[0041] Where x represents the real sample of the current task, P x represents the sample distribution, r represents the latent space sampling vector, P r Represents the latent space distribution (standard Gaussian distribution). Generator G k Try to fool the discriminator D into believing that it has generated a fake sample G k (r) is the real sample x, and the discriminator D tries its best to distinguish G k (r) and the real sample x, thus achieving the purpose of adversarial learning. In order to achieve the controllability of the generated categories, additional label information y is introduced during training, and transformed into the form of ACGAN:
[0042]
[0043]
[0044] Among them L S is the discrimination loss, L C For the additional classification loss, the training goal of D is to maximize L S +L C , G k The goal is to maximize L C -L S In order to make the model better trained, the Wasserstein distance is introduced as the loss function, and the gradient penalty term is used as the gradient truncation method, which is transformed into an improved ACGAN form:
[0045]
[0046]
[0047]
[0048] Among them L S The last term is the gradient penalty term, The loss function of D is L S +L C , G k The loss function is L G +L C .
[0049] It should be noted that this embodiment uses T m Training F k , C k and through F k-1 , C k-1 Use distillation cross entropy loss L cls , constraining the extracted features of the mixed training set to be consistent with the central features of the real training set, that is, to achieve Use MSE loss L a The two optimization objectives are as follows:
[0050]
[0051] y′=σC k-1 (F k-1 (x)),
[0052]
[0053] Among them, σ is the SoftMax function, which normalizes the prediction score and uses a hyperparameter to synthesize an optimization target: L cls +αL a .
[0054] This embodiment provides a generation model for each training task and a method for obtaining a pseudo sample set, which can reduce the information difference between the training set of each training task and the corresponding pseudo sample, and facilitate the subsequent process of extracting more accurate information from the pseudo samples generated by each training task.
[0055] Optionally, the feature extractor corresponding to the current task is frozen, and the frozen feature extractor is used to extract features of each category sample of the data set corresponding to the current task to obtain multiple category features; all the category features are standardized and averaged to obtain the central feature of the current task.
[0056] Specifically, when executing the kth training task, this embodiment first freezes the trained feature extractor F k , and from the training set T k Pick out M (M>0) samples from each category and use F k Perform feature extraction, standardization, averaging and save to memory bank Z k middle.
[0057]
[0058] Among them, F k (x j,i ) represents feature extraction for the i-th image of the j-th category in task k, ||·||2 represents the two-norm, and the vector is normalized by dividing the vector by its own modulus to remove the large offset caused by the feature scale, making the model more robust and accurate.
[0059] This embodiment provides a method for obtaining global class center features, which is used to constrain a feature extractor in a subsequent process to extract feature information from pseudo samples, thereby making the feature extraction process more accurate.
[0060] Optionally, the first teacher model is constructed based on the feature extractor and the classifier of the current training task, and the pseudo sample set corresponding to the current task is input into the first teacher model for training to obtain the first prediction label of the pseudo sample set, and then the first generated sample is obtained based on the first prediction label and the pseudo sample set; the second teacher model is constructed based on the feature extractor and the classifier of the previous training task, and the pseudo sample set corresponding to the previous training task is input into the second teacher model for training to obtain the second prediction label of the pseudo sample set, and then the second generated sample is obtained based on the second prediction label and the pseudo sample set.
[0061] Specifically, when executing the kth training task, this embodiment will train the feature extractor F k and classifier C kThe parameters contained are set as the initial parameters of the student model to obtain the student model A k +C Ak And the pseudo sample set T′ obtained by the training task k Input into the first teacher model for training to obtain the first predicted label y′1, and then according to the training set T of the kth task k The real label of y′1 is used for training correction, and the pseudo sample after label correction is used as the first generated sample; y′1 is used as the kth training task; the k-1th training task is used to obtain the feature extractor F k-1 and classifier C k-1 The second teacher model is formed and the pseudo sample set T′ obtained by the training task is k-1 Input into the second teacher model for training to obtain the second predicted label y′2, and then according to the training set T of the k-1th task k-1 The real label of y′2 is used for training correction, and the pseudo sample after label correction is used as the second generated sample.
[0062] This embodiment provides a method for knowledge distillation using a dual-teacher model. During the process of incremental category learning, the predicted labels of the pseudo sample set are corrected with the true labels of the training set. While retaining the knowledge of the old task, the knowledge of the new task is learned, which is also beneficial for alleviating the problem of catastrophic forgetting in traditional machine learning models.
[0063] Optionally, the student model is constructed based on the feature extractor and the classifier of the current task; the first generated sample and the second generated sample are input into the student model for iterative training, and the feature extractor of the student model is feature constrained based on the central feature of the current task to obtain the target student model.
[0064] according to Figure 2 As shown: This embodiment uses the feature extractor F saved by the kth training task k , classifier C k and the feature extractor F saved by the k-1th training task k-1 , classifier C k-1 Construct the first and second teacher models respectively, and use F k ,C k Initialize to get student model A k ,C Ak , use all the saved trained generators G 0~k Generate pseudo samples T′ for tasks 0 to k 0~k-1 and T′ k ; Then T′ k and T′ 0~k-1Input the first teacher model to obtain two prediction results respectively, and use these two results as the soft label and hard label of the student model. Input the student model to obtain a new prediction result, and perform distillation cross entropy loss on the hard label to constrain the probability level:
[0065]
[0066] y′=argmax(σC k-1 (F k-1 (x′))),
[0067]
[0068] (1-y′)·log(1-σC Ak (A k (x′)))],
[0069] y′=argmax(σC k (F k (x′)))
[0070] Among them, σ represents the SoftMax activation function, L cls1 , L cls2 Respectively represent F k-1 +C k-1 Distillation loss and F k +C k The distillation loss is used to constrain the soft labels at the feature level using the JS loss (Jensen-Shannon divergence):
[0071]
[0072]
[0073]
[0074] Among them, P1 and P2 represent the average value of the features extracted by the student model and the average value of the features extracted by the two teacher models, respectively. soft represents the soft distillation constraint strategy at the feature level, ⊕ represents the superposition of tensor dimension 0, and KL represents Kullback–Leibler divergence, which is used to measure the distance between two distributions. The closer the distance, the smaller the KL divergence, and vice versa. Due to the asymmetry of the KL divergence, the symmetric JS divergence is more robust in measuring the distribution. In addition, the central feature of the current task constrains the feature extractor of the student model to make the feature extraction more accurate. That is, a regularization term is added after the loss function to obtain a new loss function. The expression of the new loss function is:
[0075]
[0076] Model A for students k ,C Ak The final optimization goal is:
[0077] L=L cls1 +L cls2 +L m +μL soft +βL prototype
[0078] Where x′,y′ j They represent the generated samples and generated labels of tasks 0 to k respectively. μ and β are hyperparameters. In this embodiment, the values of the three parameters are: α = 0.2, μ = β = 0.1. When the L condition is met, the target student model can be obtained.
[0079] It should be noted that, in this embodiment, the mixed generation sample A is trained by combining the first generation sample obtained by the first teacher model training and the second generation sample obtained by the second teacher model training. k ,C Ak , which can prevent the student model from learning the gap between the two parts of the pseudo samples and calibrate the alignment loss L m The expression is as follows:
[0080]
[0081] The method described in this embodiment provides a method for performing distillation learning based on a dual-teacher model to obtain a target learning model, transferring the knowledge of the two teacher models to the student model, improving learning efficiency, and promoting knowledge transfer between different tasks.
[0082] Optionally, the machine learning model includes at least one of a DCGAN model, a WGAN model, and an ACGAN model.
[0083] It is understandable that the complexity of the training sets for different training tasks is different, and the selection of feature extractors and generators is also different. The classifier is a single-layer fully connected plus SoftMax normalization. As the number of categories increases, the number of classifier neurons is incremental. For different training samples, this embodiment can flexibly select multiple types of machine learning models for training and learning, for example: using the DCGAN model to train the MNIST dataset or SVHN dataset, using WGAN to generate the CIFAR-10 dataset, and using ACGAN to generate the ImageNet-50 dataset, etc.
[0084] The method described in this embodiment provides a variety of GAN extension models, which are applied to the dataset training process of different training tasks, facilitating the generation of pseudo samples and model parameter migration for each training task.
[0085] Optionally, the average accuracy of the target student model for the training set in each of the training tasks is obtained respectively; and a forgetting line graph is drawn according to the average accuracy corresponding to each of the training tasks.
[0086] according to Figure 2 As shown, in order to quantitatively analyze the continuous learning ability of the target learning model and intuitively reflect the learning effect, this embodiment uses the average accuracy of the training set in each training task using the target student model, and draws a forgetting line chart based on the average accuracy corresponding to each training task; the specific steps are: for tasks 0~k, the test set is divided into t0...t k , and then after incremental learning of k tasks, the final model A is obtained k ,C Ak , calculate A k ,C Ak The accuracy of all the test sets that have been learned is averaged as the accuracy result of the current task. The calculation formula for this accuracy is:
[0087]
[0088] where a k,j ∈[0,1], represents the accuracy of task i tested with the model of task k, x, y represent the samples and labels in the test set of task k, σ represents the task SoftMax activation function, and a forgetting line graph is drawn based on the AAcc calculated for tasks 0 to k. Generally, the last AAcc is taken as the final accuracy of the model on the sequence task. The higher the final accuracy, the better the incremental learning ability of the model and the smaller the degree of catastrophic forgetting.
[0089] This embodiment provides a method for testing the learning effect of a target student model, which can be used to quantitatively analyze the incremental learning ability and catastrophic forgetting degree of the target student model.
[0090] Combine Figure 3 A continuous learning device based on machine learning provided in an embodiment of the present invention is described. The continuous learning device based on machine learning described below and the continuous learning method based on machine learning described above can refer to each other.
[0091] An embodiment of the present invention provides a continuous learning device based on machine learning, the device comprising:
[0092] A determination module 301 is used to determine the execution of at least two training tasks; a generation replay module 302 is used to input the training sets of each task into a pre-stored machine learning model to obtain a generation model and a pseudo sample set corresponding to each task, wherein the generation model includes a generator, a feature extractor and a classifier; a global class center module 303 is used to use the feature extractor to extract the central features of the corresponding training tasks respectively; a generation distillation module 304 is used to input the pseudo sample set corresponding to the current task into the first teacher model for training to obtain a first generation sample; the pseudo sample set corresponding to the previous training task is input into the second teacher model for training to obtain a second generation sample; a student model is trained based on the first generation sample, the second generation sample and the central feature of the current task to obtain a target student model for the current task.
[0093] Another embodiment of the present invention provides a continuous learning device based on machine learning, the device further comprising:
[0094] The testing unit is used to obtain the average accuracy of the target student model for the training set in each training task, and draw a forgetting line chart according to the average accuracy corresponding to each training task.
[0095] This embodiment provides a continuous learning device based on machine learning, which first determines to execute at least two training tasks through a determination module 301; then, through a generation and replay module 302, the training sets of each task are respectively input into a pre-stored machine learning model to obtain a generation model and a pseudo sample set corresponding to each task; then, through a global class center module 303, the central features of the corresponding training tasks are respectively extracted according to the feature extractor; finally, through a generation and distillation module 304, the pseudo sample set corresponding to the current task is input into a first teacher model for training to obtain a first generated sample; the pseudo sample set corresponding to the previous training task is input into a second teacher model for training to obtain a second generated sample; a student model is trained based on the first generated sample, the second generated sample and the central feature of the current task to obtain a target student model for the current task; the device described in this embodiment adopts a training method that combines sample generation and replay with distillation learning to improve the continuous learning ability of the machine learning model in complex scenarios and alleviate the catastrophic forgetting of the model.
[0096] Figure 4 An example of a physical structure diagram of an electronic device is shown below. Figure 4As shown, the electronic device may include: a processor 410, a communication interface 420, a memory 430 and a communication bus 440, wherein the processor 410, the communication interface 420 and the memory 430 communicate with each other via the communication bus 440. The processor 410 may call the logic instructions in the memory 430 to execute a continuous learning method based on machine learning, the method comprising: determining to execute at least two training tasks; inputting the training sets of each task into a pre-stored machine learning model to obtain a generation model and a pseudo sample set corresponding to each task, wherein the generation model includes a generator, a feature extractor and a classifier; using the feature extractor to extract the central features of the corresponding training tasks; inputting the pseudo sample set corresponding to the current task into the first teacher model for training to obtain a first generated sample; inputting the pseudo sample set corresponding to the previous training task into the second teacher model for training to obtain a second generated sample; training the student model based on the first generated sample, the second generated sample and the central feature of the current task to obtain a target student model for the current task.
[0097] In addition, the logic instructions in the above-mentioned memory 430 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0098] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, i.e., they may be located in one location or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of the present embodiment. Persons of ordinary skill in the art will be able to understand and implement the present invention without inventive effort.
[0099] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a necessary general hardware platform, or of course, by hardware. Based on this understanding, the essence of the above technical solution or the part that contributes to the prior art can be embodied in the form of a software product. The computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or certain parts of the embodiments.
[0100] Finally, 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 aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention.
Claims
1. A continuous learning method based on machine learning, characterized in that: include: Determine to perform at least two training tasks; Inputting the training sets of each task into a pre-stored machine learning model to obtain a generative model and a pseudo sample set corresponding to each task, wherein the generative model includes a generator, a feature extractor, and a classifier; the training set is a first image set, the generative model is an image generation model, and the pseudo sample set is a second image set generated by the generative model based on the first image set; Utilizing the feature extractor to extract the central features of the corresponding training tasks respectively; Input the pseudo sample set corresponding to the current task into the first teacher model for training to obtain the first generated sample; input the pseudo sample set corresponding to the previous training task into the second teacher model for training to obtain the second generated sample; Training a student model based on the first generated sample, the second generated sample, and the central feature of the current task to obtain a target student model for the current task; inputting the training set of each task into a pre-stored machine learning model to obtain a generated model and a pseudo sample set corresponding to each task, specifically including: The training set of the kth training task Input into the pre-stored machine learning model of the corresponding task for training to obtain the generator corresponding to the current task , and the training set of the 0th~kth task Input to the corresponding generator respectively To obtain the pseudo sample set of the 0th~kth task ; The training set and the pseudo sample set Input into the machine learning model for training to obtain the feature extractor of the kth training task and classifier , where k is a natural number greater than 1.
2. The continuous learning method based on machine learning according to claim 1, characterized in that: The feature extractor is used to extract the central features of the corresponding training tasks, specifically including: Freezing the feature extractor corresponding to the current task, and using the frozen feature extractor to extract features from samples of each category of the data set corresponding to the current task, to obtain multiple category features; All the category features are standardized and averaged to obtain the central feature of the current task.
3. The continuous learning method based on machine learning according to claim 1, characterized in that: Obtaining the first generated sample and the second generated sample specifically includes: Constructing the first teacher model based on the feature extractor and the classifier of the current training task, inputting the pseudo sample set corresponding to the current task into the first teacher model for training to obtain a first predicted label of the pseudo sample set, and then obtaining the first generated sample based on the first predicted label and the pseudo sample set; The second teacher model is constructed based on the feature extractor and the classifier of the previous training task, and the pseudo sample set corresponding to the previous training task is input into the second teacher model for training to obtain the second predicted label of the pseudo sample set, and then the second generated sample is obtained based on the second predicted label and the pseudo sample set.
4. The continuous learning method based on machine learning according to claim 1, characterized in that: Training a student model based on the first generated sample, the second generated sample, and the central feature of the current task to obtain a target student model for the current task specifically includes: Constructing the student model based on the feature extractor and the classifier of the current task; The first generated sample and the second generated sample are input into the student model for iterative training, and feature constraints are performed on the feature extractor of the student model based on the central feature of the current task to obtain the target student model.
5. The continuous learning method based on machine learning according to claim 1, characterized in that: The machine learning model includes at least one of a DCGAN model, a WGAN model and an ACGAN model.
6. The continuous learning method based on machine learning according to claim 1, characterized in that: The method further comprises: Obtain the average accuracy of the target student model for the training set in each training task; A forgetting line graph is drawn according to the average accuracy corresponding to each of the training tasks.
7. A continuous learning device based on machine learning, characterized in that: The device comprises: A determination module, configured to determine to perform at least two training tasks; A generation and replay module is configured to input the training sets of each task into a pre-stored machine learning model to obtain a generation model and a pseudo sample set corresponding to each task, wherein the generation model includes a generator, a feature extractor, and a classifier; the training set is a first image set, the generation model is an image generation model, and the pseudo sample set is a second image set generated by the generation model based on the first image set; A global class center module, used to extract the center features of the corresponding training tasks respectively using the feature extractor; A generation distillation module is configured to input the pseudo sample set corresponding to the current task into the first teacher model for training to obtain first generated samples; input the pseudo sample set corresponding to the previous training task into the second teacher model for training to obtain second generated samples; and train a student model based on the first generated samples, the second generated samples, and the central feature of the current task to obtain a target student model for the current task; The generation and replay module is specifically used for: The training set of the kth training task Input into the pre-stored machine learning model of the corresponding task for training to obtain the generator corresponding to the current task , and the training set of the 0th~kth task Input to the corresponding generator respectively To obtain the pseudo sample set of the 0th~kth task ; The training set and the pseudo sample set Input into the machine learning model for training to obtain the feature extractor of the kth training task and classifier , where k is a natural number greater than 1.
8. The continuous learning device based on machine learning according to claim 7, characterized in that: The device further comprises: The testing unit is used to obtain the average accuracy of the target student model for the training set in each training task, and draw a forgetting line chart according to the average accuracy corresponding to each training task.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the continuous learning method based on machine learning as described in any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Incremental equipment fault diagnosis method based on knowledge distillation and hidden layer sharing
CN110162018A
Double knowledge distillation method for image retrieval
CN113255822A