Continuous learning network intrusion detection method and system based on gradient projection and concept drift detection
By employing gradient projection and concept drift detection, this method addresses the gradient interference and catastrophic forgetting issues of new and old knowledge in continuous learning intrusion detection. It achieves efficient adaptation and knowledge retention in dynamic network environments, thereby enhancing the robustness and reliability of the intrusion detection system.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- UNIV OF ELECTRONICS SCI & TECH OF CHINA
- Filing Date
- 2026-03-20
- Publication Date
- 2026-05-26
AI Technical Summary
Existing continuous learning intrusion detection methods lack explicit orthogonalization mechanisms when dealing with conflicts between new and old knowledge, leading to gradient interference and catastrophic forgetting. Furthermore, they are highly dependent on labeled data and struggle to maintain long-term reliability in dynamic network environments.
A gradient projection and concept drift detection method is adopted. Concept drift is actively detected through PCA variance analysis. The gradient projection memory (GPM) mechanism is used to project the gradient of the new task onto the orthogonal complement space of the historical feature subspace to construct the historical feature subspace, thereby achieving geometric decoupling of new and old knowledge. The buffer update is optimized through strategic sample selection and pseudo-label mechanism.
By explicitly avoiding the overwriting of historical knowledge by new knowledge learning, the model's adaptability and stability in dynamic environments are improved, the dependence on labeled data is reduced, and the robustness and reliability of the intrusion detection system in long-term operation are ensured.
Smart Images

Figure FT_1 
Figure SMS_16 
Figure SMS_20
Abstract
Description
Technical Field
[0001] This invention belongs to the fields of network security and deep learning, specifically relating to a continuous learning network intrusion detection method and system based on gradient projection and concept drift detection. Background Technology
[0002] With the widespread interconnection of smart cities, critical infrastructure, and the Internet of Things (IoT), the network environment is exhibiting high dynamism and complexity. Network intrusion detection systems (IDS), as a key mechanism for maintaining cyberspace security, identify malicious activities by continuously monitoring network traffic. However, the real-world network environment suffers from significant "concept drift," meaning that the data distribution of attack patterns and normal user behavior changes over time. This change leads to a discrepancy between the model's perception of data distribution and the actual distribution, directly undermining the reliability of traditional static intrusion detection systems and rendering them ineffective in responding to distribution shifts in dynamic environments.
[0003] To address this challenge, Continual Learning (CL) techniques have been introduced into intrusion detection, aiming to enable models to incrementally accumulate new knowledge without forgetting old knowledge. Nevertheless, existing CL-based intrusion detection methods still have limitations in handling conflicts between new and old knowledge, particularly in resolving geometric conflicts during parameter optimization.
[0004] In the paper "Continual Learning with Strategic Selection and Forgetting for Network Intrusion Detection" (i.e., the SSF method), Zhang et al. proposed a continuous learning framework based on strategic sample selection and forgetting, which mitigates forgetting by rearranging selected past samples. However, this method has the following problems:
[0005] (1) Lack of explicit orthogonalization mechanism: SSF mainly relies on sample-level strategies and lacks explicit constraints at the gradient level. When the gradient direction of the new task conflicts with that of the old task, direct updates will cause destructive interference, forcing the model to overwrite the existing representation to adapt to the new pattern.
[0006] (2) Entanglement of old and new knowledge: Due to the lack of geometric decoupling, the historical knowledge layer and the new knowledge layer are deeply entangled in the parameter space, which limits the model's ability to maintain long-term reliability in non-stationary environments.
[0007] In the paper "AOC-IDS: Autonomous Online Framework with Contrastive Learning for Intrusion Detection" (i.e., the AOC-IDS method), Zhang et al. proposed an autonomous online intrusion detection framework that combines contrastive learning and pseudo-labeling techniques for continuous adaptation. While this method improves adaptability to some extent, it still suffers from the following problems:
[0008] (3) Geometric conflicts in gradient updates: From the perspective of gradients, this method mainly relies on linear aggregation of updates. This approach fails to achieve the necessary geometric decoupling between historical knowledge and emerging data distributions, making it difficult to fundamentally resolve conflicts in the parameter optimization process.
[0009] (4) Dependence on label quality and quantity: Existing work indicates that such methods are often limited by the need for dense labeling, or are easily affected by label noise when facing unknown threats, thus affecting the stability of detection performance.
[0010] In summary, current mainstream continuous learning intrusion detection methods primarily focus on mitigating forgetting through various mechanisms, but they still fall short in addressing gradient-level interference, achieving geometric decoupling between new and old knowledge, and reducing dependence on labeled data. Therefore, there is an urgent need for a robust knowledge representation method that can explicitly decouple task-specific updates and ensure, through geometric constraints, that new knowledge acquisition does not come at the expense of old knowledge. Summary of the Invention
[0011] To address the aforementioned problems, this invention aims to propose an intrusion detection method for continuous learning networks based on gradient projection and concept drift detection. This solves the problems faced by existing intrusion detection systems in dynamic network environments, such as severe concept drift, catastrophic forgetting, and interference from gradients between new and old knowledge.
[0012] This method actively detects concept drift through PCA variance analysis, optimizes the memory buffer using strategic sample selection based on KL divergence, and at its core employs the gradient projection memory (GPM) mechanism to construct a historical feature subspace. The gradient of the new task is projected onto the orthogonal complement space of this subspace, thereby geometrically isolating the interference between new and old knowledge and achieving robust continuous learning.
[0013] To achieve the above objectives, the present invention adopts the following technical solution:
[0014] This invention provides a continuous learning method for network intrusion detection based on gradient projection and drift detection, comprising the following steps:
[0015] Step 1: Receive network traffic data streams, define the data for the current time window and the data for the previous time window, and use them as input for continuous learning;
[0016] Step 2: Perform characteristic variance analysis on the data from the two consecutive time windows in Step 1, and use principal component analysis to quantify the distribution changes to determine whether concept drift has occurred;
[0017] Step 3: Based on the drift detection results in Step 2, implement a strategic sample selection strategy, calculate the representativeness mask of the old samples and the new samples respectively, and select the most representative samples from the historical memory buffer and the current data stream.
[0018] Step 4: Based on the drift determination results in Step 2 and the samples selected in Step 3, perform differentiated memory buffer update and forgetting operations to dynamically adjust the sample composition in the buffer.
[0019] Step 5: Fine-tune the intrusion detection model using the updated memory buffer. By introducing a gradient projection mechanism, new attack patterns are learned while preserving the historical knowledge feature subspace, resulting in an updated network intrusion detection model.
[0020] In the above scheme, the specific steps of step 2 are as follows:
[0021] Step 2.1: Analyze the current data window D respectively. t And the previous data window D t-1 The eigenvalues are standardized to eliminate scale bias.
[0022] Step 2.2: Calculate the covariance matrix of the two window data and perform eigenvalue decomposition to obtain the eigenvalue vectors arranged in descending order;
[0023] Step 2.3: Truncate and process the eigenvalue vector to generate a spectral signature vector that reflects the data distribution structure;
[0024] Step 2.4: Calculate the cosine similarity between the two processed feature vectors, and derive the drift angle accordingly. ;
[0025] Step 2.5: Adjust the drift angle With the preset threshold The comparison is performed. If the drift angle is greater than or equal to the threshold, it is determined that concept drift has occurred; otherwise, it is determined that no drift has occurred.
[0026] In the above scheme, the specific steps of step 3 are as follows:
[0027] Step 3.1: First, using the preset feature projection matrix, project the current data window D... tThe historical buffer sample B is mapped to a low-dimensional feature space, and an L-bin probability histogram distribution is constructed, denoted as H. new and H old Then define a learnable weight vector w with the same length as the buffer samples. o The w is converted using the Sigmoid function. o The mapping is a continuous mask with values between [0, 1]. To minimize the new data distribution H new Compared with the old sample distribution H old( m o) Using the Kullback-Leibler divergence between the two as the target, we select old samples that can represent the common features of the old and new data;
[0028] Step 3.2: Maintain the optimization completed in Step 3.1 The state remains unchanged, thus determining the boundary of the selected old knowledge, and defining a learnable mask for the new samples in the current window. Construct a joint distribution histogram H combined H combined Composed of both selected old samples and candidate new samples, the goal is to minimize the Kullback-Leibler divergence between the new data distribution and the joint distribution (composed of the selected old samples and the candidate new samples) to select new samples that can represent the actual distribution drift.
[0029] Step 3.3: By optimizing the loss functions of the above two stages, determine the final set of old samples to be retained and the set of newly added samples.
[0030] In the above scheme, the specific steps of step 4 are as follows:
[0031] Step 4.1: If Step 2 determines that no significant drift has occurred, then perform a maintenance update: first remove old samples that are not representative enough from the buffer and add new samples that are highly representative. If the number of representative new samples is insufficient, then randomly supplement new samples.
[0032] Step 4.2: If Step 2 determines that a significant drift has occurred, then perform adaptive forgetting: discard all old samples in the buffer that cannot represent the common distribution, and make room to accept new samples that reflect the characteristics of the new distribution;
[0033] Step 4.3: In step 4.2, if there are insufficient manual annotation resources for new samples, use the detection model to generate pseudo-labels to annotate the remaining selected new samples in order to refresh the buffer.
[0034] In the above scheme, the specific steps of step 5 are as follows:
[0035] Step 5.1: Construct a task loss function that includes task-specific losses by introducing weight parameters. A task-specific loss function is constructed by assigning higher weights to new samples in the memory buffer than to old samples. ,in This represents the old sample data and its corresponding labels stored in the memory buffer. This represents the new sample data and its corresponding label stored in the memory buffer. This represents the loss calculation function for a single sample;
[0036] Step 5.2: Dynamically adjust the optimization target based on the drift determination result in Step 2. If the target is in a non-drift state, add a regularization term to the task loss function, which is represented as follows: ,in This is a regularization loss that helps preserve important weights. λ is a hyperparameter that balances the contribution of task-specific loss and the regularization term, constraining weight updates to reinforce existing knowledge. If in a drift state, the regularization term is removed, and the task loss function becomes... And activate the gradient projection mechanism;
[0037] Step 5.3: During the gradient projection process, the singular value decomposition of the activation value matrix of the input data at a specific layer of the model is performed, and an orthogonal basis that meets the conditions is selected according to the preset information retention threshold to construct the historical feature subspace;
[0038] Step 5.4: Project the gradient of the new task onto the orthogonal complement space of the historical feature subspace to ensure that the parameter update direction does not interfere with the existing historical knowledge representation, thereby realizing the parameter update of the model.
[0039] In the above scheme, the specific implementation of gradient projection in step 5.5 includes:
[0040] The activation values of the new data stream at each layer of the model are obtained and orthogonalized relative to the existing knowledge base to obtain the residual gradient space.
[0041] The residual gradient space is decomposed, new orthogonal bases are extracted, and the knowledge base is expanded accordingly.
[0042] When updating parameters through backpropagation, the gradient direction is corrected by subtracting the projection component of the gradient onto the historical memory matrix from the total gradient, so that the update only occurs in the direction orthogonal to the historical knowledge.
[0043] The present invention also provides a network intrusion detection continuous learning system based on gradient projection and drift detection, characterized in that the processor implements the method described thereon when executing the system.
[0044] Compared with the prior art, the beneficial effects of this invention are as follows:
[0045] 1. This invention utilizes a Principal Component Analysis (PCA)-based unsupervised drift detection module in step 2 to standardize network traffic data within a continuous time window, calculate the covariance matrix, and decompose eigenvalues to generate a spectral signature vector and quantify the drift angle. This technique addresses the technical problem of existing intrusion detection systems' delayed perception of concept drift or reliance on supervisory signals. It enables the system to proactively identify dynamic shifts in the network environment (such as the introduction of new attack patterns or the evolution of normal traffic patterns) from the inherent structural changes in data distribution, providing objective and timely decision-making basis for subsequent learning strategies and avoiding model adaptation failure due to undetected drift.
[0046] 2. This invention constructs histogram models of the distribution of new and old data respectively through a two-stage mask optimization strategy based on KL divergence in step 3 and a differentiated buffer management mechanism in step 4. It selects representative samples with the goal of minimizing distribution differences and performs strategic updates and forgetting based on the drift determination results. This technique solves the technical problems of imbalance in the selection of new and old knowledge samples and the buffer being occupied by redundant or outdated samples under limited memory resources. Through the sample selection logic guided by distribution representativeness, it accurately captures distribution drift features while retaining historical common features. Combined with the pseudo-label mechanism, it alleviates the labeling dependence and significantly improves the information density and training effectiveness of the buffer samples.
[0047] 3. This invention utilizes the gradient projection mechanism (GPM) in step 5 to construct an orthogonal basis for the feature subspace using the singular value decomposition of historical activation values, and projects the gradient of the new task onto the orthogonal complement space of this subspace for parameter updates. This technique solves the catastrophic forgetting problem caused by gradient direction conflicts in continuous learning. Starting from the geometric essence of parameter updates, it explicitly constrains the new knowledge learning path to be orthogonal to the historical knowledge representation, avoiding the overwriting or distortion of existing key feature representations during the learning of new attack modes, and realizing the structural decoupling of new and old knowledge in the parameter space, fundamentally ensuring the stability of historical detection capabilities.
[0048] 4. This invention constructs a deeply closed-loop coupled system by integrating the drift sensing mechanism in step 2, the strategic sample optimization in steps 3-4, and the gradient orthogonal update in step 5. This achieves synergistic effects beyond the superposition of single modules. Specifically, the drift detection results dynamically guide the sample selection strategy (such as triggering adaptive forgetting during drift), ensuring that the buffer samples are highly aligned with the current data distribution. The optimized representative sample set then provides a high-quality training benchmark for gradient projection, while the gradient projection mechanism ensures that parameter adjustments are strictly limited to directions that do not interfere with historical knowledge when updating the model using this sample set. The three form an organic whole of "perception triggering decision-making, decision-making optimizing data, and data driving security updates." This collaborative architecture not only endows the system with a keen response to changes in the network environment and an efficient ability to absorb new knowledge, but also completely avoids the conflict between old and new knowledge at the representation and optimization levels through the dual guarantees of geometric constraints and data filtering. It solves the core contradiction that a single technology cannot simultaneously address "dynamic adaptability" and "knowledge preservation integrity," significantly enhancing the robustness and reliability of the intrusion detection system in long-term continuous operation scenarios. Attached Figure Description
[0049] Figure 1 This is a schematic diagram of the overall framework of the present invention, illustrating the interaction between the three core stages: drift detection, strategic sample selection and forgetting, and GPM-based model fine-tuning. Detailed Implementation
[0050] The embodiments of the present invention will be described in detail below. Although the present invention will be described and illustrated in conjunction with some specific embodiments, it should be noted that the present invention is not limited to these embodiments. On the contrary, any modifications or equivalent substitutions made to the present invention should be covered within the scope of the claims of the present invention.
[0051] This invention provides an intrusion detection method for continuous learning networks based on gradient projection and concept drift detection, aiming to solve the concept drift adaptation problem in dynamic network environments. Example 1
[0052] This embodiment describes in detail the complete processing flow of the method, including core steps such as data stream processing, drift detection, sample selection, gradient projection, and model updating.
[0053] Step 1: Data Stream Preprocessing and Initialization. The system receives continuous network traffic data streams. The data stream is divided into continuous time windows (Batch), and the data window D for the current moment is defined. t The data window at the previous time step was D. t-1 Regarding D t and D t-1Each data point in the data is processed for feature standardization to eliminate the scale differences between features of different dimensions (such as traffic duration and number of bytes) and ensure the accuracy of subsequent covariance calculations.
[0054] Step 2: Active concept drift detection based on PCA. This step uses principal component analysis to quantify the structural changes in data distribution. The specific algorithm is shown below.
[0055] Step 2.1: This algorithm runs on two consecutive data windows. First, it processes the current window D... t And the previous window D t-1 Standardization is performed to eliminate scale bias, resulting in standardized data. ;
[0056]
[0057] in, and These are the mean and standard deviation of the features within the corresponding window, respectively;
[0058] Step 2.2: Calculate the covariance matrix of the two window data. ,
[0059] Depend on:
[0060]
[0061] ∑ is a diagonal matrix
[0062] It can be known that:
[0063]
[0064]
[0065] And perform eigenvalue decomposition to obtain eigenvalue vectors sorted in descending order. ,
[0066] Depend on:
[0067]
[0068] It can be known that:
[0069]
[0070]
[0071] in The determinant operator is used to represent the matrix operations. Represents the identity matrix. Represents eigenvalues, [ This represents a sequence of eigenvalues arranged in descending order. This means that transposing these vectors constitutes the spectral signature of the data. Indicates that it originates from a time window. The i-th largest eigenvalue, Indicates that it originates from a time window. The i-th largest eigenvalue.
[0072] Step 2.3: To ensure the robustness of the comparison, the data is truncated to a uniform dimension and processed to generate a spectral signature vector that reflects the data distribution structure.
[0073] Step 2.4: Select the first K principal component vectors E Proc D t and E Proc D t-1 ,
[0074] Depend on:
[0075]
[0076] It can be known that:
[0077]
[0078]
[0079] Then, cosine similarity is used to quantify the similarity between these processed vectors.
[0080]
[0081] This measures the degree of difference in their angles, and then the inverse cosine function is taken from the similarity score, i.e.
[0082] Derive the drift angle θ drift .
[0083] Step 2.5: Finally, θ drift With the preset threshold θ threshold Compare them. If θ drift ≥θ threshold This indicates that a drift has occurred; otherwise, it is determined that no drift has occurred.
[0084]
[0085] Step 3: Strategic Sample Selection Based on KL Divergence. To efficiently utilize the limited memory buffer, this invention designs an optimized sample selection strategy, which consists of two stages:
[0086] Step 3.1: Introduce the mask vector m o The aim is to retain older samples from the buffer that represent the current and historical common distributions, in order to minimize the new data distribution H. new Compared with the old sample distribution H old( m o) Using the Kullback-Leibler divergence between them as the objective, construct an optimization objective. The loss function is defined as the new data distribution. Compared with the weighted old sample distribution KL divergence between: By solving this optimization problem, m is selected. o Samples with higher values were retained, among which This indicates the calculation of the Kullback-Leibler divergence. This represents a histogram model of the dataset in the feature space. It divides each feature dimension into L equally spaced intervals (bins) and counts the frequency of samples falling into each interval, thereby generating a probability distribution vector.
[0087] Where the mask vector m o Obtained through the following steps:
[0088] Step 3.1.1: First, use a preset feature projection matrix (such as the principal component eigenvector matrix obtained through PCA) to project the current data window D. t The historical buffer sample B is mapped to a low-dimensional feature space, eliminating high-dimensional noise and preserving the discriminative structure.
[0089] Step 3.1.2: Construct the probability histogram distribution
[0090] Step 3.1.2.1: In the low-dimensional feature space, divide each feature dimension into L equal-width intervals (bins);
[0091] Step 3.1.2.2: Statistical D t The frequency of samples falling into each bin is normalized to generate a new data distribution histogram H. new ;
[0092] Step 3.1.2.3: Process the buffer sample B in the same way to generate the original old sample distribution histogram H. old ;
[0093] Step 3.1.3: Initialize the learnable weight vector
[0094] Step 3.1.3.1: Define a learnable vector w with the same length as the number of samples in the buffer. o,Each element corresponds to the initial weight of an old sample;
[0095] Step 3.1.3.2: Map the weights to a continuous mask in the interval [0,1] using the Sigmoid function:
[0096]
[0097] This represents the retention confidence level of the i-th old sample.
[0098] Step 3.2: Introduce the mask vector m n The aim is to select samples from the new data stream that can capture distribution shift characteristics. An optimization objective is constructed with the goal of minimizing the Kullback-Leibler divergence between the new data distribution and the joint distribution (composed of the selected old samples and the selected new samples). The loss function is defined as the KL divergence between the new data distribution and the mixed distribution of the old and new data: Select m n Samples with higher values are added to the buffer, where Indicates the new data distribution. This indicates a joint distribution (a mixture of old and new distributions).
[0099] Step 4: Dynamic buffer update and management. Based on the detection results of Step 2, perform specific buffer update operations:
[0100] Step 4.1: If no drift occurs: Perform a conservative update, i.e., retain the mask value from step 3.1. Old samples (with their labels) (Already stored in the history buffer, originating from historical manual annotations or previously generated high-confidence pseudo-labels). Select the mask value m from step 3.2 in the current window. n Higher new samples, if manually labeled If the prediction is positive, use it directly; otherwise, use the current model to predict the new sample, retaining only samples whose prediction confidence (maximum class probability) exceeds the threshold τ (e.g., τ=0.9), and using their predicted class as the pseudo-label. If the number of representative new samples is insufficient, random supplementation will be made from the remaining samples and label assignment will be performed synchronously.
[0101] Step 4.2: If step 2 determines that a significant drift has occurred, discard all [items / items]. The old samples; fill the buffer with the highly representative new samples selected in step 3.2, and obtain the labels in the same way as in step 4.1 (manual labeling is preferred, and high-confidence pseudo-labels are generated when there are insufficient labels).
[0102] Step 4.3: The updated memory buffer consists of two parts:
[0103] Old sample set : Retained historical samples and their valid labels;
[0104] New sample set : New samples and their labels obtained through manual annotation or pseudo-labeling mechanisms.
[0105] The feature vector of historical representative samples retained in the memory buffer (subscript i is the index, superscript o indicates old) represents the distribution of old knowledge to be retained (such as historical normal traffic or known attack patterns).
[0106] Historical authenticity label;
[0107] : The feature vector of the newly selected representative sample in the memory buffer (subscript j is the index, superscript n means new), representing the new distribution features to be learned (such as new attacks or traffic patterns after drift).
[0108] : This is a manually labeled or verified pseudo-label;
[0109] Step 5: Construct a model fine-tuning mechanism based on gradient projection memory
[0110] Step 5.1: Construct a loss function with task-specific weights. To enhance the learning of new drift patterns, a loss function with task-specific weights is constructed. Introducing weight parameters New samples in the buffer are assigned higher weights than old samples. ,Right now: ,in This represents the old sample data and its corresponding labels stored in the memory buffer. This represents the new sample data and its corresponding label stored in the memory buffer. This represents the loss calculation function for a single sample.
[0111] Step 5.2: Dynamically adjust the optimization target based on the drift determination results from Step 2:
[0112] If the task is in a non-drift state, add a regularization term to the task loss function. To consolidate old knowledge, among which This is a regularization loss that helps preserve important weights, and λ is a hyperparameter that balances the contribution of the task-specific loss and the regularization term. If in a drift state, the regularization term is removed, and the loss is directly calculated using... To optimize the objective, the gradient projection mechanism is activated.
[0113] Step 5.3: During gradient projection, the old sample set retained from the updated memory buffer is obtained using the singular value decomposition (SVD) technique. We extract orthogonal bases of key features from the activation values to construct a core feature subspace representing historical knowledge. Specifically, this is used when the model processes old sample sets. At that time, the activation values generated by the model at the p-th layer for the current input data are reorganized into matrix R, and matrix R is decomposed to obtain... Where U is a left singular vector matrix, representing an orthogonal basis for the column space; ∑ is a diagonal matrix, with the elements on the diagonal being singular values. And arranged in descending order ( , (,….), reflecting the importance of the corresponding feature direction; V T It is the transpose of the right singular vector matrix. Then, based on the information retention threshold... (e.g., 0.95), select the first k singular vectors such that their cumulative energy satisfies The orthogonal basis matrix formed by these vectors This refers to the core feature subspace that needs to be protected in this layer, where Representation: The representation matrix is the output of the p-th layer neurons in the first learning phase of the model. It represents the model's understanding of the original features of the input data at that layer. This represents the square of the Frobenius norm of a matrix. Physically, it represents the total energy or total information content of the matrix (i.e., the sum of the squares of all elements, equivalent to the sum of the squares of all singular values). );
[0114] Step 5.4: Perform orthogonal gradient projection and parameter update. Project the gradient of the new task onto the orthogonal complement space of the historical feature subspace, and update the network parameters using the corrected gradient, ensuring that the update direction does not interfere with the existing historical knowledge representation. First, calculate the original gradient. Then, calculate the loss function on the model parameters through backpropagation. gradient Then, gradient projection is performed. The original gradient is projected onto the historical feature subspace. On the orthogonal complement space, components that conflict with historical knowledge are removed. The projection formula is:
[0115]
[0116] Using the projected gradient Update the network weights. This ensures that parameter updates only occur in directions orthogonal to historical knowledge, thus avoiding catastrophic forgetting at the model parameter level.
[0117] Step 6: Real-time traffic detection and classification application
[0118] After fine-tuning the gradient projection-based model, the system uses the updated network intrusion detection model to detect incoming network traffic in real time. Real-time network traffic packets are received as samples to be detected and input into the model. The traffic category is then determined based on the model's output classification results.
[0119] Example 2
[0120] Suppose we are in a dynamically changing smart city Internet of Things (IoT) network environment, containing a large number of sensor nodes and edge devices that continuously generate network traffic data. Over time, new smart devices are introduced into the network, causing changes in normal traffic patterns. Simultaneously, attackers exploit newly emerging vulnerabilities to launch an unknown denial-of-service (DoS) attack. We aim to use the method provided in this invention to detect intrusions in this network environment and ensure that the model adapts to new traffic distributions without forgetting existing detection capabilities.
[0121] Step 1: We first perform streaming data collection on the continuous traffic data in the smart city network, dividing the continuously arriving traffic data into different time windows or batches. We denote the data in the current time window as D. t The data from the previous time window is denoted as D. t−1 This serves as the input sequence for continuous learning.
[0122] Step 2: We use the PCA module to perform drift detection on continuous data windows. Specifically, we perform drift detection on D... t and D t−1 Standardize the data and calculate its covariance matrix. Through eigenvalue decomposition, we extract eigenvectors representing the principal components of the data distribution. We calculate the cosine similarity between these two feature vector sets and derive the drift angle θ. drift In this embodiment, we found that the calculated θ drift Greater than the preset threshold θ threshold This means that there is a significant concept drift in the network (e.g., changes in data distribution due to the access of new smart devices).
[0123] Step 3: To address the detected concept drift, we initiate a strategic sample selection and forgetting mechanism to update the memory buffer. We do this by minimizing the KL divergence loss function. and We calculate the selection mask for the samples. In this embodiment, we identify the new traffic samples (i.e., m) that are highly representative in the current batch. n We select samples with higher mo values (samples that capture new device behavior patterns and potential new attack features), and identify old samples in the buffer that no longer represent the current public distribution (i.e., samples with low mo values). We remove these invalid old samples and add selected new samples to the buffer. If labeling resources are insufficient, we use the detection model to generate pseudo-labels to supplement them, thus completing the dynamic update of the buffer.
[0124] Step 4: For the detected concept drift, we perform differentiated memory buffer update and forgetting operations. Specifically, we adopt an adaptive forgetting strategy, forcibly discarding all representative mask values m in the buffer. o We first remove old samples with a confidence score < 0.5 to prevent old knowledge from interfering with the model's adaptation to the new environment. Then, we fill the space freed up in the buffer with the highly representative new samples (including traffic from new smart devices and DoS attack traffic) selected in step 3. If some new samples lack manual annotation, we use the detection model to generate high-confidence pseudo-labels to supplement them, thereby completing the rapid refresh of the buffer and ensuring that the training dataset contains sufficient new threat samples.
[0125] Step 5: Construct a model fine-tuning mechanism based on gradient projection memory. First, we construct a loss function that includes task-specific weights. Give higher weight parameters to new device traffic and DoS attack samples in the buffer. This forces the model to prioritize these new patterns. Given that the network is in a drifting state, we remove the regularization term from the loss function, making the objective function the optimal one. The gradient projection mechanism is then activated. The system first performs SVD decomposition on historical activation values to extract orthogonal bases representing traditional sensor flow patterns. When calculating the gradient for the new task (DoS attack detection), we project the original gradient onto this historical feature subspace. On the orthogonal complement space, this means that the direction of parameter updates is restricted to the dimension that does not affect the traditional sensor feature recognition, ensuring that when the model learns new DoS attack features, its update direction is orthogonal to the feature representation of historical sensor traffic.
[0126] Step 6: The updated model was used to perform real-time detection of subsequent network traffic. The results showed that the model not only successfully identified new types of DoS attack behavior mixed in with the traffic (classified as abnormal), but also accurately determined that early traditional sensor traffic and newly added smart device traffic were normal behavior. This demonstrates that the method of this invention successfully adapts to new knowledge and retains old knowledge in the face of conceptual drift in the network environment.
[0127] In summary, the present invention has the following characteristics:
[0128] Addressing catastrophic forgetting: By introducing a gradient projection mechanism, this invention explicitly avoids feature directions crucial to historical knowledge during parameter updates. This geometric constraint ensures that new knowledge acquisition does not overwrite old knowledge, thereby maintaining a high detection rate against historical attacks over long-term operation.
[0129] Enhanced dynamic adaptability: Through a PCA-based unsupervised drift detection module, the system can keenly perceive subtle changes in data distribution. Combined with strategic sample selection, the model can quickly adjust its learning focus and adapt rapidly to attack variants or new types of attacks.
[0130] Optimized resource utilization: The strategic buffer management method proposed in this invention selects samples based on distribution representativeness. This enables the model to utilize the most informative samples for training within limited storage space and labeling resources, improving training efficiency and sample effectiveness.
Claims
1. An intrusion detection method for continuous learning networks based on gradient projection and concept drift detection, characterized in that, Includes the following steps: Step 1: Receive network traffic data streams, define the data for the current time window and the data for the previous time window, and use them as input for continuous learning; Step 2: Perform characteristic variance analysis on the data from the two consecutive time windows in Step 1, and use principal component analysis to quantify the distribution changes to determine whether concept drift has occurred; Step 3: Based on the drift detection results in Step 2, implement a strategic sample selection strategy, calculate the representativeness mask of the old samples and the new samples respectively, and select the most representative samples from the historical memory buffer and the current data stream. Step 4: Based on the drift determination results in Step 2 and the samples selected in Step 3, perform differentiated memory buffer update and forgetting operations to dynamically adjust the sample composition in the buffer. Step 5: Fine-tune the intrusion detection model using the updated memory buffer. By introducing a gradient projection mechanism, new attack patterns are learned while preserving the historical knowledge feature subspace, resulting in an updated network intrusion detection model.
2. The method according to claim 1, characterized in that, The specific steps of step 2 are as follows: Step 2.1: Analyze the current data window D respectively. t And the previous data window D t-1 The eigenvalues are standardized to eliminate scale bias. Step 2.2: Calculate the covariance matrix of the two window data and perform eigenvalue decomposition to obtain the eigenvalue vectors arranged in descending order; Step 2.3: Truncate and process the eigenvalue vector to generate a spectral signature vector that reflects the data distribution structure; Step 2.4: Calculate the cosine similarity between the two processed feature vectors, and derive the drift angle accordingly. ; Step 2.5: Adjust the drift angle With the preset threshold The comparison is performed. If the drift angle is greater than or equal to the threshold, it is determined that concept drift has occurred; otherwise, it is determined that no drift has occurred.
3. The method according to claim 1, characterized in that, The specific steps of step 3 are as follows: Step 3.1: First, using the preset feature projection matrix, project the current data window D... t The historical buffer sample B is mapped to a low-dimensional feature space, and an L-bin probability histogram distribution is constructed, denoted as H. new and H old Then define a learnable weight vector w with the same length as the buffer samples. o The w is converted using the Sigmoid function. o The mapping is a continuous mask with values between [0, 1]. To minimize the new data distribution H new Compared with the old sample distribution H old( m o) Using the Kullback-Leibler divergence between the two as the target, we select old samples that can represent the common features of the old and new data; Step 3.2: Maintain the optimization completed in Step 3.1 The state remains unchanged, thus determining the boundary of the selected old knowledge, and defining a learnable mask for the new samples in the current window. Construct a joint distribution histogram H combined H combined Composed of both selected old samples and candidate new samples, the goal is to minimize the Kullback-Leibler divergence between the new data distribution and the joint distribution (composed of the selected old samples and the candidate new samples) to select new samples that can represent the actual distribution drift. Step 3.3: By optimizing the loss functions of the above two stages, determine the final set of old samples to be retained and the set of newly added samples.
4. The method according to claim 1, characterized in that, The specific steps of step 4 are as follows: Step 4.1: If Step 2 determines that no significant drift has occurred, then perform maintenance update: first remove old samples that are not representative enough from the buffer and add new samples that are highly representative. If the number of representative new samples is insufficient, then randomly supplement new samples. Step 4.2: If Step 2 determines that a significant drift has occurred, then perform adaptive forgetting: discard all old samples in the buffer that cannot represent the common distribution, and make room to accept new samples that reflect the characteristics of the new distribution; Step 4.3: In step 4.2, if there are insufficient manual annotation resources for new samples, use the detection model to generate pseudo-labels to annotate the remaining selected new samples in order to refresh the buffer.
5. The method according to claim 1, characterized in that, The specific steps of step 5 are as follows: Step 5.1: Construct a task loss function that includes task-specific losses by introducing weight parameters. A task-specific loss function is constructed by assigning higher weights to new samples in the memory buffer than to old samples. ,in This represents the old sample data and its corresponding labels stored in the memory buffer. This represents the new sample data and its corresponding label stored in the memory buffer. This represents the loss calculation function for a single sample; Step 5.2: Dynamically adjust the optimization target based on the drift determination result in Step 2. If the target is in a non-drift state, add a regularization term to the task loss function, which is represented as follows: ,in This is a regularization loss that helps preserve important weights. λ is a hyperparameter that balances the contribution of task-specific loss and the regularization term, constraining weight updates to reinforce existing knowledge. If in a drift state, the regularization term is removed, and the task loss function becomes... And activate the gradient projection mechanism; Step 5.3: During the gradient projection process, the singular value decomposition of the activation value matrix of the input data at a specific layer of the model is performed, and an orthogonal basis that meets the conditions is selected according to the preset information retention threshold to construct the historical feature subspace; Step 5.4: Project the gradient of the new task onto the orthogonal complement space of the historical feature subspace to ensure that the parameter update direction does not interfere with the existing historical knowledge representation, thereby realizing the parameter update of the model.
6. The method according to claim 1, characterized in that, The specific implementation of gradient projection in step 5.5 includes: The activation values of the new data stream at each layer of the model are obtained and orthogonalized relative to the existing knowledge base to obtain the residual gradient space. The residual gradient space is decomposed, new orthogonal bases are extracted, and the knowledge base is expanded accordingly. When updating parameters through backpropagation, the gradient direction is corrected by subtracting the projection component of the gradient onto the historical memory matrix from the total gradient, so that the update only occurs in the direction orthogonal to the historical knowledge.
7. A network intrusion detection continuous learning system based on gradient projection and drift detection, characterized in that, When the processor executes the system, it implements the method as described in any one of claims 1-6.