Regularized Continuous Learning Method Based on Bayesian Parameter Update and Weight Memory
By employing regularization methods for Bayesian parameter updates and weight memory, the catastrophic forgetting problem in deep neural networks during continuous learning is solved, achieving the effect of reducing the forgetting of old knowledge and improving the classification accuracy of new tasks when learning new tasks.
Patent Information
- Application Number
- CN202310156840.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-23
- Publication Date
- 2025-10-31
- Estimated Expiration
- 2043-02-23
AI Technical Summary
Deep neural networks are prone to catastrophic forgetting when transitioning from batch learning to continuous learning. Existing regularization methods are ineffective in mitigating the forgetting of old knowledge and limit the learning of new knowledge.
We employ a regularization method based on Bayesian parameter updating and weight memory. We generate replay data through a brain-inspired replay model, use regularization constraints to determine the importance of model parameters, and adaptively update weight parameters using Bayesian probability. We also combine the Fisher information matrix as a measure of parameter importance to limit changes in important parameters and prevent the forgetting of old task knowledge.
When learning new tasks, it effectively reduces the forgetting of knowledge from old tasks, improves the model's classification accuracy and efficiency for new tasks, and achieves better knowledge updating and preservation.
Smart Images

Figure CN116206337B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of machine learning technology, and in particular to a regularized continuous learning method based on Bayesian parameter update and weight memory. Background Technology
[0002] Continuous learning helps apply machine learning to resource-constrained, privacy-sensitive, or non-stationary data distribution environments. However, due to the differences in structure between deep neural networks (DNNs) and the human brain, DNN training struggles to transition from batch learning to continuous learning. It tends to adjust learning parameters to adapt to new tasks, leading to a major challenge: catastrophic forgetting. In recent years, regularization-based methods have been proposed to mitigate this problem. For example, Elastic Weight Integration (EWC), Synaptic Intelligence (SI), and Memory-Aware Synapses (MAS) use different metrics to identify and penalize changes in important parameters of the original network when learning new tasks. However, this approach often leads to model rigidity. While it preserves some knowledge of older classes, it limits the model's ability to learn new knowledge, often resulting in a situation where it neither learns new knowledge well nor retains relevant knowledge from previous tasks effectively. Summary of the Invention
[0003] This invention aims to at least solve the technical problems existing in the prior art, and in particular, it innovatively proposes a regularized continuous learning method based on Bayesian parameter update and weight memory.
[0004] To achieve the above-mentioned objectives of this invention, this invention provides a regularized continuous learning method based on Bayesian parameter update and weight memory, comprising the following steps:
[0005] S1, when learning each new task, uses a brain-inspired replay model to generate replay data;
[0006] S2, input the new task and replay data into the brain-inspired replay model, and train it through regularization constraints to determine the importance of the model parameters;
[0007] S3, perform loss function analysis on the model based on the importance of the model parameters.
[0008] Furthermore, the brain-inspired replay model includes an encoder, a classifier, and a decoder.
[0009] The encoder comprises five convolutional layers and two hidden layers, each with 400 nodes, and a SoftMax output layer. All hidden nodes use ReLU nonlinearity. A bottleneck attention mechanism (BAM) is incorporated into the third and / or fourth convolutional layers, integrated with the convolutional neural network. BAM attention infers the attention map along the channel and spatial paths. BAM attention has two branches: a channel attention branch and a spatial attention branch. Each channel in the channel attention branch contains a specific feature response, emphasizing which feature to focus on; the spatial attention branch emphasizes or suppresses features at different spatial locations.
[0010] To prevent overfitting during training, a dropout layer with a probability of 0.3 is added to the classification layer (fc_layer) of the classifier.
[0011] Furthermore, the regularization constraints include:
[0012] S2-1, Whenever there is a new task that needs to be learned, the weight parameters are updated adaptively through Bayesian probability and converted into Fisher information matrix as a measure of parameter importance;
[0013] S2-2, For each task, calculate each parameter θ in the network model. i The degree to which changes affect the model output is represented by the importance M to the current task. i The parameters with the greatest impact are retained and used in subsequent training tasks.
[0014] Further, S2-1 includes:
[0015] S2-1, Whenever there is a new task that needs to be learned, the weight parameters are updated adaptively through Bayesian probability and converted into Fisher information matrix as a measure of parameter importance;
[0016] S001, using Bayes' theorem, find the optimal parameter that maximizes the probability:
[0017]
[0018] Where logp(θ|D) 1:k ) represents data D 1:k Given the optimal parameter θ, the data D from task 1 to task k 1:k The posterior;
[0019] Representing data D 1:k Optimal parameters Given the data D for tasks 1 to k, 1:k The posterior;
[0020] To determine the sign of the partial derivative;
[0021] θ represents the parameter to be optimized, which is used when past data D is inaccessible. 1:k The optimal parameters that need to be solved at that time;
[0022] The optimal parameters are those given the old task data, and are those based on known past data D. 1:k In this case, the optimal parameters have already been obtained;
[0023] S002, After determining the optimal parameters, update the parameters:
[0024] Optimal parameters for current task k+1 Updated to:
[0025]
[0026] in Indicates the use of data D 1:k+1 Chinese Ambassador D 1:k+1 The parameter θ with the lowest probability;
[0027] L k+1 (θ) represents the data D k+1 The log-likelihood;
[0028] λ is a hyperparameter;
[0029] F i k Indicates the parameter θ in all old tasks i Fisher's information matrix;
[0030] This formula only depends on the task data D to be trained. k+1 Previous task data and information are encapsulated in the second term's quadratic penalty, ensuring that θ always remains close to the previously learned optimal parameters.
[0031] S003 stores important parameters in Fisher's format as a measure of parameter importance:
[0032] First, calculate the Fisher information matrix for the current task, treat it as an importance score, and save it. When calculating the Fisher information matrix for the next task's parameters, use the average value for effective updating to obtain the final Fisher information matrix.
[0033]
[0034] in: Is the parameter θ during training iteration t? nFisher information matrix of time parameters;
[0035] Is the parameter θ during training iteration t? n-1 Fisher information matrix of time parameters;
[0036] t n This represents the nth training iteration;
[0037] γ, η are hyperparameters, γ, η ∈ (0,1) and γ + η = 1.
[0038] Furthermore, S2-2 includes: given data point x k The function output changes approximately as follows:
[0039]
[0040] Where f(x) k ;θ) is the output of the brain-inspired replay model;
[0041] θ(t+Δt) represents the weighting parameter at time t+Δt;
[0042] θ(t) represents the weighting parameter at time t;
[0043] Δt is the change over time;
[0044] It is the learning function with respect to the weight parameters θ i The partial derivatives;
[0045] δ i (t) is the parameter θ i The change Δθ i ;
[0046] From formula (8), we can obtain the gradient g of the model learning function in formula (9). i (x k );
[0047] Starting from Task 1, for each observation data point x in the task... k The goal is to calculate the change in the learning function caused by each data point, with the aim of preserving the model's predictions and preventing changes to parameters that are critical to those predictions.
[0048]
[0049] m i This indicates the sensitivity of the model output to changes in parameters;
[0050] N represents the sum of data points for a given method;
[0051] g i(x k ) represents the learning function with respect to the weight parameters θ i The gradient;
[0052] To find the magnitude of the gradient, let the change in parameter θ be δ. i =Δθ i →0, approximate the KL divergence using a second-order Taylor series:
[0053]
[0054] Where D KL ( ) represents the KL divergence;
[0055] p θ ||p θ+Δθ Indicates p θ p θ+Δθ To perform fitting, use p θ+Δθ To fit p θ ;
[0056] p θ This represents the probability of parameter θ occurring, and the probability of that parameter occurring after the parameter changes.
[0057] p θ+Δθ This represents the probability that θ+Δθ will occur after the parameter θ changes;
[0058] This indicates calculating the gradient;
[0059] T is the transpose symbol;
[0060] Δθ represents the change in parameter θ;
[0061] Δθ T It is the transpose of Δθ;
[0062] E z [log p θ ] indicates finding the logarithmic distribution logp θ Expectations;
[0063] This represents the expectation of the gradient of the logarithmic distribution;
[0064] Δθ i This represents the amount of smoothing applied to the i-th parameter;
[0065] Formula (10) calculates the KL divergence (distance) of the parameters before and after the change in the denominator of Formula (11). The KL divergence measurement using Formula (10) indicates the direction that gives the largest target change per unit change in the model. In this case, parameter importance is defined as the ratio of the change in the learning function to the distance between the conditional likelihood distributions at each step in the parameter space, where the parameter θ... iImportance can be calculated as follows:
[0066]
[0067] Where t n This is the total number of training iterations;
[0068] m i The sensitivity of the model output to changes caused by parameter changes is calculated by formula (9);
[0069] It is the parameter θ i The Fisher calculation formula for iteration at t is given by formula (7);
[0070] Δθ i (t)=θ i (t+Δt)-θ i (t), θ i (t+Δt) and θ i (t) represents the parameters at different iterations, θ i (t+Δt)-θ i (t) represents the change in parameters under different training iterations;
[0071] ε represents a hyperparameter, and ε>0 is used to prevent the first part of the denominator from being zero.
[0072] By inputting a new data point into the network, the importance of the weight parameters corresponding to that data point can be calculated online using this equation. Data point x k It is the input data (control at the previous neuron), and the parameter θ is the input data point x. k The corresponding weight coefficients are the parameters / coefficients that need to be trained; the process of optimizing the parameters / coefficients is to change the parameters / coefficients to minimize the difference between the prediction and the true value.
[0073] Furthermore, through the loss function analysis, the loss function of the brain-inspired replay model is obtained as follows:
[0074]
[0075] This represents the final loss after applying regularization constraints;
[0076] L k (θ) represents the loss of the current task;
[0077] λ is a hyperparameter, λ∈[0,1], used to ensure and M t (θ i The proportions of these two items are in the same order, so their influence is retained.
[0078] The parameter θ is the parameter of the last iteration of task k-1. i Fisher;
[0079] M t (θ i ) is from the first training iteration t0 to the last training iteration t corresponding to task k-1. n The importance of accumulation;
[0080] θ i These are the weights that currently need to be trained;
[0081] These are the weights corresponding to the parameters at the end of task k-1.
[0082] In summary, by adopting the above technical solution, this invention can overcome the shortcomings and deficiencies of existing regularization techniques, and can better learn new tasks. While learning new task knowledge more efficiently, it should also reduce the catastrophic forgetting of old task knowledge.
[0083] Additional aspects and advantages of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. Attached Figure Description
[0084] The above and / or additional aspects and advantages of the present invention will become apparent and readily understood from the description of the embodiments taken in conjunction with the following drawings, in which:
[0085] Figure 1 This is a diagram illustrating the catastrophic forgetting phenomenon in machine learning.
[0086] Figure 2 This is a schematic diagram illustrating the test accuracy of the regularization method and the method of this invention on the CIFAR-100 dataset.
[0087] Figure 3 This is a schematic diagram illustrating the test accuracy of the regularization method and the method of this invention on the split MNIST dataset.
[0088] Figure 4 This is the incremental learning result (accuracy %) on CIFAR-100. Figure 4 (a) is divided into 5 categories of incremental batches. Figure 4 (b) is an incremental batch divided into 10 categories. Figure 4 (c) is an incremental batch of 20 classes.
[0089] Figure 5 This is a flowchart of parameter update and weight memory.
[0090] Figure 6This is a structural diagram of a brain-inspired replay model. Detailed Implementation
[0091] Embodiments of the present invention are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and should not be construed as limiting the present invention.
[0092] This invention is primarily used in the field of computer vision, which includes image classification, semantic segmentation, and object detection. Specifically, this patent is applied to the field of continuous learning image classification, solving classification problems, improving the accuracy of classifying new images, and reducing the forgetting of classification accuracy for older images.
[0093] The method proposed in this invention is a regularized continuous learning method based on Bayesian parameter update and weight memory, comprising the following steps:
[0094] S1, when learning each new image task, uses a brain-inspired replay model to generate replay data;
[0095] S2, input the new image task and image replay data into the brain-inspired replay model, and train it through regularization constraints to determine the importance of the model parameters;
[0096] S3, perform loss function analysis on the model based on the importance of the model parameters.
[0097] For example, there are visual differences between new and old categories (mule and donkey). Traditional classification algorithms may classify the new and old categories into one category. However, by using the regularization method of this invention, we can calculate the parameters that best express and distinguish the characteristics of new and old things (mule and donkey), and constrain these parameters so that the model can remember them. When inputting similar new tasks, it can also correctly classify similar objects.
[0098] Catastrophic forgetting is a fundamental challenge facing artificial intelligence based on neural networks. For example... Figure 1 As shown, after learning a new task, the newly learned task knowledge overwrites the knowledge of previously learned tasks, causing the network model to almost completely forget the previously acquired knowledge. Addressing existing regularization methods that mitigate catastrophic forgetting in continuous learning, this invention, from the perspective of model parameters, employs regularization techniques to reduce catastrophic forgetting of old task knowledge, thus solving the continuous learning problem in image classification. Simultaneously, it combines Bayesian criteria to update the parameters of the deep model, improving the accuracy and efficiency of the model in classifying new images. Specifically, it includes the following steps:
[0099] First, Bayesian probabilistic adaptive weight update is introduced. Whenever a new sample arrives, prior knowledge is used to predict and discriminate the new task data according to formulas (1)-(3) to obtain its posterior knowledge. Then, the posterior knowledge is used to modify the prior knowledge, so the original posterior knowledge becomes the prior knowledge. Therefore, Bayesian incremental learning is a dynamic process that uses sample knowledge to continuously adjust the current prior knowledge. Second, by observing the changes in the network parameter vector and their impact on the model output function, the changes in the model parameters are regularized. According to formulas (8)-(11), the importance of all parameters in preserving old knowledge is measured. By restricting the changes in parameters that are more important to the old task, knowledge about the old class is preserved. Finally, the method of this invention is combined with the modified replay model to achieve more advanced performance in continuous learning.
[0100] The regularization term of this method consists of two parts. The first part adaptively updates the weight parameters based on the Bayesian criterion, converting them into a Fisher information matrix as a measure of parameter importance. The second part, for each task, calculates each parameter θ in the network model after training for that task. i The degree to which changes affect the model output is represented by the importance M to the current task. i (importance weight) retains parameters with a significant impact and uses them in subsequent training tasks.
[0101] 1. Analysis of parameter update methods based on Bayesian probability models
[0102] First, given the data D from the first k tasks. 1:k Optimal parameters We now need to use new data D k+1 Learning to optimize the parameters of new task k+1 From a probabilistic perspective, training a neural network involves optimizing its parameters, which is equivalent to enabling the model to operate without relying on past data D. 1:k Find the most likely value from task 1 to k+1 in the given situation. This maximizes the posterior of all data accessed so far, i.e., logp(θ|D) 1:k+1 When the θ is at its maximum, then the desired data D is obtained. 1:k+1 Optimal parameters For logp(θ|D) 1:k+1 Using Bayesian estimation:
[0103] logp(θ∣D 1:k+1 ) = logp(D k+1 |θ)+logp(θ|D 1:k )-logp(D k+1 |D 1:k (1)
[0104] logp(θ∣D 1:k+1 ) represents the data D from task 1 to task k+1. 1:k+1 The posterior, i.e., the calculation of D given that parameter θ occurs. 1:k+1 The probability of occurrence.
[0105] The first term on the right side of formula (1) is logp(D) k+1 |θ) represents the log-likelihood of the new task k+1, and represents the new data D. k+1 The probability, i.e., logp(D) k+1 |θ)=-L k+1 (θ).
[0106] The second term logp(θ|D) 1:k ) represents the posterior of tasks 1 to k.
[0107] The third item logp(D) k+1 |D 1:k The parameter θ we want to optimize is a constant C. Therefore, we only need to optimize the first two terms:
[0108]
[0109] This indicates that the maximum parameter θ is used to construct all data D from 1 to k+1. 1:k+1 The maximum a posteriori.
[0110] Indicates the use of data D 1:k+1 Chinese Ambassador D 1:k+1 The parameter θ represents the maximum probability.
[0111] L k+1 (θ) represents the data D k+1 The log-likelihood is the probability that the data will occur.
[0112] C represents a constant, in which past data D is inaccessible. 1:k In the case of posterior logp(θ|D) 1:k It is difficult to obtain the optimal parameters for the first k old tasks by using the Laplace diagonal approximation of the Gaussian posterior. Performing a Taylor expansion at (the first-order pole), ignoring terms of power 3 and above, we obtain:
[0113]
[0114] Data D represents tasks 1 to k. 1:k The posterior, i.e., data D 1:k Optimal parameters Given that something has already happened, calculate the probability of it happening again.
[0115] θ represents the parameter to be optimized, which is used when past data D is inaccessible. 1:k The optimal parameters that need to be solved at that time;
[0116] The optimal parameters are those given the old task data, and are those based on known past data D. 1:k In the case of the already obtained optimal parameters; Formula (3) is derived from Bayesian inference. In the case of the inability to access past task data, Formula (3) is used to solve for the optimal parameter θ with the highest probability.
[0117] This refers to the data D from tasks 1 to k. 1:k posterior In the optimal parameters of the model The second derivative of the Hessian matrix is given by the definition of the Hessian matrix.
[0118]
[0119] Where H represents the Hession matrix;
[0120] This indicates finding the optimal parameters of the model. The Hession matrix.
[0121] Since the Fisher information matrix equals the negative expectation of the Hessian matrix, and assuming the Fisher matrix is diagonal, then:
[0122]
[0123] F represents the Fisher information matrix.
[0124] It's in the parameters Calculate the expectation of the Hession matrix at point .
[0125] express log p(θ|D) under the condition 1:k The partial derivatives of ).
[0126] Substituting formulas (3) and (4) into (2), we get:
[0127]
[0128] Wherein: F i k The parameter θ is from all the old tasks i Fisher's information matrix;
[0129] λ is a hyperparameter used to measure the importance of older task data.
[0130] Both C and C' are constants;
[0131] Assuming F is diagonal, we can use the optimal parameters from the old task. The diagonal term F i k This reduces the number of parameters. The diagonal elements contain the first derivative of the neural network output with respect to the neural network parameters, reflecting the importance of the neural network parameters to the old task dataset. Its definition as the second derivative of the logarithmic probability is key to understanding its role in preventing forgetting.
[0132] Extracting the negative sign from the right-hand side of formula (5), the optimal parameters for the current task k+1 are updated as follows:
[0133]
[0134] This formula only depends on the task data D to be trained. k+1 Previous task data and information are encapsulated in the second term's quadratic penalty, ensuring that θ always remains close to the previously learned optimal parameters.
[0135] Formulas (4) to (6) are used to update the parameters after the optimal parameters are determined.
[0136] When scaled to a large number of tasks, this leads to a linear increase in the number of regularization terms with the number of tasks. To estimate the empirical Fisher's information, EWC requires additional passes to the dataset for each task. This computational approach becomes practically infeasible with many tasks and millions of parameters in the network. Therefore, we introduce a novel improvement. We first compute the Fisher's information matrix for the current task, treating it as an importance score and storing it. When computing the Fisher's information for the parameters of the next task, we use the average value for efficient updates, resulting in the final Fisher's information matrix:
[0137]
[0138] in: Is the parameter θ during training iteration t? n Fisher information matrix of time parameters;
[0139] t n This represents the nth training iteration;
[0140] γ, η are hyperparameters, γ, η ∈ (0,1) and γ + η = 1.
[0141] Formula (7) stores important parameters in Fisher's format as a measure of parameter importance.
[0142] Fisher's information, calculated in this way, includes information about previous tasks and also eliminates the need for additional forward-backward passes on the dataset. At the end of each task, the Fisher's information matrix is iterated over from the last word of the current task. The previous iteration t n-1 Fisher information matrix at the location The Fisher data is stored in a specific way and used for regularization of the next task. Throughout the training process, we only need to store two sets of Fisher data: the Fisher data from the previous task and the Fisher data from the current task, regardless of the number of tasks.
[0143] 2. Analysis of Weighted Memory Regularization Method
[0144] We first calculated the Fisher information matrix for the previous task. When training the next task, we can obtain the Fisher information for the current task using formula (7). However, since the Fisher information only captures the model's inherent properties at their minimum values, we also need to calculate the Fisher information for each parameter θ. i Calculate an importance score, representing the score's importance relative to the preceding task. Given a task sequence D ∈ {D1, ..., D2}. k-1}, where 1,…,k-1 represent the number of tasks, D1,......,D k-1 This represents the training data corresponding to each task. Each training task has its own training data. The training data consists of a feature vector x from the input data. i ∈X and a target vector Composition. We start with Task 1, training the model using the training data from Task 1. Minimize the L1 loss of the previous task.
[0145] Once the model converges, the true function F constructs an approximate function f for x→y based on the known data samples. This approximate function outputs y1 from the new input x1 in a mapping relationship. We want to save this approximate function for learning other tasks. Our goal is to estimate an important weight for each parameter in the network. In this case, parameter importance is not defined as the (inverse) measure of parameter uncertainty in EWC, or the sensitivity of loss to parameter changes in SI, but rather as the sensitivity of the learning function f to parameter changes.
[0146] Given data point x k The output of the network model is f(x) kIf a small change in parameter θ(t) at time t leads to a large change in the output of the learning function, then its importance is higher. The change in the function output can be approximated as:
[0147]
[0148] θ(t+Δt) represents the weighting parameter at time t+Δt;
[0149] Δt is the change over time;
[0150] It is the learning function with respect to the weight parameters θ i The partial derivatives;
[0151] δ i It is the parameter θ i The change Δθ i .
[0152] Starting from Task 1, for each observation data point x in the task... k We calculate the change in the learning function caused by each data point, with the goal of preserving the model's predictions and preventing changes to parameters that are critical to those predictions.
[0153]
[0154] m i This indicates the sensitivity of the model output to changes caused by parameter variations.
[0155] N represents the sum of data points for a given method;
[0156] g i (x k ) represents the learning function with respect to the weight parameters θ i The gradient;
[0157] ||·|| is used to calculate the magnitude of the gradient;
[0158] This part of the calculation is the same as MAS, both calculating the sensitivity of the learning function to parameter changes. The difference is that we don't directly approximate importance using the gradient of the model output relative to the model parameters. Instead, we consider the changes in parameters at each step, attempting to choose a descent direction at each step so that the amount of change (in the KL sense) in our model is a given value. This parameter change causes a corresponding change in the model distribution. In deep learning gradient descent, the descent direction is usually chosen based on the direction of the fastest parameter change; each time the parameter moves a certain distance, the direction of the fastest change is chosen. KL divergence can be used to measure the difference in probability distributions after parameter changes; therefore, we can define a similarity measure between nearby density functions. Assume the change in parameter θ is δ...i =Δθ i →0, we can approximate the KL divergence using a second-order Taylor series:
[0159]
[0160] D KL ( ) represents the KL divergence;
[0161] p θ ||p θ+Δθ Indicates p θ p θ+Δθ To perform fitting, use p θ+Δθ To fit p θ ;
[0162] p θ This represents the probability of parameter θ occurring;
[0163] p θ+Δθ This represents the probability of parameter θ occurring, and the probability of that parameter occurring after the parameter changes.
[0164] This indicates calculating the gradient;
[0165] T is the transpose symbol;
[0166] Δθ represents the change in parameter θ;
[0167] Δθ T It is the transpose of Δθ;
[0168] E z [log p θ ] indicates finding the logarithmic distribution logp θ Expectations;
[0169] This represents the expectation of the gradient of the logarithmic distribution;
[0170] Δθ i This represents the amount of smoothing applied to the i-th parameter;
[0171] Where F θ The empirical Fisher information matrix at θ is defined by equation (4). Using the KL divergence measure, this direction gives the largest target change per unit change in the model. In this case, parameter importance is defined as the ratio of the change in the learning function to the distance between the conditional likelihood distributions at each step in the parameter space. The parameter θ at this point... i Importance can be calculated as follows:
[0172]
[0173] t n This is the total number of training iterations;
[0174] m i The sensitivity of the model output to changes caused by parameter changes is calculated by formula (9);
[0175] It is Fisher's parameter when iterating at t, and the calculation formula is given by formula (7);
[0176] Δθ i (t)=θ i (t+Δt)-θ i (t), θ i (t+Δt) and θ i (t) represents the parameters at different iterations, θ i (t+Δt)-θ i (t) represents the change in parameters under different training iterations;
[0177] ε represents a hyperparameter, and ε>0 is used to prevent the first part of the denominator from being zero.
[0178] By inputting a new data point into the network, the importance of the weight parameter corresponding to that data point can be calculated online using this equation.
[0179] 3. Final Loss Function Analysis
[0180] When learning a new task, to avoid catastrophic forgetting of previous tasks, the final objective function includes a regularization term in addition to the loss L of the new task. This regularization term penalizes parameter changes that are important to the old task. It is based on a combination of the importance of the Fisher information matrix and the sensitivity of the learning function.
[0181]
[0182] L represents the final loss after adding regularization constraints. k (θ) represents the loss of the current task. The parameter θ is the parameter of the last iteration of task k-1. i Fisher, M t (θ i ) is from the first training iteration t0 to the last training iteration t corresponding to task k-1. n The importance of accumulation. The hyperparameter λ∈[0,1] is used to ensure... and M t (θ i The proportions of these two items are in the same order, so their influence is retained. i These are the weights that need to be trained now. These are the weights corresponding to the parameters at the end of task k-1.
[0183] We compare our method with state-of-the-art methods on two datasets (CIFAR-100 and split MNIST). Existing methods for mitigating catastrophic forgetting in continuous learning include regularization methods (SI, EWC, and MAS), knowledge distillation methods (LwF), generative replay methods (GR), and brain-inspired replay methods (BI-R). First, we compare our method with knowledge distillation methods (LwF), regularization methods (SI, EWC, and MAS), and generative replay (GR) on the CIFAR-100 and split MNIST datasets. Then, we combine our method with a brain-inspired replay model (BI-R+Our) on the CIFAR-100 dataset, comparing it with brain-inspired replay (BI-R) and brain-inspired replay combined with SI (BI-R+SI).
[0184] 1. Comparison with existing regularization methods, generative replay methods, and knowledge distillation methods.
[0185] The regularization method was compared with other regularization methods in a basic network consisting of two hidden layers, with dropout of probability p = 0.25 added to the last hidden layer (fully connected layer fc_layer) of the basic network.
[0186] In incremental learning scenarios on the CIFAR-100 dataset, CIFAR-100 was divided into 5, 10, and 20 tasks for incremental learning. The method of this invention was compared with the Generative Replay (GR) method, regularization methods SI, EWC, and MAS. The incremental learning results on the CIFAR-100 dataset are as follows: Figure 2 As shown. Figure 2 The figure shows the average accuracy of different methods across all tasks on different task partitions. In partitioning the complete CIFAR-100 dataset into 5 tasks, the method significantly outperforms the Generative Replay (GR) method and also outperforms the classification performance of regularization methods SI, EWC, and MAS. The method of this invention outperforms MAS by 2.2% and GR by 1.93%. In partitions of 10 and 20 tasks, the method of this invention outperforms the classification accuracy of regularization methods SI, EWC, MAS, and GR.
[0187] In the split MNIST dataset, we divide the complete MNIST dataset into 5 tasks, each containing two digits (binary classification). We then compare our method with the most advanced regularization methods SI, EWC, and MAS, as well as the knowledge distillation method LwF. Figure 3The average classification accuracy of the method of this invention is compared with that of state-of-the-art methods. Results show that the method of this invention exhibits better classification performance than existing regularization and knowledge distillation methods.
[0188] 2. Comparison with brain-inspired replay models
[0189] By combining the method of this invention with brain-inspired replay, and dividing CIFAR-100 into 5 and 10 tasks, the accuracy of each task was compared with that of BI-R and BI-R+SI. The results in Tables 1 and 2 show that the method of this invention has advantages in incremental learning. From the results in the two tables, we can see that the average classification accuracy of our method combined with BI-R is 12.48% and 14.38% higher than that of BI-R, respectively, and 1.4% and 2.78% higher than that of BI-R+SI, respectively.
[0190] Table 1. Accuracy of different methods in CIFAR-100 on five tasks.
[0191] Method Task 1 Task 2 Task 3 Task 4 Task 5 BI-R 3.10 4.40 19.65 35.90 68.20 BI-R+SI 36.90 32.85 41.60 36.55 38.75 BI-R+Our 39.60 34.10 34.75 42.15 43.05
[0192] Table 2. Accuracy of different methods in CIFAR-100 across 10 tasks.
[0193]
[0194] Finally, we also evaluated all methods in the incremental learning setting, using all classes so far (i.e., 100 classes). For example... Figure 4 The image shows the incremental learning results when 100 classes are divided into 5, 10, and 20 classes. In the incremental learning with 5 and 10 classes, as shown... Figure 4 The results in (a) show that combining the method of the present invention with a brain-inspired model (BI-R+Our) is better than combining SI with brain-inspired model (BI-R+SI) in the 2nd to 6th incremental batches. In the 7th to 8th incremental batches, it has similar performance to combining SI with brain-inspired model (BI-R+SI). However, after the 9th incremental batch, the test accuracy of BI-R+Our is higher than that of BI-R+SI. Figure 4 (b) shows the incremental learning of 10 classes. The incremental learning of BI-R+Our is better than the classification accuracy of BI-R+SI. Figure 4 (c) shows the incremental learning across 20 classes. In the first three incremental batches, BI-R+Our and BI-R+SI have similar performance, but in subsequent incremental batches, BI-R+Our significantly outperforms BI-R+SI. The results from these three different class incremental batches demonstrate that, in terms of both final incremental accuracy and average incremental accuracy, the method of this invention combined with brain-inspired replay is superior to BI-R+SI.
[0195] Figure 4 The upper bound results shown are obtained by training a non-incremental model using all training samples from all classes. These results demonstrate that the method of this invention is more efficient and robust in handling class-incremental learning. By using Bayesian parameter updates in class-incremental learning, the model can learn the current task faster and better; simultaneously, by combining the impact of parameter changes on the model output to calculate the importance of parameters and keeping important parameters relatively unchanged, the model can retain knowledge of old tasks while learning new tasks. This confirms that the method of this invention effectively mitigates catastrophic forgetting in continuous learning scenarios in class-incremental learning.
[0196] Figure 5 This is a flowchart of parameter update and weight memory. First, the input new task data D is calculated. 1:k Sample knowledge p(D) 1:k |θ), then convert the expert knowledge into a prior probability distribution p(θ), and calculate the posterior probability distribution p(θ|D) based on the input data. 1:k Finally, calculate the probability distribution p(D) of the next sample data. 1:k+1 |D 1:k ).
[0197] Figure 6 This is a diagram of the brain-inspired replay model structure. The present invention adds two bottleneck attention mechanisms (BAM) to the feature extraction layer and a Dropout layer with a probability of 0.3 to the classification layer, which are based on the original replay model.
[0198] Although embodiments of the invention have been shown and described, those skilled in the art will understand that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the claims and their equivalents.
Claims
1. A regularized continuous learning method based on Bayesian parameter update and weight memory, applied in the field of computer vision, specifically image classification, characterized in that... Includes the following steps: S1, when learning each new image task, uses a brain-inspired replay model to generate replay data; S2, input the new image task and replay data into the brain-inspired replay model, and train it through regularization constraints to determine the importance of the model parameters; the regularization constraints include: S2-1, whenever a new task needs to be learned, the weight parameters are adaptively updated using Bayesian probability, and converted into a Fisher information matrix as a measure of parameter importance; S2-1 includes: S001, using Bayes' theorem, find the optimal parameter that maximizes the probability: Where logp(θ|D) 1:k ) represents data D 1:k Given the optimal parameter θ, the data D from task 1 to task k 1:k The posterior; Representing data D 1:k Optimal parameters Given the data D for tasks 1 to k 1:k The posterior; To determine the sign of the partial derivative; θ represents the parameter to be optimized, which is used when past data D is inaccessible. 1:k The optimal parameters that need to be solved at that time; The optimal parameters are those given the old task data, and are those based on known past data D. 1:k In this case, the optimal parameters have already been obtained; S002, After determining the optimal parameters, update the parameters: Optimal parameters for current task k+1 Updated to: in Indicates the use of data D 1:k+1 Chinese Ambassador D 1:k+1 The parameter θ with the lowest probability; L k+1 (θ) represents the data D k+1 The log-likelihood; λ is a hyperparameter; F i k Indicates the parameter θ in all old tasks i Fisher's information matrix; S003 stores important parameters in Fisher's format as a measure of parameter importance: First, calculate the Fisher information matrix for the current task, treat it as an importance score, and save it. When calculating the Fisher information matrix for the next task's parameters, use the average value for effective updating to obtain the final Fisher information matrix. in: Is the parameter θ during training iteration t? n Fisher information matrix of time parameters; Is the parameter θ during training iteration t? n-1 Fisher information matrix of time parameters; t n This represents the nth training iteration; γ, η are hyperparameters, γ, η∈(0,1) and γ+η=1; S2-2, For each task, calculate each parameter θ in the network model. i The degree to which changes affect the model output is represented by the importance M to the current task. i The parameters with the greatest impact are retained and used in subsequent training tasks. In S2-2, this includes: given data point x k The change in the function output is approximately as follows: Where f(x) k ;θ) is the output of the brain-inspired replay model; θ(t+Δt) represents the weighting parameter at time t+Δt; θ(t) represents the weighting parameter at time t; Δt is the change over time; It is the learning function with respect to the weight parameters θ i The partial derivatives; δ i (t) is the parameter θ i The change Δθ i ; Starting from Task 1, for each observation data point x in the task... k Calculate the change in the learning function caused by each data point. m i This indicates the sensitivity of the model output to changes in parameters; N represents the sum of data points for a given method; g i (x k ) represents the learning function with respect to the weight parameters θ i The gradient; To calculate the magnitude of the gradient, the descent direction is chosen to be the direction of the fastest parameter change, and the change in parameter θ is δ. i =Δθ i →0, approximate the KL divergence using a second-order Taylor series: Where D KL () represents the KL divergence; p θ ||p θ+Δθ Indicates p θ p θ+Δθ To perform fitting, use p θ+Δθ To fit p θ ; p θ This represents the probability of parameter θ occurring, and the probability of that parameter occurring after the parameter changes. p θ+Δθ This represents the probability that θ+Δθ will occur after the parameter θ changes; This indicates calculating the gradient; T is the transpose symbol; Δθ represents the change in parameter θ; Δθ T It is the transpose of Δθ; E z [log p θ ] indicates finding the logarithmic distribution logp θ Expectations; This represents the expectation of the gradient of the logarithmic distribution; Δθ i This represents the amount of smoothing applied to the i-th parameter; The KL divergence measure using formula (10) indicates that this direction gives the largest target change per unit change in the model. In this case, parameter importance is defined as the ratio of the change in the learning function to the distance between the conditional likelihood distributions at each step in the parameter space, where the parameter θ is... i Importance is calculated as follows: Where t n This is the total number of training iterations; m i The sensitivity of the model output to changes caused by parameter changes is calculated by formula (9); It is the parameter θ i Fisher during iteration at point t; Δθ i (t)=θ i (t+Δt)-θ i (t), θ i (t+Δt) and θ i (t) represents the parameters at different iterations, θ i (t+Δt)-θ i (t) represents the change in parameters under different training iterations; ε represents a hyperparameter, and ε > 0 is used to prevent the first part of the denominator from being zero; S3, perform loss function analysis on the model based on the importance of the model parameters.
2. The regularized continuous learning method based on Bayesian parameter update and weight memory according to claim 1, characterized in that, The brain-inspired replay model includes an encoder, a classifier, and a decoder. The encoder includes: five convolutional layers and two hidden layers, each hidden layer having 400 nodes, and a SoftMax output layer. A bottleneck attention mechanism (BAM) is added to the third and / or fourth convolutional layers. The BAM attention infers the attention map along the channel path and the spatial path. Add a dropout layer with a probability p of 0.3 to the classification layer of the classifier.
3. The regularized continuous learning method based on Bayesian parameter update and weight memory according to claim 1, characterized in that, Based on the loss function analysis, the loss function of the brain-inspired replay model is obtained as follows: This represents the final loss after applying regularization constraints; L k (θ) represents the loss of the current task; λ is a hyperparameter; The parameter θ is the parameter of the last iteration of task k-1. i Fisher; M t (θ i ) is from the first training iteration t0 to the last training iteration t corresponding to task k-1. n The importance of accumulation; θ i These are the weights that currently need to be trained; These are the weights corresponding to the parameters at the end of task k-1.