Method for continuously learning new data features and categories
By combining EWC, LwF, and experience replay, the problems of catastrophic forgetting and high training costs in the DAS early warning system when learning new data categories are solved, achieving efficient incremental learning, improving recognition rate and system stability, and reducing resource consumption.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-19
- Publication Date
- 2026-04-14
AI Technical Summary
Existing DAS early warning systems suffer from catastrophic forgetting problems when learning new data categories, have high training costs, struggle to adapt to dynamically changing environments and threat types, and waste storage resources, making them inefficient for handling incremental learning needs of small batches of data.
We employ a synergistic application of three incremental learning strategies: Elastic Weight Consolidation (EWC), Forget-Free Learning (LwF), and Experience Replay. By combining a joint loss function and adaptive weights with parameter-level constraints, output-level distillation, and sample-level replay, we achieve explicit transfer and fusion of old model parameters and dynamically balance the constraint strength of each strategy.
In both class-increment and domain-increment scenarios, the recognition rate of new categories reaches over 98%, the recognition accuracy of old categories remains above 96%, training efficiency is improved by 80%–95%, storage resources are reduced to the requirement of storing a small number of replay samples, and system stability and reliability are improved.
Smart Images

Figure CN121859984A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to machine and continuous learning technologies, specifically a method for continuously learning new data features and categories. Background Technology
[0002] Distributed Acoustic Sensing (DAS) is an advanced technology that uses optical fibers as sensors to monitor physical quantities such as sound waves and vibrations along the fiber path in real time. In DAS early warning systems, by extracting features and recognizing patterns from the signals collected by the optical fibers, real-time monitoring and early warning of events such as intrusions, sabotage, and geological disasters can be achieved.
[0003] Existing DAS (Discretionary Alert System) early warning systems primarily employ the following technical solutions: 1. Traditional Machine Learning Methods: These methods use traditional machine learning algorithms such as Support Vector Machines (SVM) and Random Forests to classify extracted features. These methods require training on all training data at once, and the parameters are fixed after model training. 2. Deep Learning Methods: These methods use deep learning models such as Convolutional Neural Networks (CNN) and Recurrent Neural Networks (RNN) for end-to-end learning. Although deep learning models have stronger feature extraction capabilities, they still require a complete training dataset. 3. Offline Update Mode: When new recognition categories need to be added or new scenarios need to be adapted, existing systems typically need to collect a large amount of both old and new data, retrain the entire model, and then replace the original model.
[0004] The existing technical solutions suffer from the following major problems: 1. Catastrophic forgetting: When the model needs to learn new data categories, directly using new data for training causes the model to forget previously learned knowledge, a phenomenon known as "catastrophic forgetting." This severely impacts the stability and reliability of the system. 2. High training costs: Each time a new category is added or a new scenario is adapted, a large amount of historical data needs to be collected and the entire model needs to be retrained, resulting in high computational resource consumption and time costs. 3. Difficult system maintenance: In practical applications, customers may discover a small number of new data features or categories during system operation. Existing technologies cannot efficiently handle the incremental learning needs of such small batches of data. 4. Poor adaptability: Existing systems struggle to adapt to dynamically changing environments and threat types, failing to achieve rapid response and learning to new threats. 5. Wasted storage resources: A large amount of historical training data needs to be stored for retraining, consuming significant storage space. Summary of the Invention
[0005] To address the shortcomings of existing technologies, this invention proposes a method for continuously learning new data features and categories. This invention collaboratively applies three incremental learning strategies—Elastic Weight Consolidation (EWC), Forget-Free Learning (LwF), and Experience Replay—according to engineering rules: a joint loss function organically combines parameter-level constraints, output-level distillation, and sample-level replay, and introduces adaptive weights based on training performance to dynamically balance the constraint strength of each strategy. The system can operate in both class-increment and domain-increment scenarios, and explicitly transfers and fuses old model parameters, Fisher information, and replay sample indices, thereby maximizing the retention of existing recognition capabilities while rapidly learning new categories or domains.
[0006] The technical solution of this invention is: a method for continuously learning new data features and categories, characterized by comprising the following steps: Step 1: Steps for calculating elastic weight consolidation: When training on a new task, the loss is calculated as follows: ; Here, Fisher information is represented, current parameters are represented, and old model parameters are represented. Step Two: Steps for Forget-Free Learning Computation There are two main approaches to handling classless increments: one for class-based increments and another for special cases. The method for handling classless increments is as follows: Given input x, let the logits of the teacher model be and the logits of the student model be . Introduce the temperature parameter T (T>1) and perform softmax smoothing to obtain the probability distribution: ; Represents the probability distribution of the teacher model; Represents the probability distribution of the student model; Distillation loss is: ; in ; Where T 2 It is a scaling factor. j For category indexing, for , for C represents the number of categories in the current classification task, and B represents the batch size; The special handling method for class increments is as follows: when the output dimension of student includes the newly added category while teacher only includes the old category, let: ; This indicates taking the first few logits of the student model. One component; Calculate distillation loss for: ; in Dimensions ; Step 3: Steps for Experience Replay Calculation Sample selection strategy: Select samples with high classification confidence and close to the average features within the class as representative samples, and determine the initial number of samples selected for each class and the upper limit of the number of replay samples for each class; Storage management: A directory is maintained locally for each category. When a new category appears for the first time, the sample is copied into this directory; once the limit is reached, some samples are randomly selected for replacement. Training Hybrid Strategy: During training, replay samples and new samples are mixed and shuffled to form a database. Regular supervised training is performed while forgetting-free learning and elastic weight consolidation are applied. Step 4: The steps of the coordination mechanism and parameter transfer; Use joint losses to coordinate: ; in: This represents a loss for the current oversight task; : is the classification cross-entropy; , For adaptive weights.
[0007] According to the method for continuously learning new data features and categories as described above, the characteristic is that the calculation process of adaptive weights is as follows: ; This represents the relative decrease in performance of the old class compared to the initial baseline. This is a normalized measure of the current learning rate relative to the initial learning rate for a new task. This indicates the accuracy of the initial baseline (old class baseline). Indicates the initial learning rate of the new class; ; In the formula , , , This is a configurable constant. Indicates performance degradation for older classes Sensitivity Indicates the learning rate for new classes Sensitivity.
[0008] According to the method for continuously learning new data features and categories as described above, the characteristic is that the pre-supervised task loss is calculated as follows: ; This represents the input data for the 1 / nth sample in the current training batch; Indicates sample Corresponding real category labels; This indicates that the student model, under the condition of temperature T=1, performs well on the input samples. Output category probability distribution.
[0009] According to the method described above for continuously learning new data features and categories, the key feature is that the Fisher information estimation method is: using data from the previous task... exist Fisher at the estimated diagonal: ; Total number of sample data; These are the data from the previous task. Indicates an estimate of the diagonal; In incremental-like scenarios, for each weight tensor k: ; Indicates the weight of the old value. Indicates the weight of the new value. Indicates the weight of the old value. Indicates the weight of the new value. Save the parameter information matrix after merging the old and new F matrices and replace it with the new Fisher matrix.
[0010] According to the method for continuously learning new data features and categories as described above, the characteristic is that: in step two, when the teacher's maximum prediction probability for a certain input exceeds a threshold... At that time, a selective distillation and confidence-weighted method was adopted: the original... Replace with confidence weights The distillation loss with confidence weights is then expressed in the form of [formula missing] and normalized. ; It is a relatively small constant; If all =1 degenerates into the original uniform state. ; in: ; The index of the sample in the batch. =1,2,…,B; : Index of categories =1,2,…,C.
[0011] According to the method for continuously learning new data features and categories as described above, the characteristic is: threshold It is 0.8.
[0012] According to the method for continuously learning new data features and categories as described above, the characteristics are: the initial number of selections for each category is 100-200, and the maximum number of replay samples for each category is 500.
[0013] According to the method for continuously learning new data features and categories as described above, the feature is that the experience replay library also includes representative scoring and replacement rules. ; in For configurable weights, and ; conf(x): confidence level, div(x): class representativeness, fresh(x): time factor.
[0014] According to the method for continuously learning new data features and categories as described above, the time factor is calculated as follows: ; Half-life, The weight decays after a certain day; To protect the initial playback sample; The current time; The time when the replay sample was added.
[0015] The method for continuously learning new data features and categories, as described above, is characterized in that: the method for continuously learning new data features and categories is applied in the field of distributed fiber optic acoustic sensing devices deployed along pipelines.
[0016] The beneficial effects of this invention are as follows: Compared with single strategies or simple combined methods, the adaptive collaborative incremental learning system proposed in this invention has the following significant advantages: Firstly, in the incremental class scenario (adding 3000 new classes and replaying 200 classes per class), the experimental results show that the accuracy of new class recognition can reach ≥98%, while the overall recognition accuracy of old classes decreases by ≤2% (remaining above 96%). This performance is better than the combination of EWC, LwF, and experience replay alone.
[0017] Secondly, in the domain incremental scenario (adding 300 different scenario samples for each class), the adaptive method of this invention is adopted. and The configuration can achieve a recognition rate of ≥98% on the new domain, while the performance of the old domain remains virtually unchanged.
[0018] Third, training efficiency and resource consumption: the average time for incremental updates is significantly less than that for full retraining (typically saving 80%–95% of training time), and the memory and storage overhead is only required to save a small number of replay samples (saving a lot of storage compared to long-term storage of all historical samples).
[0019] Fourth, system reliability: By combining "selective distillation + representative playback + Fisher fusion", the system can effectively reduce misjudgments caused by teacher noise transmission and playback sample redundancy, thereby improving the stability and maintainability of long-term deployment. Attached Figure Description
[0020] Figure 1 For system architecture.
[0021] Figure 2 This is the training process.
[0022] Figure 3 This is the original confusion matrix.
[0023] Figure 4 This is the confusion matrix after multiple incremental online learning processes.
[0024] Figure 5 This is for using only the ewc strategy.
[0025] Figure 6 This is for using only the lwf strategy.
[0026] Figure 7 To use ewc+lwf, configure the appropriate parameters.
[0027] Figure 8 This is for using ewc+lwf+experience replay. Detailed Implementation
[0028] The technical solution of the present invention will be further described below with reference to the accompanying drawings.
[0029] The present invention provides a method for continuously learning new data features and categories, comprising the following steps: Step 1: Steps for calculating Elastic Weight Consolidation (EWC): EWC uses the Fisher information matrix F to measure each parameter in the old task. The importance of this. When training on a new task, the following regularization term is added to the original loss to suppress large fluctuations in key parameters, and the loss is: ; in For Fisher information, For the current parameter, These are the parameters for the old model.
[0030] Fisher's estimation: The importance of the parameters is approximated by the mean of the squared log-likelihood gradients, using data from the previous task. exist Fisher at the estimated diagonal: ; Total number of sample data; These are the data from the previous task. This indicates an estimate of the diagonal.
[0031] An approximate value of F is obtained by calculating the gradient of the log-likelihood of several old samples, squaring it, and then averaging the results.
[0032] In this way, EWC "anchors" the weights that contributed significantly to previous tasks and reduces their learning rate, thereby mitigating the forgetting of old knowledge while continuously learning new tasks. In incremental scenarios, the network output layer needs to dynamically expand to adapt to new categories, from a dimensional perspective... D in ×C old Extended to D in ×C new The parameters corresponding to the newly added category can be initialized with zero padding, allowing it to learn the new category while retaining existing knowledge.
[0033] In incremental scenarios, the elastic weight consolidation method of this invention calculates the weighted fusion rules using a weighted fusion approach, applying the old Fisher F... old With "this new Fisher F new The weighted fusion rule, note that Fisher is stored element-wise, and fusion requires element-to-element correspondence, for each weight tensor k: ; Indicates the weight of the old value. Indicates the weight of the new value. Indicates the weight of the old value. Indicates the weight of the new value. The parameter information matrix obtained by fusing the old and new F matrices is saved and replaced with a new Fisher matrix (i.e., Fisher information matrix F) for calculating the loss during training. ; Among them, taking from the class increment Larger values (e.g., 0.6–0.8) are preferred to retain information about the importance of older tasks; this can be improved in domain increments. .
[0034] For parameters corresponding to newly added output units, their Fisher values are initially set to zero (zero-padding) to avoid imposing unreasonable constraints on new EWC parameters in the early training phase; subsequently, the Fisher values of these new parameters are gradually estimated and updated according to the training progress. This rule ensures that old parameters are firmly protected while new parameters can learn freely during incremental training.
[0035] Step 2, the steps for calculating Forget-Free Learning (LwF): LwF uses knowledge distillation to maintain the model's consistent behavior on old categories. This is achieved by treating the output probability distribution of the old model (teacher) on the input as "soft targets," and using distillation loss to force the new model (student) to produce a similar output distribution on the same input, thus preserving the behavioral patterns of the old model.
[0036] The method for handling classless increments is as follows: Mathematical expression (distillation loss): Given input x, let the logits of the teacher model be... The logits of the student model are By introducing a temperature parameter T (T>1) and performing softmax smoothing, the probability distribution is obtained: ; Represents the probability distribution of the teacher model; This represents the probability distribution of the student model.
[0037] Distillation loss can be represented by KL divergence (or equivalent form of cross-entropy) (B = batch size). Batch size refers to the number of data samples input into the model for each gradient update (i.e., one backpropagation) during training of a neural network model. In mini-batch gradient descent, the model takes a batch of data (batch size) at a time, calculates the average gradient of this batch, and then updates the parameters. ; in ; Where T 2 This is a scaling factor used to compensate for the effect of temperature scaling on the gradient magnitude. j For category indexes (1 to C), for , for C represents the number of categories in the current classification task.
[0038] Special handling for class increments: When the output dimension of student includes a newly added category ( The teacher category only contains the old category. When distilling, only the old category portion should be distilled (i.e., the teacher can only provide soft labels for the old category). In implementation, let: ; in Dimensions .
[0039] To avoid forcibly distilling unreliable teacher outputs on new domain / new class samples into the student model, this invention proposes a selective distillation and confidence-weighted method: distillation is only performed when the teacher's maximum prediction probability for a given input exceeds a threshold. (Preferred value 0.8) Only when the input is included in the KD term; otherwise, the distillation weight of the sample is decayed according to the confidence level or ignored directly. Formally, sample weights can be introduced to convert the original... Replace with confidence weights The distillation loss with confidence weights is then expressed in the form of [formula missing] and normalized. ; : is a relatively small constant, such as 1 × 10 -8 This prevents division by zero without affecting the normal result.
[0040] If all =1 degenerates into the original uniform state. ; in: ; The index of the sample in the batch. =1,2,…,B : Index of categories =1,2,…,C This selective distillation is also an important improvement of the present invention. If the teacher model has a high prediction accuracy, the distillation is strong. If the teacher model has a low prediction accuracy (especially for new classes), the distillation is reduced or even turned off, which reduces the negative impact of the teacher model on the learning of new classes and thus improves the overall robustness.
[0041] Step 3: Steps for Experience Replay Calculation A small subset of representative samples from each old category is saved and mixed with new samples during training on a new task, allowing the model to "review" old knowledge and reduce forgetting.
[0042] Implementation details: Sample selection strategy: Select samples with high classification confidence and close to the average features within the class as representative samples. Initially, the number of samples selected for each class is 100-200, and the upper limit of the number of replay samples for each class is set to M=500. A random replacement strategy is used to maintain the upper limit.
[0043] Storage management: A directory is maintained locally for each category. When a new category appears for the first time, the sample is copied into this directory; once the limit is reached, some samples are randomly selected for replacement.
[0044] Training Hybrid Strategy: During training, replay samples are mixed and shuffled with new samples to form a database. Regular supervised training is performed while applying LwF and EWC.
[0045] The representative scoring and replacement rules for the experience replay library in this step are as follows: This invention proposes a sample representativeness scoring function: ; in For configurable weights, and .
[0046] Definitions of each sub-item: conf(x): Confidence score, i.e., the softmax output of the model; div(x): Representativeness within the class. Because the initial samples are manually selected typical samples, the initial replay samples... The value is set to 1. Subsequent replacements, due to the random nature of the samples, present significant uncertainty when using machine learning to find representative samples "close to the class center." Therefore, the value is uniformly set to 1. The value is set to 0.8. Further research can be conducted to develop suitable computational center methods and embed them into this system. fresh(x): A time factor that favors "newer" samples to reflect the latest distribution, achieving: ; Half-life, measured in days. =7 means that the weight decays after 7 days; Protect the initial replay samples to prevent premature replacement due to a small fresh(x) value. Current time; : The time when the replay sample was added.
[0047] When the replay capacity reaches its limit (M=500 per class), the batch of samples with the lowest R(x) (20%) is replaced first. This replacement rule ensures diversity while keeping the replay library updated as the scenario evolves, which is a key difference from existing random replay strategies.
[0048] Step 4: The steps of the coordination mechanism and parameter transfer; Overall, the system maintains and transmits three types of key intermediate information in each incremental update: — Old model parameters: θ ∗ (Used to initialize the student model and as a distillation teacher); — Fisher vector / matrix: F (weighted regularization for EWC); — Replay Sample Index and Representativeness Score: {(x i , R(x i (Sample selection and replacement decisions for experience replay).
[0049] Based on the above information, this invention uses a unified joint loss during the training phase to coordinate the effects of the three strategies: ; in: : The loss for the current supervised task, the classification cross-entropy for hard labels (new class label and replay sample): ; Here, B = batch size; This represents the input data for the 1 / nth sample in the current training batch; Indicates sample Corresponding real category labels; This indicates that the student model, under the condition of temperature T=1, performs well on the input samples. The output class probability distribution (because) The current oversight tasks have resulted in losses, which need to be addressed with real hard labels. Direct alignment, hence T=1. Temperature parameter 𝑇 >1 is only used for knowledge distillation (KD / LwF), not for supervised cross-entropy; : Usually it is the categorical cross-entropy; Distillation loss based on teacher (old model) soft labels; Loss based on EWC regularization suppression.
[0050] , The adaptive weights proposed in this invention (dynamically adjusted as training progress t) are used to balance the constraint strength of LwF and EWC during training.
[0051] Performance-driven in this step , The adjustment adopts both the old and new adaptive weighted closed-loop methods. The adaptive weighted closed-loop process is as follows: Real-time monitoring of old class baseline accuracy A during training old (t) and the new class learning rate G new (t), and dynamically adjust based on the relative changes of the two. and This allows for the automatic enhancement of elastic weights to consolidate EWC when the performance of the old class declines; and the appropriate relaxation of distillation constraints to accelerate the convergence of the new class when learning is slow.
[0052] The following calculation formula can be used: ; The relative decrease in performance of the old class relative to the initial baseline. The normalized measure of the current learning rate of the new task relative to the initial learning rate; This indicates the accuracy of the initial baseline (old class baseline). This represents the initial learning rate of the new class. Take 1 × 10 -8 To prevent division by zero.
[0053] ; In the formula , , , This is a configurable constant (default). =0.5, =0.7, =1.0, =0.5), Indicates performance degradation for older classes Sensitivity (gain coefficient) Indicates the learning rate for new classes Sensitivity (reducing the magnitude of KD).
[0054] Parameter limitations: , Make cutting, , , express The minimum value, express The maximum value, express The minimum value, express The maximum value, , , , The value should be adjusted according to the actual situation to avoid exceeding a reasonable range; the default value is [not specified]. , And it is updated once per epoch. To avoid fluctuations caused by frequent updates.
[0055] Mechanism of action: If the performance of the old class begins to decline (s old (Increase), the system will automatically increase Enhance EWC to constrain important parameters; if new class learning is very fast (s new Large), system appropriately reduced Relax the distillation constraint to avoid hindering the convergence of new classes.
[0056] Appendix Figure 2 To ensure the coordinated execution order and information transmission among the three (engineering closed loop), the specific training process using the method of this invention is as follows: The process involves: customer input of newly collected online learning data (labels must be manually entered if new classes exist) → preprocessing → new class detection (detecting for new classes based on category labels) → building a student model (expanding the output layer if class increments occur) → parameter distillation (KD) using the old Fisher constraint parameter variation (EWC strategy) + the old model as the teacher model, loading replay samples → initiating joint training (loss is...). Different parameter configurations are invoked based on the incremental category, and adaptive weights are used. and Adjustment → Estimation after training And perform Fisher fusion and save. Used for subsequent training → update sample playback library (according to R(x) strategy) → export / publish and version management.
[0057] In this closed loop, the old model parameters, Fisher, replay index, and new sample features are all used as data structures that are explicitly passed between modules, ensuring the continuity and stability of each round of incremental training.
[0058] The collaborative mechanism, parameter transmission, and rules of this invention constitute the core innovation of this invention. They not only enable EWC, LwF, and experience replay to complement each other, but also solve the limitations of single or simple combined strategies in actual DAS scenarios through adaptive adjustment and sample representativeness management.
[0059] The method of continuously learning new data features and categories according to the present invention is applied to the field of distributed fiber acoustic sensing (DAS) devices deployed along pipelines. The system architecture is as follows: Figure 1 As shown, it includes the following main parts: 1. Data Acquisition Layer: Acoustic signals are acquired in real time (sampling frequency 1000Hz) by laying optical fibers along the pipeline through distributed optical fiber acoustic sensing (DAS) equipment. 2. Feature Processing Layer: The original signal is processed by pre-emphasis, windowing, FFT transformation, Mel filtering, etc., to extract MFCC features; 3. Incremental Learning Layer: The core algorithms for implementing EWC regularization, LwF knowledge distillation, and experience replay are used to continuously learn new categories without forgetting old knowledge; 4. Model storage layer: Used to store the latest network parameters, Fisher information matrix, and representative samples of each category; 5. Application Service Layer: Provides functions such as data collection, online early warning, model update, and parameter configuration to achieve collaboration between real-time edge early warning and cloud management.
[0060] The following example illustrates the method of this invention using a specific project: In a pipeline external damage prevention and early warning project, the initial system can identify six common threats and events: mechanical impact, minor vehicle impact, rotating machinery, construction sites, traffic flow, and environmental noise. The system takes one-dimensional time-domain signals from distributed fiber optic sensors as input, and after preprocessing, classifies and predicts threat types using a neural network. As the operating time progresses, new threat categories or differences in monitoring scenarios emerge, requiring model updates under conditions of incomplete retraining. This embodiment employs an incremental learning method (combining EWC, LwF, and experience replay) to meet this requirement.
[0061] 1. Hardware and software environment; Hardware environment. Sensing equipment: Distributed fiber optic early warning system (model Thinker-6001), sampling rate 1000Hz, single-channel monitoring distance 50km; Software configuration. Deep learning framework: TensorFlow 2.15, ONNX Runtime 1.16; 2. New data collection; Fiber optic sensing equipment collects vibration signals along the pipeline. The currently configured model processes and identifies the threat type of the signal in real time, providing real-time warnings. For threat signals, the system automatically stores them in a designated directory and labels them with their type. When users discover event signals of interest at a specific time and location during pipeline inspections, they can export this data from the relevant database directory and manually label the sample types. Users can also upload manually labeled new samples in the configuration interface, specifying the event category or adding a new category label. The system saves these new samples to a separate directory and updates the sample index table. 3. Data preprocessing and selection of typical samples; Preprocessing: The acquired raw data is preprocessed. The time-domain signal is downsampled, normalized, and features (MFCC, spectrogram) are calculated, converting it to a Mel-frequency plot for model extraction using visual features. The processing flow is implemented in Python using libraries such as NumPy, SciPy, and OpenCV. Preprocessed features (or converted tensors) are saved per sample to accelerate training and retrieval.
[0062] Typical sample selection: To enable experience replay (experience sample preservation), "typical samples" are stored in the database for the original categories. Based on expert experience, 100-200 representative samples are selected for each category. These samples' features and labels, along with the new data, are used for incremental training. Data storage uses a lightweight database to record sample paths and metadata for easy retrieval. 4. Local offline training and parameter updates; Initial model training: In the initial stage of system deployment, offline training was performed on the existing 6 classes of data. Hyperparameters were set (learning rate 0.001, batch size 32, number of training epochs 20). During training, the model parameters were continuously updated (weight matrix optimization), and after training, the parameter importance matrix (the Fisher information matrix required by EWC) was calculated and saved. Loss function design: Classification cross-entropy is used as the base loss. During the initial training phase, normal training is performed without applying EWC / LwF. After training, the final model weights are saved as model_v1.keras and then converted to model_v1.onnx.
[0063] Performance Validation: Accuracy was tested using the reserved validation set, and the accuracy for each class reached the expected level (overall above 95%). Training logs recorded training time, loss curves, and accuracy information, and saved them to log files. At this point, the system began online deployment with model_v1.onnx, and was loaded and used by the C# client via ONNX Runtime.
[0064] 5. Incremental learning triggers (classified incremental and pre-incremental); 5.1 Data preparation (loading newly collected data and checking if it is a new category); Objective: To prepare user-uploaded or manually collected data into a sample set for training and to determine the task type (class increment or domain increment). Read the samples to be processed from the manually uploaded directory or the designated storage area, and check the sample metadata (sample type, confidence level, collection time, collection device, sampling rate, etc.). For each sample, standard preprocessing (sampling and normalization) is performed, and it is then converted into a uniform feature representation (Mel time-frequency plot). Preprocessing parameters: sampling rate 500 Hz, window length 256, window shift 74, Mel filter 64, FFT points 512; If the user has explicitly marked the new category when uploading, it will be directly marked as a class increment and the new class name will be recorded.
[0065] 5.2 Model Building (Determine the task type and prepare the model structure); Objective: To prepare training models based on task types, including whether to extend the output layer and the setting of the teacher model; Task judgment: The system compares the category label of the newly passed incremental sample with the stored category set: if there is a label that is not in the set, it is judged as "class increment" (a new category exists), and the new label is written into the category set to complete the update; otherwise, it is judged as "domain increment". Load existing model parameters: Load the previously saved model weights model_v1.keras as old model parameters for subsequent comparison and knowledge distillation (teacher model). Output expansion during class increment: For class increment, the output units of the last layer of the model are expanded according to the number of new classes. Expansion strategy: The weights of the new outputs are initialized with zero to avoid significant perturbation to the old classes; the biases are also zero-padded. After expansion, the original weights of the shared feature extraction layer are retained unchanged (and can be fine-tuned), and the new output units are learned gradually during training; Teacher model: During the training phase, the old model is used as the "teacher" to generate soft targets for distillation. The teacher model keeps its parameters frozen and does not participate in updates. Recommended training hyperparameters: Incremental learning rate reference: Initial fine-tuning learning rate 1 × 10⁻⁶ -3 → Fine-tuning 5 × 10 -5 Training rounds: 8–16 (depending on sample size); Domain incremental learning rate reference: initial 5 × 10 -4 → Fine-tune 5 × 10 -5 ; 10–20 training rounds; BATCH_SIZE is recommended to be 16–64, depending on device resources.
[0066] 5.3 Fisher matrix loading (injecting importance information of old task parameters); Objective: To provide a parameter importance metric for EWC regularization terms, preventing excessive modifications to key old parameters during training; Key steps: The Fisher information matrix is read from the model storage layer (or calculated and saved using the initial model if it is the first training iteration). The Fisher matrix is a set of importance weights corresponding to the dimensions of the model parameters (the scalar importance of each parameter can be stored using a diagonal approximation). If this is a class of incremental and an output unit has been added, the Fisher value of the new parameter is zero-padded (indicating that the old task had no constraints on these parameters). During training, the EWC regularization term applies a weighted penalty to the squared differences of each parameter based on the Fisher value, thereby imposing stronger stability constraints on important parameters.
[0067] 5.4 Loading experience samples (searching, filtering, and formatting); Objective: To load typical samples of old categories from the experience sample library for replay during training to consolidate old knowledge; Complete process: Location lookup: Experience samples are stored in a predefined directory (subdirectories divided by category), and two data representations are maintained: the original sample files (for archiving and tracing) and the pre-computed feature cache (e.g., a feature set file for each category); Loading strategy: Based on training requirements, first read the pre-cached features of each old category (prioritize using the cache to speed up the process), and if the cache is missing, process the original samples online as needed to generate features and cache them. Sample formatting and mixing: Experience replay samples and new samples are converted into a unified feature format and merged into the training set. To avoid class imbalance affecting training, samples are randomly shuffled and mixed during the training phase, so that each training batch contains samples from both the old and new classes, thus ensuring that the model balances new knowledge learning and historical class stability during the update process. Output: Loaded and organized training dataset (including new samples and replay samples), and metadata of replay samples (ID, source, representativeness score, collection time).
[0068] 5.5 Joint Training: Objective: The joint training phase aims to complete the learning of new samples (or new classes) and the consolidation of old knowledge within a single training cycle—that is, to adapt to the new class / domain with as little new data as possible, while maximizing the performance of the old classes. To this end, this invention adopts a comprehensive strategy of "joint loss + adaptive weights + selective distillation + representative replay + staged training," and implements real-time monitoring and protection strategies during training to ensure safe release of training data.
[0069] Joint loss is defined as: ; The meanings of each item are explained in Section 3.4. The following sections will explain the construction of training data, loss details, adaptive weights, optimization process, monitoring and contingency strategies.
[0070] (1) Phased training; Phase 1 (Rapid Learning): Freeze the shared feature layers and train only the newly added output units and the last few layers (if a new class exists). The purpose is to quickly verify whether a new class (if one exists) can be learned. The advantage is that it minimizes the impact on existing knowledge. Example hyperparameter: lr_head = 1 × 102 -3 epochs_head=2–4, batch_size is consistent with the main training.
[0071] Phase Two (Global Fine-tuning): Unfreeze the shared layers and fine-tune the entire system using a low learning rate (e.g., lr_finetune=5×10). -5 Up to 5×10 -4 Simultaneously enable EWC and LwF (and enable adaptive weights). epochs_finetune depends on the sample size of 4–10.
[0072] Phase switching criterion: specify the training round.
[0073] (2) Optimizer, learning rate and stopping policy; Optimizer: Adam; Initial learner set according to task type (incremental class, initial=1×10). -3 →finetune=5×10 -5 Domain increment initial = 5 × 10 -4 → finetune=5×10 -5 ).
[0074] Learning rate scheduling: ReduceLROnPlateau is used; early stopping (patience 3–5) is used to prevent overfitting.
[0075] 5.6 Parameter Update (Calculate and merge the new Fisher matrix); Objective: To re-estimate the parameter importance (Fisher) after this training is completed and then weighted and fused with the old Fisher for use in the next round of EWC.
[0076] Step-by-step instructions: The trained model is used to compute an approximate estimate of the Fisher information matrix on new data, with a configurable sample size of 300.
[0077] A weighted fusion strategy is used to merge the old Fisher with the new Fisher, as mentioned above. ; The fused Fisher matrix is saved to the model storage layer as the baseline for the next incremental training.
[0078] 5.7 Experience Sample Updates (How to Select, Replace, and Store): Objective: To maintain the representativeness and diversity of the experience sample database and ensure the effectiveness of subsequent replay training.
[0079] Detailed strategy: New sample storage: When a new category appears, a new class replay sample library is built, and typical samples are selected from the new samples and added to the library (prioritizing the high confidence judgment of the new samples by the model after training). The upper limit of the sample library is set to M=500.
[0080] Maintenance of old class samples: Maintain an upper limit M (500) for each old class. If the current number of replay samples is insufficient, prioritize filling it up; if the upper limit has been exceeded, adopt a replacement strategy.
[0081] Replacement strategy ( (Sample representativeness score): When a new sample needs to be written but the number of samples in the class has reached the upper limit, a score based on... The representative score replacement strategy replaces the 20% with the lowest representativeness.
[0082] Caching and Index Maintenance: After each replay set update, rebuild or update the feature cache file and index metadata (including sample type, confidence score, representativeness score, and collection time) for that category. This ensures that the cache can be quickly loaded for the next training run without recalculating the features of all samples.
[0083] Atomic write and consistency: Atomic operations are used during the write and replace process (first write to the temporary file, then replace the original file) to avoid inconsistencies caused by concurrent reads.
[0084] Versioning: Every major change to the replay library (such as the first entry of a new class into the library or a large-scale replacement) should be recorded with a version number and change log for auditing and rollback purposes.
[0085] 6. Model saving, verification, ONNX conversion and publishing (deployment); Objective: After training and validation, export the updated model into a cross-platform inference format and replace the online model, while retaining rollback capability.
[0086] Operating procedures: Offline validation: Before replacing the online model, evaluate the new model using a comprehensive validation set (containing both old and new class validation samples), recording the overall accuracy of the old class, the accuracy of the new class, the confusion matrix, and other key metrics. Set strict pass / fail criteria: The overall accuracy of the old category must not decrease by more than 3%; The accuracy of the new category must reach or exceed the specified threshold (93%–98%). The recall rate for each key category should exceed the minimum value. If the condition is not met, automatic releases will be paused and a manual review or rollback will be prompted.
[0087] Model and Fisher Memory Saving: After successful training, the model weights, fused Fisher matrix, updated empirical sample index, label dictionary, etc. are saved together, along with the version number and timestamp for version management.
[0088] Export to ONNX: Export the model to ONNX format for loading by C# or other runtimes, and verify the correctness of metadata such as input and output shape and type during the export process. After export, perform an inference validation on the ONNX model (use several samples to verify that the inference results are consistent with the training framework).
[0089] Atomic Replacement and Release: Atomic replacement strategy is used to replace the online model file with a new ONNX model (e.g., first write to a temporary file, then rename and overwrite the official model file) to avoid reading the partially written model.
[0090] Rollback mechanism: All approved older versions and the current version are stored in the repository. If problems occur during online operation (triggered by manual or automated monitoring), the system can roll back the online model to a specified historical version. Rollback should simultaneously restore the corresponding Fisher matrix and experience sample configuration.
[0091] Logs and notifications: After the release is completed, the system generates a summary report containing training parameters, sample size, accuracy metrics, version number and file path, sends it to the administrator and writes it to the persistent log for tracking.
[0092] Figure 3 This is the confusion matrix from the initial local training, which shows that the classification performance is high across all six time classes. Figure 4 It is a confusion matrix after multiple online learning sessions, having undergone more than ten class increment and domain increment training sessions. After more than ten training sessions, each class still maintains high recognition accuracy. Figure 3 and Figure 4 It can be seen that there are still some slightly confused types. This is because the incremental new category data selected in the experiment is slightly similar to the old data. They are not two strictly distinguishable events, so there is a small amount of aliasing. Figure 5 and Figure 6 The effectiveness of each strategy was verified individually. It can be seen that neither using only ewc nor only lwf yielded very good results. Figure 7 Use ewc+lwf and configure the appropriate parameters. Figure 8 Using ewc+lwf+experience replay, and combining relevant experiments, the various performance parameters after adding the new category are shown in Table 1. From the appendix Figures 1 to 8 As shown in Table 1, the combined effect of using adaptive weights of the three methods is significantly better than other methods.
[0093] This method combines three strategies: Elastic Weight Consolidation (EWC), Learning without Forgetting (LwF), and Experience Replay, enabling the model to rapidly adapt and learn to new or mutated data in real-world deployment environments while maintaining its original class recognition capabilities. (See attached...) Figures 1 to 8 It is known that the technology of the present invention can be applied to fiber optic sensing and early warning scenarios such as long-distance pipeline safety monitoring and perimeter security. It can continuously learn new data features and categories during system operation, and realize timely identification and early warning of new threats in distributed fiber optic sensing systems.
Claims
1. A method for continuously learning new data features and categories, characterized in that: Includes the following steps: Step 1: Steps for calculating elastic weight consolidation: When training on a new task, the loss is calculated as follows: ; in For Fisher information, For the current parameter, These are the parameters for the old model; Step Two: Steps for Forget-Free Learning Computation There are two main approaches to handling classless increments: one for class-based increments and another for special cases. The approach to handling classless increments is as follows: Given input x, let the logits of the teacher model be... The logits of the student model are By introducing a temperature parameter T (T>1) and performing softmax smoothing, the probability distribution is obtained: , ; Represents the probability distribution of the teacher model; Represents the probability distribution of the student model; Distillation loss is: ; in ; Where T2 is the scaling factor and j is the category index. for , for C represents the number of categories in the current classification task, and B represents the batch size; The special handling method for class increments is as follows: when the output dimension of student includes the newly added category while teacher only includes the old category, let: ; This indicates taking the first few logits of the student model. One component; Calculate distillation loss for: ; in Dimensions ; Step 3: Steps for Experience Replay Calculation Sample selection strategy: Select samples with high classification confidence and close to the average features within the class as representative samples, and determine the initial number of samples selected for each class and the upper limit of the number of replay samples for each class; Storage management: Maintain a local directory for each category; when a new category appears for the first time, the sample is copied into this directory; achieving... After reaching the upper limit, randomly select a portion to replace; Training Hybrid Strategy: During training, replay samples and new samples are mixed and shuffled to form a database. Regular supervised training is performed while forgetting-free learning and elastic weight consolidation are applied. Step 4: The steps of the coordination mechanism and parameter transfer. Use joint losses to coordinate: ; in: This represents a loss for the current oversight task; : is the classification cross-entropy; , For adaptive weights.
2. The method for continuously learning new data features and categories according to claim 1, characterized in that: The calculation process for adaptive weights is as follows: , ; This represents the relative decrease in performance of the old class compared to the initial baseline. This is a normalized measure of the current learning rate relative to the initial learning rate for a new task. This indicates the accuracy of the initial baseline (old class baseline). This represents the initial learning rate of the new class. , ; In the formula , , , This is a configurable constant. Indicates performance degradation for older classes Sensitivity Indicates the learning rate for new classes Sensitivity.
3. A method for continuously learning new data features and categories according to claim 1 or 2, characterized in that: The calculation of the pre-supervision task loss is as follows: ; This represents the input data for the 1 / nth sample in the current training batch; Indicates sample Corresponding real category labels; This indicates that the student model, under the condition of temperature T=1, performs well on the input samples. Output category probability distribution.
4. A method for continuously learning new data features and categories according to claim 1 or 2, characterized in that: The Fisher information estimation method is as follows: using data from the previous task. exist = Fisher at the estimated diagonal: ; Total number of sample data; These are the data from the previous task. Indicates an estimate of the diagonal; In incremental-like scenarios, for each weight tensor k: ; Indicates the weight of the old value. Indicates the weight of the new value. Indicates the weight of the old value. Indicates the weight of the new value. Save the parameter information matrix after merging the old and new F matrices and replace it with the new Fisher matrix.
5. A method for continuously learning new data features and categories according to claim 1 or 2, characterized in that: In step two, when the teacher's maximum predicted probability for a certain input exceeds a threshold... At that time, a selective distillation and confidence-weighted method was adopted: the original... Replace with confidence weights The distillation loss with confidence weights is then expressed in the form of [formula missing] and normalized. ; It is a relatively small constant; If all =1 degenerates into the original uniform state. ; in: ; ; The index of the sample in the batch. =1,2,…,B : Index of categories =1,2,…,C.
6. A method for continuously learning new data features and categories according to claim 1 or 2, characterized in that: The initial selection quantity for each class is 100-200, and the maximum number of replay samples for each class is 500.
7. The method for continuously learning new data features and categories according to claim 5, characterized in that: threshold It is 0.
8.
8. A method for continuously learning new data features and categories according to claim 1 or 2 as described above, characterized in that: The experience replay library also includes representative ratings and replacement rules: ; in , , For configurable weights, and + + =1; conf(x): confidence level, div(x): class representativeness, fresh(x): time factor.
9. The method for continuously learning new data features and categories according to claim 8, characterized in that: The time factor is calculated as follows: ; Half-life, The weight decays after a certain day; To protect the initial playback sample; The current time; The time when the replay sample was added.
10. A method for continuously learning new data features and categories according to claim 1 or 2, characterized in that: It is used in the field of distributed fiber optic acoustic sensing equipment where fiber optic cables are laid along pipelines.