A double compensation network-based continual learning method and system, and an electronic device
By employing a continuous learning method with dual compensation networks, utilizing chain distillation loss and relational compensation contrast loss, and combining dark experience replay, the catastrophic forgetting problem of deep learning models when learning new tasks is solved, achieving stable retention of old knowledge and effective learning of new knowledge.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- NORTH CHINA ELECTRIC POWER UNIV
- Filing Date
- 2026-03-05
- Publication Date
- 2026-06-05
AI Technical Summary
Existing deep learning models are prone to catastrophic forgetting of old knowledge when learning new tasks, especially in cases of imbalanced samples, where traditional methods cannot effectively mitigate representation bias and information loss.
A continuous learning method based on a dual-compensation network is adopted. By mixing training data, chain distillation loss and relation compensation contrast loss are applied, combined with dark experience replay loss, to achieve cross-layer information compensation and construction of sample relation matrix, so as to enhance feature extraction and preserve old knowledge.
Under limited memory constraints, the model can stably learn new knowledge while firmly retaining old knowledge, improving the accuracy and robustness of classification boundaries and reducing dependence on the size of the replay buffer.
Smart Images

Figure CN122154836A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence technology, specifically to a continuous learning method, system, and electronic device based on a dual-compensation network. Background Technology
[0002] With the rapid development of artificial intelligence technology based on deep neural networks, computer technology has made tremendous breakthroughs, and can even rival humans in certain single tasks in some fields.
[0003] However, current deep learning does not possess the human ability to quickly learn new knowledge from complex and diverse real-world scenarios without affecting the stability of previously learned knowledge. This is because current deep models acquire knowledge in the form of parameters, which severely interferes with the parameters of old tasks when learning new tasks, thus causing a "catastrophic forgetting" of previously learned knowledge. To alleviate this catastrophic forgetting problem, a paradigm called continuous learning has emerged.
[0004] Continuous learning methods aim to enable models to learn new tasks without catastrophically forgetting old ones. Existing continuous learning methods can be broadly classified into three categories: regularization-based methods, structure-based methods, and playback-based methods.
[0005] The playback-based method simulates the human brain's memory playback mechanism. It stores a small number of samples from previous tasks in a buffer. When the next task arrives, the samples from previous tasks in the buffer are used together with the current task data for training to consolidate previously learned knowledge. Compared to the other two methods, this biomimetic paradigm is closer to the human mechanism for mitigating forgetting, thus offering a significant advantage in mitigating catastrophic forgetting.
[0006] Recently, a class of playback-based methods, represented by DER (Dark Experience Replay), has attracted widespread attention from researchers. They use knowledge distillation to constrain the consistency of the responses of the same sample at different times, thereby preserving old knowledge and thus mitigating catastrophic forgetting.
[0007] DER refers to storing a small number of samples of past tasks (old experiences) in a memory buffer and mixing them with current data during training when learning new tasks, in order to simulate the brain's memory replay process and thus consolidate old knowledge.
[0008] Knowledge distillation, proposed by Hinton et al. in 2015, is inspired by the "mentor-apprentice" model in education: the teacher model passes on its rich knowledge (such as similarity relationships between categories) to the student model through an output probability distribution (i.e., soft labels). Unlike traditional training that uses true labels (hard labels), soft labels contain more semantic information. For example, for a picture of a cat, the teacher model might output a probability of [cat: 0.9, dog: 0.1], indicating the potential similarity between cats and dogs, while a hard label would only be [cat: 1, dog: 0]. This softened probability distribution helps the student model learn more robust feature representations.
[0009] In continuous learning scenarios, knowledge distillation is extended to a "self-distillation" framework, where the teacher model and the student model are versions of the same model at different training times. For example, in the DER method, the old model acts as the teacher and the new model as the student, preserving old knowledge by constraining the consistency of their outputs on the same replay samples.
[0010] The standard process of knowledge distillation includes three steps: 1. Teacher model generates soft labels: The teacher model performs forward propagation on the input samples to generate soft labels (usually processed by a high-temperature Softmax function to amplify subtle differences between categories).
[0011] 2. Student model mimics soft labels: The student model not only fits the real labels, but also minimizes the difference between its output and the teacher's soft labels through loss functions (such as KL divergence or MSE).
[0012] 3. Knowledge transfer: The ultimate goal is to enable the student model to achieve performance close to that of the teacher model while maintaining its lightweight nature.
[0013] It's easy to see that the quality of sample responses is a prerequisite for knowledge preservation in these methods. A high-quality initial sample response allows as much knowledge as possible to be preserved to mitigate forgetting. To enrich the knowledge contained in the model's response, it's necessary to improve the network's ability to represent knowledge and minimize information loss during training.
[0014] While the replay-based approach has achieved promising results, the limited buffer size restricts the number of samples available for replay compared to the current sample size. Therefore, when training these samples together using the DER paradigm, data imbalance inevitably leads to a biased representation towards the current class, potentially causing misclassification. To enrich the model's response with knowledge, it's necessary to enhance the network's ability to represent knowledge and minimize information loss during training.
[0015] To achieve better classification results, we need a good feature extractor to obtain less biased and discriminative features. Currently, many continuous learning methods utilize supervised contrastive learning (using a metric function to bring similar samples closer together and push dissimilar samples further apart) to make the features obtained by the feature extractor more discriminative, thereby achieving better classification using discriminative features. However, traditional contrastive learning only achieves classification through clear task boundaries and does not correct the representation bias caused by sample imbalance. This bias is essentially caused by the lack of relationships between samples. Summary of the Invention
[0016] In view of this, the purpose of the present invention is to provide a continuous learning method, system, and electronic device based on a dual-compensation network, so as to solve the catastrophic forgetting problem caused by representational bias due to information loss within the network and scarcity of replay samples when neural networks continuously learn new tasks in the prior art.
[0017] According to a first aspect of the present invention, a continuous learning method based on a dual-compensation network is provided, comprising: Step S1: Obtain the data stream of the current task and the playback data of the memory buffer, combine the two into mixed training data, and provide it to the neural network model for training; the memory buffer is used to store samples of previous tasks and their corresponding old model output responses. Step S2: During the forward propagation of the mixed training data through the neural network model, feature maps generated by different layers of the neural network model are extracted and processed, and chain distillation loss is calculated based on the feature maps to achieve cross-layer information compensation. Step S3: Extract the deep feature map from the feature map, and based on the deep feature map, construct the relationship matrix between different data instances in the mixed training data, and calculate the relationship compensation contrast loss based on the relationship matrix to compensate for the representation bias caused by sample imbalance. Step S4: Calculate the loss based on dark experience replay, and sum it with the chain distillation loss and the relational compensation contrast loss to form the overall objective function; based on this overall objective function, use the mixed training data to calculate the gradient through the backpropagation algorithm, and update the parameters of the neural network model to minimize the overall objective function.
[0018] According to a second aspect of the present invention, a continuous learning system based on a dual-compensation network is provided, comprising: The training module is used to acquire the data stream of the current task and the replay data of the memory buffer, combine the two into mixed training data, and provide it to the neural network model for training; the memory buffer is used to store samples from previous tasks and their corresponding old model output responses. The feature compensation hierarchical distillation module is used to extract and process feature maps generated by different layers of the neural network model during the forward propagation of mixed training data through the neural network model, and calculate chain distillation loss based on the feature maps to achieve cross-layer information compensation. The relation compensation module is used to extract deep feature maps from the feature maps, construct a relation matrix between different data instances in the mixed training data based on the deep feature maps, and calculate the relation compensation contrast loss based on the relation matrix to compensate for the representation bias caused by sample imbalance. An update module is used to calculate the loss based on dark experience replay and to perform a weighted summation of it with the chain distillation loss and the relational compensation contrast loss to form a total objective function. Based on this total objective function, the gradient is calculated using the mixed training data through the backpropagation algorithm, and the parameters of the neural network model are updated to minimize the total objective function.
[0019] According to a third aspect of the present invention, an electronic device is provided, comprising: The processor, communication interface, memory, and communication bus are connected, with the processor, communication interface, and memory communicating with each other via the communication bus. The memory is used to store computer programs; When the processor executes a program stored in the memory, it implements the above method.
[0020] According to a fourth aspect of the present invention, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the method described above.
[0021] The technical solutions provided by the embodiments of the present invention may include the following beneficial effects: Firstly, through the mixed training data replay in step S1 and the dark experience replay loss in step S4, the model is forced to review the key knowledge of the old task when learning a new task, which directly combats the forgetting caused by parameter coverage, thus providing a solid foundation for the model's stability.
[0022] Secondly, the compensation mechanisms in steps S2 and S3 further solidify this stability. The chain distillation in step S2 ensures the integrity of the transmission of old knowledge within the model, while the relational compensation in step S3 prevents the model from being biased towards new tasks due to data imbalance.
[0023] Specifically, step S2 breaks down the barriers between network layers through chain distillation, enabling the effective flow and compensation of shallow detail information (such as texture and edges) to deep semantic information, reducing information loss within the network, and making the final model response contain richer and higher quality knowledge.
[0024] Step S3 constructs a sample relationship matrix using deep feature maps, uncovering and utilizing rich semantic relationships that are overlooked in traditional contrastive learning. This not only alleviates representational bias caused by insufficient replay samples but also learns more discriminative features, directly improving the accuracy of classification boundaries.
[0025] At the same time, the model maintains necessary plasticity by learning from current task data normally. This allows the model to stably learn new knowledge while firmly retaining old knowledge under limited memory constraints.
[0026] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit the invention. Attached Figure Description
[0027] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0028] Figure 1 This is a flowchart illustrating a continuous learning method based on a dual-compensation network according to an exemplary embodiment; Figure 2 This is a schematic diagram of the internal structure of a feature-compensated hierarchical distillation module according to an exemplary embodiment; Figure 3 This is a schematic diagram of the internal structure of a relationship compensation module according to an exemplary embodiment; Figure 4 This is a schematic diagram of the Fashion-MNIST dataset according to an exemplary embodiment. Detailed Implementation
[0029] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Rather, they are merely examples of apparatuses and methods consistent with some aspects of the invention as detailed in the appended claims. Example 1
[0030] Figure 1 This is a flowchart illustrating a continuous learning method based on a dual-compensation network according to an exemplary embodiment, such as... Figure 1 As shown, the method includes: Step S1: Obtain the data stream of the current task and the playback data of the memory buffer, combine the two into mixed training data, and provide it to the neural network model for training; the memory buffer is used to store samples of previous tasks and their corresponding old model output responses. Step S2: During the forward propagation of the mixed training data through the neural network model, feature maps generated by different layers of the neural network model are extracted and processed, and chain distillation loss is calculated based on the feature maps to achieve cross-layer information compensation. Step S3: Extract the deep feature map from the feature map, and based on the deep feature map, construct the relationship matrix between different data instances in the mixed training data, and calculate the relationship compensation contrast loss based on the relationship matrix to compensate for the representation bias caused by sample imbalance. Step S4: Calculate the loss based on dark experience replay, and sum it with the chain distillation loss and the relational compensation contrast loss to form the overall objective function; based on this overall objective function, use the mixed training data to calculate the gradient through the backpropagation algorithm, and update the parameters of the neural network model to minimize the overall objective function.
[0031] It should be noted that the technical solution provided in this embodiment is applicable to scenarios including but not limited to: 1. Intelligent Security Monitoring: Cameras deployed in shopping malls and communities need to continuously learn new product styles, vehicle models, or suspicious behaviors, while maintaining their ability to identify existing targets. This method allows the system to incrementally learn new knowledge without requiring complete retraining, significantly reducing update costs and latency.
[0032] 2. Industrial visual quality inspection: On the production line, when product models are updated or new defect types are added, the quality inspection system can use this method to quickly learn and identify new defects, while maintaining high-precision detection of existing defects to ensure the continuity of production quality.
[0033] 3. Smart Home and Robots: Home service robots need to constantly recognize newly purchased items, understand new voice commands, and adapt to new home environment layouts, while not forgetting how to perform basic operations (such as obstacle avoidance and turning on existing home appliances).
[0034] 4. E-commerce and Content Recommendation: User interests and the platform's product / content library are constantly changing. Recommendation systems can use this method to continuously learn about emerging trending products and evolving user tastes, while also retaining long-term user preferences, thereby achieving more accurate personalized recommendations.
[0035] 5. Intelligent Voice Assistant: The assistant needs to learn new vocabulary, sentence structures, and user habits (such as new contacts and schedules). This method ensures that it does not forget previous user commands or important information when absorbing new information, providing a more stable and reliable service.
[0036] 6. Autonomous Driving Systems: Vehicles encounter countless new scenarios throughout their lifecycle (such as new vehicle models, new road signs, and special construction zones). This method allows the onboard system to continuously learn from these rare or emerging scenarios while ensuring that its ability to recognize regular driving rules and scenarios never declines, greatly improving the system's safety and adaptability.
[0037] 7. Medical Imaging Diagnosis: New disease variants, imaging equipment, and technologies are constantly emerging. AI-assisted diagnostic systems can utilize this method to continuously learn the ability to diagnose new diseases while firmly grasping diagnostic knowledge of known diseases, thus avoiding the increased risk of misdiagnosis of existing diseases due to learning new knowledge.
[0038] It is understandable that the technical solution provided in this embodiment firstly uses the mixed training data replay in step S1 and the dark experience replay loss in step S4 to force the model to review the key knowledge of the old task when learning a new task, which directly combats the forgetting caused by parameter coverage, thus providing a solid foundation for the stability of the model.
[0039] Secondly, the compensation mechanisms in steps S2 and S3 further solidify this stability. The chain distillation in step S2 ensures the integrity of the transmission of old knowledge within the model, while the relational compensation in step S3 prevents the model from being biased towards new tasks due to data imbalance.
[0040] Specifically, step S2 breaks down the barriers between network layers through chain distillation, enabling the effective flow and compensation of shallow detail information (such as texture and edges) to deep semantic information, reducing information loss within the network, and making the final model response contain richer and higher quality knowledge.
[0041] Step S3 constructs a sample relationship matrix using deep feature maps, uncovering and utilizing rich semantic relationships that are overlooked in traditional contrastive learning. This not only alleviates representational bias caused by insufficient replay samples but also learns more discriminative features, directly improving the accuracy of classification boundaries.
[0042] At the same time, the model maintains necessary plasticity by learning from current task data normally. This allows the model to stably learn new knowledge while firmly retaining old knowledge under limited memory constraints.
[0043] In practice, step S2 includes: Step S21: The feature maps of different layers of the neural network are processed by the feature alignment generator. The feature alignment generator performs bilinear upsampling and spatial softening operations in sequence to achieve dimensional alignment and normalization of feature maps at different levels. Step S22: Based on the aligned feature maps, calculate the distillation loss layer by layer between adjacent layers of the network, thereby forming a knowledge distillation chain from shallow to deep layers. The chain-like distillation loss... The calculation formula is as follows:
[0044] Where M represents the total number of layers in the neural network, This represents the feature map of the m-th layer. For feature alignment generator function, This is the interlayer distillation loss function.
[0045] Understandably, the feature alignment generator in step S21 achieves standardized alignment of hierarchical feature maps with different resolutions and levels of abstraction in space and dimensions, laying the foundation for subsequent effective inter-layer knowledge comparison and transfer.
[0046] In traditional network training, shallow features (rich in spatial details and texture information) are inevitably filtered and discarded when passed to deeper layers. This approach, through the chain distillation loss constructed in step S22, forces knowledge distillation between adjacent layers, forming an information highway that runs through the network. This allows more beneficial shallow details to be preserved and integrated into the final deep semantic representation. This directly results in the model's final output response containing richer and higher-quality knowledge, providing a high-quality prerequisite for subsequent response-based knowledge preservation (such as dark experience replay).
[0047] Chain distillation is not unidirectional. While achieving information compensation from the shallow layer to the deep layer, the rich semantic information obtained from the deep layer also serves as a supervisory signal, influencing the learning of shallow features through the distillation chain.
[0048] This two-way interaction constitutes an implicit feedback mechanism. It allows shallow feature extractors to not only focus on basic edges and textures, but also, guided by deep semantics, learn representations more favorable to the final task. This greatly enhances the network's overall representation learning ability, enabling the model to learn more discriminative features.
[0049] The hierarchical features optimized in step S2 form the basis for the relationship compensation module in step S3. Higher-quality deep feature maps mean a more accurate constructed sample relationship matrix with richer semantic information. The hierarchical information compensation provided in step S2 offers better material for the relationship compensation in step S3, while the discriminative features learned through relationship compensation positively influence the feature extractor through the training process, further optimizing the hierarchical features. This interaction ensures that the final features used for classification are not only information-rich but also highly discriminative and robust, effectively resisting interference from data imbalance.
[0050] In practice, step S3 includes: Step S31: For any two data instances in a batch of the mixed training data, extract their corresponding deep feature maps and calculate the relationship matrix between them. This is used to capture the semantic relationships between samples; the formula for calculating the relationship matrix is as follows: ; in, and These are the deep feature maps of the i-th and j-th data instances, respectively; Step S32: Utilize the aforementioned relationship matrix For the original deep feature map and By supplementing the relationships, new deep feature maps with enhanced relationships are obtained. and ; Step S33: Combine the original deep feature map with the new deep feature map after relationship enhancement to construct a hybrid contrastive loss as the relationship compensation contrastive loss. This method utilizes both the sample's own features and the relationships between samples to enhance the discriminative power of the features; the calculation formula for the hybrid contrast loss is as follows: ; Where p is the balance coefficient and N is the batch size. For indicator functions, To have the same label as the i-th sample The number of samples, and This is the contrast loss term calculated based on cosine similarity.
[0051] Preferably, the following formula is used to calculate and and ,include: ; ; in, This is a similarity metric function used to calculate the degree of similarity between two feature vectors; This is a temperature coefficient used to adjust the sharpness of the probability distribution, affecting the model's attention to difficult samples; The summation Σ in the denominator is used to calculate the similarity distribution between sample i and k for all samples k except sample i itself in the entire batch of samples of size 2N; where the batch of samples of size 2N is obtained by expanding a batch of samples of size N to 2N data points using data augmentation.
[0052] Understandably, step S31 is no longer limited to the features of a single sample, but actively calculates the relationship matrix between the deep feature maps of any two data instances. This relationship matrix quantitatively characterizes the strength of the association between samples in the high-level semantic space.
[0053] Traditional methods, when faced with imbalanced data (few replay samples), tend to favor learning features from the more numerous new samples. This approach introduces this explicit "relationship" as a supervisory signal, forcing the model to consider and incorporate the semantic connections between features and other samples when constructing feature representations. This effectively provides rich, contextual information derived from sample relationships to minority class (old task) samples, directly and effectively correcting biases in the representation learning process and making the learned features less sensitive to the number of classes.
[0054] Step S32 transforms the original features using the relation matrix to generate a "new feature map with enhanced relations". Step S33 innovatively combines the original feature map with the relation-enhanced feature map to construct a hybrid contrastive loss.
[0055] This method achieves dual feature utilization. The model not only needs to learn how to make the original features themselves highly discriminative (bringing similar features closer together and distancing them from dissimilar ones), but also must ensure that the "relationship-enhancing features" derived from sample relationships are equally discriminative. This dual constraint greatly strengthens the constraint on the feature space, enabling the model to uncover deeper and more robust distinguishing patterns. The ultimately learned features are not only based on the content of the samples themselves, but also contain rich knowledge of the relationships between samples, and their discriminative power is far superior to features obtained through traditional contrastive learning.
[0056] The input to step S3 depends on the "deep feature map" optimized by the chain distillation in step S2. A deep feature map rich in more information (thanks to the chain distillation) helps to calculate a more accurate sample relationship matrix.
[0057] Steps S2 and S3 are not isolated but form a synergistic enhancement loop. The hierarchical information compensation in step S2 provides higher-quality raw materials (deep features) for step S3, resulting in more effective sample relationships. Conversely, the more discriminative features learned in step S3 through relationship compensation influence the feature extractor through gradient backpropagation positive feedback, thereby helping each layer (including shallow layers) in step S2 learn feature patterns that better facilitate relationship construction. This close collaboration between modules achieves overall performance gains.
[0058] It is understandable that the technical solution provided in this embodiment reduces the absolute dependence on the size of the playback buffer by focusing on "relationships" rather than simply the amount of data.
[0059] In the more realistic setting of generalized continuous learning, where task boundaries are unknown, models cannot rely on explicit task identifiers. This approach achieves knowledge preservation by mining the inherent relational structure within the data; this task-independent characteristic makes it more applicable and robust.
[0060] In practice, the loss based on dark experience replay is calculated using the following formula. ,include:
[0061] ; in, Dark experience replay loss is the basic replay loss function in continuous learning. It achieves knowledge preservation by constraining the current model's output response to replay samples to remain consistent with the old model's output response. Enhanced Dark Experience Replay Loss, in Based on this, a supervision loss based on real labels is added to achieve dual protection of output consistency constraints and real label supervision; M is the cross-entropy loss calculated by the model on the current new task data, where M is the memory buffer. These are the playback data triples extracted from M. and This represents the input data for historical tasks. and This represents the true labels corresponding to the input data of historical tasks; and The old model output response corresponding to the input data of the historical task is the teacher signal in knowledge distillation; α and β are hyperparameters; and A parameterized neural network model; For loss function, The expectation is the average value calculated over all possible data sampled from a certain distribution, which is approximated by randomly sampling a batch of data from the memory buffer M.
[0062] Preferably, step S4, calculating the loss based on dark experience replay and then weighting and summing it with the chain distillation loss and the relational compensation comparison loss to form the overall objective function, specifically involves:
[0063] in, and These are hyperparameters used to balance various terms. To enhance the loss of Dark Experience Replay, This is due to losses during chain distillation. To compensate for the loss in relational comparison.
[0064] Understandable, The core of the loss term lies in knowledge distillation. Instead of directly using potentially overly absolute true labels (hard labels), it utilizes the output response of the old model to replay samples (soft labels, i.e., "dark knowledge") as a supervisory signal to constrain the output behavior of the new model to be consistent with it.
[0065] This output consistency-based constraint can directly and effectively "distill" the complex decision boundaries and inter-class relationships learned by the old model into the new model. It provides a basis for learning new tasks (from...). The dominant regularization term provides a powerful regularization term that acts as an "anchor" to stabilize the model parameters, preventing them from making destructive updates to parameters related to old tasks when learning new knowledge. This precisely balances the model's stability (preserving old knowledge) and plasticity (learning new knowledge).
[0066] exist Based on this, an additional cross-entropy loss term (i.e., the β term in the formula) based on the real labels (hard labels) of the replay samples is added. This constitutes a dual guarantee mechanism of "output consistency constraint + real label supervision".
[0067] This design delivers significant performance improvements. On one hand, distillation loss ensures consistent "behavior"; on the other hand, true label loss ensures correct "answers." The latter corrects potential errors or biases in the old model, preventing erroneous knowledge from being continuously distilled and solidified. Simultaneously, it strengthens the consolidation of class discriminant bounds, making the model more reliable in maintaining performance on older tasks. Experimental results show that DER++ typically outperforms DER, validating the effectiveness of dual supervision.
[0068] In practice, to verify the feasibility of the technical solution provided in this embodiment, the following verification experiment was conducted: Setup: The effectiveness of this method is validated in two scenarios: Task-Incremental Learning (Task-IL) and Class-Incremental Learning (Class-IL). Task-Incremental Learning divides training samples into different tasks and provides task labels for each task during both the training and testing phases. Class-Incremental Learning only provides task labels during the training phase; they cannot be used during the testing phase. This means the model needs to infer the task labels provided by Task-Incremental Learning during the testing phase, making it a more stringent scenario than Task-Incremental Learning.
[0069] Datasets: Experiments were conducted on the CIFAR-10, CIFAR-100, and Tiny-ImageNet datasets to validate the effectiveness of the proposed method. CIFAR-10 consists of 10 classes, each containing 6000 color images (32x32 pixels), with 5000 images used as the training set and 1000 as the test set. CIFAR-100 consists of 100 classes, with 500 images per class used as training samples and 100 images per class used as test samples; otherwise, it is similar to CIFAR-10. Tiny-ImageNet is a subset of ImageNet, containing 200 classes, with 500 images per class used as training samples. The CIFAR-10, CIFAR-100, and Tiny-ImageNet datasets were divided into 5, 20, and 10 tasks, respectively, with each task containing 2, 5, and 20 classes, respectively.
[0070] Implementation details: An untrained ResNet18 was used as the backbone network for these three datasets, and the mapping head in the two-layer contrastive learning used a two-layer fully connected network. Due to the varying complexity of the different datasets, different numbers of epochs were used when training the model.
[0071] The epoch numbers for CIFAR-10, CIFAR-100, and Tiny-ImageNet are 50, 50, and 100, respectively. When training data arrives, a batch of samples is collected from the current data and the buffer, with a batch size of 32. The model is optimized using stochastic gradient descent. After each batch of training, the buffer is updated using a reservoir sampling method. In the two-layer contrastive learning module, the temperature coefficient... Set to 0.7. In the knowledge distillation module. and The weights of the two modules in the total loss are set to 0.04 and 0.16 respectively. and All values are 0.1. The model was implemented using the PyTorch framework and trained and tested on an NVIDIA Tesla V100 GPU.
[0072] Method Comparison: Twelve state-of-the-art methods were selected for comparison with our method. These included ER, A-GEM, DER, DER++, LARS, DualNet, GeoDL, CER, HAL, FRD, and ER-ACE. The setting of joint training across all tasks was used as the upper bound, and SGD without any forgetting mitigation methods during training was used as the lower bound. All experimental results are the average of five runs.
[0073] Incremental Class-IL Experiment Results: Table 1 shows the experimental results under the Class-IL setting. It can be seen that, except for the Tiny-ImageNet dataset, our method (DCN) outperforms competitors on all datasets. Specifically, our method achieves 88.43% and 59.25% accuracy on the Cifar-10 and Cifar-100 datasets with a buffer size of 5120, respectively, exceeding the second-best method by at least 2.52% and 4.68%. Although our method is lower than ER-ACE on the Tiny-ImageNet dataset with a buffer size of 500, it is only 0.75% lower. When the buffer size is 200 and 5120, our method outperforms it by 1.14% and 2.56%, respectively. Similar to other methods, our method's performance improves with increasing buffer size. Compared to other methods, our method achieves greater performance improvement with increasing buffer size. This is because when more replay samples are provided to the compensation network, information gain is generated in the large amount of knowledge, thus retaining more old knowledge to mitigate the impact of catastrophic forgetting.
[0074] Table 1. Average accuracy under incremental settings. Best result is bolded, second best result is underlined.
[0075] Incremental task experiment results: As shown in Table 2, under the incremental task setting, our method (DCN) consistently outperforms all competitors on all datasets with all buffer sizes. Specifically, for the Cifar-10 dataset, DCN only brings a slight performance improvement, outperforming the second-best method CO2L by 0.58%, 0.26%, and 0.37% for buffer sizes of 200, 500, and 5120, respectively. This is because the performance of the compared methods on the Cifar-10 dataset is already close to its limit, thus limiting the performance improvement of our method. For the CIFAR-100 and TinyImageNet datasets, our method outperforms the second-best method by 1.38%~2.70%, 1.50%~2.01%, and 0.95%~2.32% for buffer sizes of 200, 500, and 5120, respectively. For the more complex TinyImageNet dataset, our method achieves a greater performance improvement compared to the second-best method. This is because hierarchical distillation enables mutual compensation of information between different layers, while the contrastive loss of the constructed feature maps fully utilizes the relationships between samples. Thus, for more complex datasets, this method can obtain more spatial and semantic information for replay than other methods, thereby retaining more knowledge from older tasks to mitigate catastrophic forgetting.
[0076] Table 2. Average accuracy under task increment settings. Best result is bolded, second best result is underlined.
[0077] Results under the General Continuous Learning (GCL) setting: Table 3 shows the results under the GCL setting, where our method (DCN) achieved the best performance in all cases. Specifically, for the UG-CIFAR-100 dataset, the DCN method achieved average accuracies of 38.22%, 42.25%, and 44.27% with buffer sizes of 200, 500, and 1000, respectively, which are 8.99%, 7.46%, and 3.76% higher than the second-best method. Furthermore, our method also outperformed the second-best method on the LG-CIFAR-100 dataset by 8.87%, 7.62%, and 4.55% in average accuracy, representing a significant performance improvement. This indicates that the DCN method is more suitable for the GCL setting. This is because in the GCL setting, Task-ids are unavailable during the training and testing phases, meaning that specific prior knowledge cannot be utilized to mitigate catastrophic forgetting. During experience replay, it is necessary to mine some inherent non-specific scene information to consolidate knowledge of old tasks. This method uses two modules, hierarchical feature compensation and contrast relationship compensation, to mine and utilize non-specific scene information (network hierarchical information and inter-sample information), and consolidates knowledge of old tasks by replaying this information.
[0078] Table 3. Average accuracy under typical continuous learning settings, with optimal accuracy highlighted in bold.
[0079] Ablation experiment: To verify the performance contribution of different components in the method, ablation experiments were conducted on the S-CIFAR-10 and UG-CIFAR-100 datasets. Since this method is an improvement on DER++, DER++ was used as the baseline. The impact of the MGL (relation compensation module) and FAG (feature compensation hierarchical distillation module) modules on model performance was observed. The experimental results are shown in Table 4. It can be seen that on the S-CIFAR-10 dataset, the performance of the MGL and FAG modules is improved by at least 2.4% and 1.57% respectively compared to DER++. Especially when the buffer size is 500, the improvements are 3.26% and 3.07% respectively. For the UG-CIFAR-100 dataset, the MGL and FAG modules, with buffer sizes of 200 and 500, respectively, improve the performance of the baseline DER++ by 7.13%–8.23% and 6.72%–7.13%. Furthermore, these two modules are complementary; their combined performance is higher than the performance of either module individually. Taking the UG-CIFAR-100 dataset as an example, when the buffer size is 500, the combined DCN performs 1.98% and 2.39% better than the individual MGL and FAG modules, respectively. This also verifies that: Information compensation enriches semantic information, which is beneficial for constructing sample relationships. At the same time, relationship compensation can further enhance the representation ability of deep networks. Then, through hierarchical distillation, it will positively influence the features of shallow layers, deepening the interaction between shallow and deep features, thereby further improving the knowledge contained in the response.
[0080] Table 4 Ablation studies of different parts on CIFAR-100
[0081] In practical application, when the method needs to be deployed in a visual recognition system to classify and identify products in images captured by a camera, it includes the following steps: Initialization and Data Preparation: Initialize a convolutional neural network as the neural network model and load a training dataset containing images of multiple product categories; preprocess the images in the training dataset, including image normalization and image enhancement operations, including random rotation and random flipping, to simulate the diversity of images captured by cameras in a real production environment; See Figure 4 Taking the Fashion-MNIST dataset as an example, this dataset contains 10 different categories of fashion items (such as T-shirts, pants, shoes, etc.) and is suitable for image classification tasks. The dataset contains 60,000 training images and 10,000 test images, with an image size of 28x28 pixels and grayscale representation.
[0082] Suppose this algorithm is applied to camera image processing in a shopping mall security system. By classifying goods, it can identify different categories of items (such as clothing, shoes, etc.) and dynamically adapt to updates in product categories. When new seasonal styles are introduced, this method helps the model quickly adapt to the recognition of new items while avoiding forgetting older styles, thus improving the overall recognition accuracy of the system.
[0083] In practical applications, this algorithm can be used to improve the classification accuracy of real-time image data acquired by cameras. To simulate a production environment, the following preprocessing steps are performed on Fashion-MNIST: Image normalization: Normalizes image pixel values to the range of [0, 1] to improve model training performance.
[0084] Image enhancement: Random rotation, flipping, and other enhancement operations simulate the diversity of images in real-world environments.
[0085] Incremental task sequence construction: Product images from different periods or batches are defined as a continuous task sequence, where the data stream of the current task corresponds to new product images newly captured by the camera or introduced in a new season, and the playback data in the memory buffer corresponds to old product images learned in historical tasks and their corresponding old model outputs. Incremental training and replay of the model: For each new task in the task sequence, execute steps S1 to S4, including: The model is trained by mixing images of new products with images of old products replayed from the memory buffer. Cross-layer information compensation is achieved by calculating chain distillation loss. Contrast loss is calculated by constructing a sample relationship matrix to compensate for representation bias. The model parameters are optimized by combining the dark experience replay loss. This allows the model to adapt to recognizing new products while maintaining high recognition accuracy for learned old products. Model deployment and online updates: The trained model is deployed on the visual recognition system; when the system captures a new product category or style through the camera, the new image is added to the training dataset, and the above incremental training and playback steps are repeated to achieve continuous learning and dynamic optimization of the model on the production line.
[0086] It is understandable that the technical solution provided in this embodiment improves the model's response quality while also leveraging the relationships between samples to construct a contrastive loss, thereby obtaining more discriminative features for classification. Specifically, a hierarchical distillation module is designed to retain more useful information by constructing distillation chains between different layers of the network, and to obtain a high-quality response by compensating for shallow structural information with deep linguistic information; simultaneously, to improve the model's classification ability, a contrastive loss utilizing feature maps is designed based on traditional contrastive learning. By utilizing the relationships between samples, more semantic information is compensated for to construct more discriminative features. Extensive experiments demonstrate that the method provided in this embodiment exhibits strong competitiveness. Example 2
[0087] An exemplary embodiment illustrates a continuous learning system based on a dual-compensation network, the system comprising: The training module is used to acquire the data stream of the current task and the replay data of the memory buffer, combine the two into mixed training data, and provide it to the neural network model for training; the memory buffer is used to store samples from previous tasks and their corresponding old model output responses. Feature-compensated hierarchical distillation module (see) Figure 2 This is used to extract and process feature maps generated by different layers of the neural network model during the forward propagation of mixed training data through the neural network model, and to calculate chain distillation loss based on the feature maps in order to achieve cross-layer information compensation. Relationship compensation module (see) Figure 3 The deep feature map is used to extract the deep feature map from the feature map, and based on the deep feature map, a relation matrix between different data instances in the mixed training data is constructed, and the relation compensation contrast loss is calculated based on the relation matrix to compensate for the representation bias caused by sample imbalance. An update module is used to calculate the loss based on dark experience replay and to perform a weighted summation of it with the chain distillation loss and the relational compensation contrast loss to form a total objective function. Based on this total objective function, the gradient is calculated using the mixed training data through the backpropagation algorithm, and the parameters of the neural network model are updated to minimize the total objective function.
[0088] See Figure 3 Because different layers of the network have different output dimensions, using Let represent the feature map output of the m-th layer of the network, where d, H, and W represent the channel, height, and width, respectively. The outputs of each layer are aligned using a bilinear upsampling operation, denoted as . For the aligned output, to facilitate distillation, a spatial softening operation is performed on the output, denoted as . The two operations on features described above are combined and termed FAG (Feature Alignment Generator). Formally, FAG consists of a function... express.
[0089] It is understandable that the technical solution provided in this embodiment firstly uses the mixed training data replay in step S1 and the dark experience replay loss in step S4 to force the model to review the key knowledge of the old task when learning a new task, which directly combats the forgetting caused by parameter coverage, thus providing a solid foundation for the stability of the model.
[0090] Secondly, the compensation mechanisms in steps S2 and S3 further solidify this stability. The chain distillation in step S2 ensures the integrity of the transmission of old knowledge within the model, while the relational compensation in step S3 prevents the model from being biased towards new tasks due to data imbalance.
[0091] Specifically, step S2 breaks down the barriers between network layers through chain distillation, enabling the effective flow and compensation of shallow detail information (such as texture and edges) to deep semantic information, reducing information loss within the network, and making the final model response contain richer and higher quality knowledge.
[0092] Step S3 constructs a sample relationship matrix using deep feature maps, uncovering and utilizing rich semantic relationships that are overlooked in traditional contrastive learning. This not only alleviates representational bias caused by insufficient replay samples but also learns more discriminative features, directly improving the accuracy of classification boundaries.
[0093] At the same time, the model maintains necessary plasticity by learning from current task data normally. This allows the model to stably learn new knowledge while firmly retaining old knowledge under limited memory constraints. Example 3
[0094] An electronic device according to an exemplary embodiment includes: The processor, communication interface, memory, and communication bus are connected, with the processor, communication interface, and memory communicating with each other via the communication bus. The memory is used to store computer programs; When the processor executes a program stored in the memory, it implements the above method.
[0095] It is understandable that the technical solution provided in this embodiment firstly uses the mixed training data replay in step S1 and the dark experience replay loss in step S4 to force the model to review the key knowledge of the old task when learning a new task, which directly combats the forgetting caused by parameter coverage, thus providing a solid foundation for the stability of the model.
[0096] Secondly, the compensation mechanisms in steps S2 and S3 further solidify this stability. The chain distillation in step S2 ensures the integrity of the transmission of old knowledge within the model, while the relational compensation in step S3 prevents the model from being biased towards new tasks due to data imbalance.
[0097] Specifically, step S2 breaks down the barriers between network layers through chain distillation, enabling the effective flow and compensation of shallow detail information (such as texture and edges) to deep semantic information, reducing information loss within the network, and making the final model response contain richer and higher quality knowledge.
[0098] Step S3 constructs a sample relationship matrix using deep feature maps, uncovering and utilizing rich semantic relationships that are overlooked in traditional contrastive learning. This not only alleviates representational bias caused by insufficient replay samples but also learns more discriminative features, directly improving the accuracy of classification boundaries.
[0099] At the same time, the model maintains necessary plasticity by learning from current task data normally. This allows the model to stably learn new knowledge while firmly retaining old knowledge under limited memory constraints. Example 4
[0100] An exemplary embodiment illustrates a computer-readable storage medium having a computer program stored thereon that, when executed by a processor, implements the method described above.
[0101] It is understandable that the technical solution provided in this embodiment firstly uses the mixed training data replay in step S1 and the dark experience replay loss in step S4 to force the model to review the key knowledge of the old task when learning a new task, which directly combats the forgetting caused by parameter coverage, thus providing a solid foundation for the stability of the model.
[0102] Secondly, the compensation mechanisms in steps S2 and S3 further solidify this stability. The chain distillation in step S2 ensures the integrity of the transmission of old knowledge within the model, while the relational compensation in step S3 prevents the model from being biased towards new tasks due to data imbalance.
[0103] Specifically, step S2 breaks down the barriers between network layers through chain distillation, enabling the effective flow and compensation of shallow detail information (such as texture and edges) to deep semantic information, reducing information loss within the network, and making the final model response contain richer and higher quality knowledge.
[0104] Step S3 constructs a sample relationship matrix using deep feature maps, uncovering and utilizing rich semantic relationships that are overlooked in traditional contrastive learning. This not only alleviates representational bias caused by insufficient replay samples but also learns more discriminative features, directly improving the accuracy of classification boundaries.
[0105] At the same time, the model maintains necessary plasticity by learning from current task data normally. This allows the model to stably learn new knowledge while firmly retaining old knowledge under limited memory constraints.
[0106] It is understood that the same or similar parts in the above embodiments can be referred to each other, and the contents not described in detail in some embodiments can be referred to the same or similar contents in other embodiments.
[0107] It should be noted that in the description of this invention, the terms "first," "second," etc., are used for descriptive purposes only and should not be construed as indicating or implying relative importance. Furthermore, in the description of this invention, unless otherwise stated, "a plurality of" means at least two.
[0108] Any process or method description in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more executable instructions for implementing a particular logical function or process, and the scope of the preferred embodiments of the invention includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functions involved, as will be understood by those skilled in the art to which embodiments of the invention pertain.
[0109] It should be understood that various parts of the present invention can be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.
[0110] Those skilled in the art will understand that all or part of the steps of the methods in the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, the program includes one or a combination of the steps of the method embodiments.
[0111] Furthermore, the functional units in the various embodiments of the present invention can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into a module. The integrated module can be implemented in hardware or as a software functional module. If the integrated module is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium.
[0112] The storage media mentioned above can be read-only memory, disk, or optical disk, etc.
[0113] In the description of this specification, references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.
[0114] Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of the present invention.
Claims
1. A continuous learning method based on a dual-compensation network, characterized in that, include: Step S1: Obtain the data stream of the current task and the playback data of the memory buffer, combine the two into mixed training data, and provide it to the neural network model for training; the memory buffer is used to store samples of previous tasks and their corresponding old model output responses. Step S2: During the forward propagation of the mixed training data through the neural network model, feature maps generated by different layers of the neural network model are extracted and processed, and chain distillation loss is calculated based on the feature maps to achieve cross-layer information compensation. Step S3: Extract the deep feature map from the feature map, and based on the deep feature map, construct the relationship matrix between different data instances in the mixed training data, and calculate the relationship compensation contrast loss based on the relationship matrix to compensate for the representation bias caused by sample imbalance. Step S4: Calculate the loss based on dark experience replay, and sum it with the chain distillation loss and the relational compensation contrast loss to form the overall objective function; based on this overall objective function, use the mixed training data to calculate the gradient through the backpropagation algorithm, and update the parameters of the neural network model to minimize the overall objective function.
2. The method according to claim 1, characterized in that, Step S2 includes: Step S21: The feature maps of different layers of the neural network are processed by the feature alignment generator. The feature alignment generator performs bilinear upsampling and spatial softening operations in sequence to achieve dimensional alignment and normalization of feature maps at different levels. Step S22: Based on the aligned feature maps, calculate the distillation loss layer by layer between adjacent layers of the network, thereby forming a knowledge distillation chain from shallow to deep layers. The chain-like distillation loss... The calculation formula is as follows: ; Where M represents the total number of layers in the neural network, This represents the feature map of the m-th layer. For feature alignment generator function, This is the interlayer distillation loss function.
3. The method according to claim 1, characterized in that, Step S3 includes: Step S31: For any two data instances in a batch of the mixed training data, extract their corresponding deep feature maps and calculate the relationship matrix between them. This is used to capture the semantic relationships between samples; the formula for calculating the relationship matrix is as follows: ; in, and These are the deep feature maps of the i-th and j-th data instances, respectively; Step S32: Utilize the aforementioned relation matrix For the original deep feature map and By supplementing the relationships, new deep feature maps with enhanced relationships are obtained. and ; Step S33: Combine the original deep feature map with the new deep feature map after relationship enhancement to construct a hybrid contrastive loss as the relationship compensation contrastive loss. This method utilizes both the sample's own features and the relationships between samples to enhance the discriminative power of the features; the calculation formula for the hybrid contrast loss is as follows: ; Where p is the balance coefficient and N is the batch size. For indicator functions, To have the same label as the i-th sample The number of samples, and This is the contrast loss term calculated based on cosine similarity.
4. The method according to claim 3, characterized in that, Calculate according to the following formula and ,include: ; ; in, This is a similarity metric function used to calculate the degree of similarity between two feature vectors; This is a temperature coefficient used to adjust the sharpness of the probability distribution, affecting the model's attention to difficult samples; The summation Σ in the denominator is used to calculate the similarity distribution between sample i and k for all samples k except sample i itself in the entire batch of samples of size 2N; where the batch of samples of size 2N is obtained by expanding a batch of samples of size N to 2N data points using data augmentation.
5. The method according to claim 1, characterized in that, Calculate the loss based on dark experience replay using the following formula. ,include: ; in, Dark experience replay loss is the basic replay loss function in continuous learning. It achieves knowledge preservation by constraining the current model's output response to replay samples to remain consistent with the old model's output response. To enhance the loss of Dark Experience Replay, in Based on this, a supervision loss based on real labels is added to achieve dual protection of output consistency constraints and real label supervision; M is the cross-entropy loss calculated by the model on the current new task data, where M is the memory buffer. These are the playback data triples extracted from M. and This represents the input data for historical tasks. and This represents the true labels corresponding to the input data of historical tasks; and The old model output response corresponding to the input data of the historical task is the teacher signal in knowledge distillation; α and β are hyperparameters; and A parameterized neural network model; For loss function, The expectation is the average value calculated over all possible data sampled from a certain distribution, which is approximated by randomly sampling a batch of data from the memory buffer M.
6. The method according to any one of claims 1 to 5, characterized in that, Step S4 involves calculating the loss based on dark experience replay and then weighting and summing it with the chain distillation loss and the relational compensation comparison loss to form the overall objective function. Specifically: ; in, and These are hyperparameters used to balance various terms. To enhance the loss of Dark Experience Replay, This is due to losses during chain distillation. To compensate for the loss in relational comparison.
7. The method according to claim 1, characterized in that, When the method needs to be deployed in a visual recognition system to classify and identify products in images captured by a camera, it includes the following steps: Initialization and Data Preparation: Initialize a convolutional neural network as the neural network model and load a training dataset containing images of multiple product categories; preprocess the images in the training dataset, including image normalization and image enhancement operations, including random rotation and random flipping, to simulate the diversity of images captured by cameras in a real production environment; Incremental task sequence construction: Product images from different periods or batches are defined as a continuous task sequence, where the data stream of the current task corresponds to new product images newly captured by the camera or introduced in a new season, and the playback data in the memory buffer corresponds to old product images learned in historical tasks and their corresponding old model outputs. Incremental training and replay of the model: For each new task in the task sequence, execute steps S1 to S4, including: The model is trained by mixing images of new products with images of old products replayed from the memory buffer. Cross-layer information compensation is achieved by calculating chain distillation loss. Contrast loss is calculated by constructing a sample relationship matrix to compensate for representation bias. The model parameters are optimized by combining the dark experience replay loss. This allows the model to adapt to recognizing new products while maintaining high recognition accuracy for learned old products. Model deployment and online updates: The trained model is deployed on the visual recognition system; when the system captures a new product category or style through the camera, the new image is added to the training dataset, and the above incremental training and playback steps are repeated to achieve continuous learning and dynamic optimization of the model on the production line.
8. A continuous learning system based on a dual-compensation network, characterized in that, include: The training module is used to acquire the data stream of the current task and the replay data of the memory buffer, combine the two into mixed training data, and provide it to the neural network model for training; the memory buffer is used to store samples from previous tasks and their corresponding old model output responses. The feature compensation hierarchical distillation module is used to extract and process feature maps generated by different layers of the neural network model during the forward propagation of mixed training data through the neural network model, and calculate chain distillation loss based on the feature maps to achieve cross-layer information compensation. The relation compensation module is used to extract deep feature maps from the feature maps, construct a relation matrix between different data instances in the mixed training data based on the deep feature maps, and calculate the relation compensation contrast loss based on the relation matrix to compensate for the representation bias caused by sample imbalance. An update module is used to calculate the loss based on dark experience replay and to perform a weighted summation of it with the chain distillation loss and the relational compensation contrast loss to form a total objective function. Based on this total objective function, the gradient is calculated using the mixed training data through the backpropagation algorithm, and the parameters of the neural network model are updated to minimize the total objective function.
9. An electronic device, characterized in that, include: The processor, communication interface, memory, and communication bus are connected, with the processor, communication interface, and memory communicating with each other via the communication bus. The memory is used to store computer programs; When the processor executes a program stored in the memory, it implements the method described in any one of claims 1 to 6.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method as described in any one of claims 1 to 6.