Network intrusion detection method based on small sample class incremental learning strategy
Through the FSCIL-NID method, technologies such as meta-learning and self-attention mechanism are used to solve the problem of incremental learning of small sample classes in network intrusion detection, improve the detection ability of new attacks and the classification performance of old attacks, and achieve rapid response and efficient detection.
Patent Information
- Application Number
- CN202410515365.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-26
- Publication Date
- 2024-08-27
AI Technical Summary
Existing network intrusion detection methods cannot effectively handle new attacks and quickly adapt to new samples. Especially in small sample incremental learning scenarios, it is difficult to avoid potential risks and property losses.
A network intrusion detection method FSCIL-NID based on a small sample class incremental learning strategy is proposed. It mines intrusion patterns from a small number of samples through meta-learning, using feature extractors, prototype enhancement modules and distance-based classifiers, combined with parameter protection , self-attention mechanism and knowledge distillation to improve the model's generalization ability against emerging attacks.
It improves the precision, accuracy and recall rate of network intrusion detection, can quickly respond to new types of attacks, reduces catastrophic forgetting, maintains high performance against old attacks, and effectively meets the challenges of network intrusion detection in the real world.
Smart Images

Figure CN118555092A
Abstract
Description
Technical Field
[0001] The invention relates to a classification method, in particular to a network intrusion detection method based on a small sample class incremental learning strategy, and belongs to the technical field of network intrusion detection. Background Art
[0002] With the rapid development of information technology, cyberspace security issues are becoming increasingly severe. Network intrusion detection is a practical solution to protect network systems from network attacks. However, due to the continuous emergence of new vulnerabilities and unknown attack types, only a small number of such attack samples can be captured for analysis, and the existing detection methods deployed in actual systems cannot handle these attacks. Existing network intrusion detection methods are usually supervised deep learning models, which are obtained through offline training and can achieve good performance in the early stages of system construction. However, with the rapid and diverse evolution of intrusion methods, the knowledge learned is no longer applicable to new attacks. In addition, the existing incremental learning methods lack the ability to learn quickly, making it difficult to avoid potential risks and reduce property losses when there are fewer new samples. This can be attributed to the problem of incremental intrusion detection for small sample classes. Summary of the invention
[0003] The present invention aims at the problems existing in the prior art and provides a network intrusion detection method based on a small sample class incremental learning strategy. In order to solve the problem that new attacks are difficult to classify, the present invention proposes a learning strategy called FSCIL-NID, which can cope with the increase in attack categories by expanding the source detection system. It fully mines new intrusion patterns from a small number of samples through meta-learning and maximizes the generalization ability of the model to cope with emerging attacks.
[0004] In order to achieve the above objectives, the specific technical solutions of the present invention are as follows:
[0005] Step 1: Data collection: Use the network packet capture tool wireshark or tcpdump to capture the network traffic to be detected and save it in pcap file format. Use the traffic feature extraction tool CICFlowMeter to parse the pcap file traffic data, convert it into the model input format, and save it as a csv file.
[0006] Step 2: Data preprocessing, preprocessing the data collected in step 1;
[0007] Step 3: Deep learning model training, training the Few-shot class incremental learning-network intrusion detection (FSCIL-NID) model. The FSCIL-NID model mainly consists of three modules, namely the feature extractor module, the prototype enhancement module and the distance-based classifier module. The training is divided into two stages. In the basic stage, the parameters of the first two modules are trained. In each subsequent incremental stage, the feature extractor module is fixed and only the prototype enhancement module is trained. The distance-based classifier is non-parametric and uses the nearest neighbor classifier for prediction. The model is trained using a public dataset.
[0008] Step 4: Result output. Based on the FSCIL-NID model trained in step 3, the target network traffic data is input and the intrusion detection classification result is output.
[0009] As an improvement of the present invention, step 2 is as follows: data preprocessing only needs to be digitized, and data normalization is implemented by the BatchNormal layer of the feature extractor module, so there is no need to adopt global normalization. A binarization technique called one-hot encoding method is used to convert the original features into numerical values so that the subsequent network can process these features.
[0010] As another improvement of the present invention, step 3 is as follows: FSCIL includes a basic stage and multiple incremental stages. In the basic stage, each category has sufficient training data. In the incremental stage, the amount of training data for new categories is small. The trained model should be able to classify all categories it has seen. We regard each stage of FSCIL as a task, {T0, T1, ..., T n}. The categories to be classified for each task can be regarded as {C0, C1, ..., C n}. T0 represents the basic task, {T1,...,T n} represents n incremental tasks. ΔC i represents the new category in the i-th task, C0=△C0, Corresponding to {T0,T1,...,T n} training set. Corresponding to {T0,T1,...,T n We use the episode meta-learning paradigm to address the few-shot scenarios encountered in incremental tasks. Contains a support set and a queryset i∈[0,n]. Similarly, Metric learning is used to predict the label of a sample. In the prediction process, p i ,i∈[0,n] represents the prototypes of all categories in the i-th task. The FSCIL-NID model is divided into a feature extractor module, a prototype enhancement module, and a distance-based classifier module. The model training uses the public dataset CIC-IDS2017.
[0011] As another improvement of the present invention, the feature extractor module in step 3 is specifically as follows, and the feature extractor is intended to extract features from the support set and the query set. When new categories appear, the difficulty faced by class incremental learning is that the network must be retrained so that the model can adapt to the new categories. However, the model may suffer from catastrophic forgetting. In order to maintain the model's ability to classify old classes in the incremental stage, the present invention adopts a parameter protection strategy. The feature extractor trained on the samples in the basic stage will be frozen, and in each incremental stage, the same frozen feature extractor is used for all training samples to obtain their corresponding feature vectors.
[0012] As another improvement of the present invention, the prototype enhancement module in step 3 is specifically as follows: the present invention adopts the episode meta-learning paradigm to cope with the situation where there are few new class data in the incremental stage. Each episode in has a support set and a query set, and samples are selected for each class as training data. Using the feature extractor module, the corresponding representation of each support set sample is obtained. The prototype of the class is obtained by averaging all the representations of samples in each class in the support set. The prototype p of the i-th class i From (11), we can get:
[0013]
[0014] Where M represents all the data in the support set of class i, Represents the parameters in the feature extractor. are all samples belonging to the i-th class, p i is the prototype of the ith class.
[0015] There is a certain relationship between different prototypes. However, the prototype calculated by (11) cannot capture the information of the relationship between classes. The present invention uses a self-attention mechanism to enhance the prototype to capture such relevant information. The prototype of each class is used as the input of the self-attention model. By using self-attention, each prototype can focus on the information of different prototypes from different positions. In particular, for new classes with little data, the prototype usually contains a lot of noise. It can be reduced by information aggregation and make the prototype more expressive.
[0016] In the self-attention mechanism, the prototype relationship is represented by the matrix Q = WQ ·p i and K = W K ·p i The coefficient matrix of the i-th and j-th prototypes is α ij From (12), we can get:
[0017]
[0018] where p i and p j Represent the prototypes of the i-th and j-th categories respectively. Q and W K are different linear transformations, d k is the dimension of the prototype. α is the correlation coefficient matrix.
[0019] Update each prototype according to the correlation coefficient matrix. By feeding the prototype into the self-attention mechanism, we can obtain the enhanced prototype. Equation (13) shows the enhanced prototype of the i-th class.
[0020] p i ′=p i +W V (p i )·α ij (13)
[0021] where p i ′ is the updated new prototype, W V is a linear transformation.
[0022] As another improvement of the present invention, the distance-based classifier module in step 3 is specifically as follows: samples are classified according to the distance from the prototype. The sample belongs to the class that is closest to its prototype. Metric learning requires that the two compared must belong to the same feature space. Therefore, the samples in the query set must first pass through the feature extractor module and the prototype enhancement module. After prediction, three loss functions are defined, namely, sample classification loss, prototype non-overlapping loss, and knowledge distillation loss, and various loss function combinations are used to update the model at each stage.
[0023] As another improvement of the present invention, the sample classification loss of the distance-based classifier module in step 3 is specifically as follows, and the loss function measures the degree of correct classification of the sample. Determine the distance between each sample and the prototype, and select the prototype closest to the sample as its label. Usually, we use the conventional cross-entropy loss function to measure the quality of the classification strategy. However, unlike the conventional cross entropy, the present invention uses a distance metric to represent the degree of proximity to each class, rather than the probability of the network output. Since the distances are all positive numbers, the minimum distance represents the most likely category. However, in the softmax step of the cross entropy function, the class to which it belongs has the highest probability. Therefore, the distance is negative so that the score obtained by the negative distance after softmax is the largest.
[0024]
[0025]
[0026] Where y is the true value, x i is a sample in the query set, and N is the number of samples in the query set. j represents the prototypes that have been seen, and k represents the number of prototypes.
[0027] As another improvement of the present invention, the prototype non-overlapping loss of the distance-based classifier module in step 3 is as follows: as new classes appear in the incremental stage, their prototypes may overlap with the prototypes of the old classes in the metric space. Once overlap occurs, the model's distance-based classification ability will drop sharply. Therefore, in the incremental stage, the prototypes of the new class should be kept as far away from the prototypes of the old class as possible. The model can highly distinguish between the new and old categories. The present invention uses the Euclidean distance to measure the distance between the old prototype and the new prototype. A nonlinear monotone decreasing function is used as the loss function, and the closest distance between the prototypes is used as the independent variable. Therefore, when the loss is optimized, the minimum distance between the prototypes will increase, and then all distances will increase.
[0028]
[0029] Among them C i-1 represents the number of categories in the i-1th stage, C i Represents the number of all categories in stage i.
[0030] As another improvement of the present invention, the knowledge distillation loss of the distance-based classifier module in step 3 is specifically as follows: in class incremental learning, in addition to using a replay-based method to combat catastrophic forgetting, a regularization-based method can also be used. Among the regularization-based methods, the most widely used is knowledge distillation. Knowledge distillation was originally designed for model compression. In order to make the lightweight model as capable as possible as a large model, the output of the large model is used as a soft label to guide the lightweight model. In FSCIL, the model of the previous stage is regarded as a teacher model, and the model of the current stage is regarded as a student model. The distance is calculated to obtain the prediction result and divided by the temperature hyperparameter. Then, the softmax function is used to obtain the prediction probability, which is used as a soft label. The maximum value in the soft label still represents the category of the sample, while other values can reflect the relationship between different categories. Equations (17) and (18) are used to obtain the soft labels of the previous stage and the current stage. The soft label of the teacher model only contains the categories it has seen. Therefore, in order to preserve the student model's memory of old categories, equation (19) compares the similarity of categories seen by the teacher model in the previous stage. Since soft labels contain more information than ordinary one-hot labels, the output of the student model should be not only close to the true label, but also as close as possible to the soft label of the teacher model. Through equations (17) and (18), two sets of probability scores are obtained. The KL (Kullback-Leibler) divergence is used to evaluate the approximation between the two sets of probability distributions. By optimizing the KL divergence, the output of the student model is as close as possible to the output of the teacher model so that knowledge can be transferred between stages. Through knowledge distillation, it is ensured that the model is still able to classify old categories in the incremental stage.
[0031]
[0032]
[0033]
[0034] in and Represent the outputs of the teacher model and the student model respectively. T is the temperature hyperparameter, C i-1 Indicates the number of categories in the i-1th stage.
[0035] In the basic stage, (15) is selected as the loss function, where the parameters that need to be updated are those in the feature extractor and the self-attention mechanism. In the incremental stage, (20) is used as the loss function, where the parameters of the feature extractor module are fixed and only the parameters in the prototype enhancement module are updated.
[0036] l all = lc +l p +l kd (20)
[0037] Compared with the prior art, the advantages of the present invention are as follows: the technical solution applies the small sample class incremental learning strategy to the network intrusion detection problem, and the proposed FSCIL-NID model is superior to the traditional machine learning algorithm and the existing deep learning algorithm in terms of precision, accuracy, recall and F1 score, indicating that the model has good performance in the network intrusion detection task and greatly improves the classification efficiency; at the same time, the detection model can quickly respond to new attacks, can cope with the challenges of new types of attacks constantly emerging in the real world, and can maintain high performance against old attacks, effectively solving the problem of catastrophic forgetting that is prevalent in class incremental learning. The present invention can more efficiently cope with the network intrusion detection problem in the real world. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 It is the overall flow chart of the present invention;
[0039] Figure 2 This is the overall architecture diagram of the FSCIL-NID model;
[0040] Figure 3 It is the structure diagram of feature extractor;
[0041] Figure 4 This is the FAT network structure diagram;
[0042] Figure 5 Enhanced structure diagram for prototypes. DETAILED DESCRIPTION
[0043] In order to deepen the understanding of the present invention, the present embodiment is described in detail below with reference to the accompanying drawings.
[0044] Example: See Figure 2 , a network intrusion detection method based on a small sample class incremental learning strategy. The method comprises the following steps:
[0045] Step 1: Data collection: Use the network packet capture tool wireshark or tcpdump to capture the network traffic to be detected and save it in pcap file format. Use the traffic feature extraction tool CICFlowMeter to parse the pcap file traffic data, convert it into the model input format, and save it as a csv file.
[0046] Step 2: Data preprocessing, preprocessing the data collected in step 1;
[0047] Step 3: Deep learning model training. The FSCIL-NID model is trained. The FSCIL-NID model mainly consists of three modules, namely the feature extractor module, the prototype enhancement module and the distance-based classifier module. The training is divided into two stages. In the basic stage, the parameters of the first two modules are trained. In each subsequent incremental stage, the feature extractor module is fixed and only the prototype enhancement module is trained. The distance-based classifier is non-parametric and uses the nearest neighbor classifier for prediction. The model is trained using a public dataset.
[0048] Step 4: Result output. Based on the FSCIL-NID model trained in step 3, the target network traffic data is input and the intrusion detection classification result is output.
[0049] Among them, step 2 is as follows: data preprocessing only needs to be digitized, and data normalization is implemented by the BatchNormal layer of the feature extractor module, so there is no need to take global normalization. A binarization technique called one-hot encoding method is used to convert the original features into numerical values so that the subsequent network can process these features.
[0050] Step 3 is as follows: FSCIL includes a basic stage and multiple incremental stages. In the basic stage, each category has sufficient training data. In the incremental stage, the amount of training data for new categories is small. The trained model should be able to classify all categories it has seen. We regard each stage of FSCIL as a task, {T0,T1,...,T n}. The categories to be classified for each task can be regarded as {C0, C1, ..., C n}. T0 represents the basic task, {T1,...,T n} represents n incremental tasks. ΔC i represents the new category in the i-th task, C0=△C0, Corresponding to {T0,T1,...,T n} training set. Corresponding to {T0,T1,...,T n We use the episode meta-learning paradigm to address the few-shot scenarios encountered in incremental tasks. Contains a support set and a queryset i∈[0,n]. Similarly, Metric learning is used to predict the label of a sample. In the prediction process, p i, i∈[0,n] represents the prototypes of all categories in the i-th task. The FSCIL-NID model is divided into a feature extractor module, a prototype enhancement module, and a distance-based classifier module. The model training uses the public dataset CIC-IDS2017. The overall architecture of the FSCIL-NID model is shown in the figure below. Figure 2 The pseudo code of FSCIL-NID is as follows:
[0051]
[0052] Among them, the feature extractor module in step 3 is specifically as follows. The feature extractor is designed to extract features from the support set and the query set. When new categories appear, the difficulty faced by class incremental learning is that the network must be retrained so that the model can adapt to the new categories. However, the model may suffer from catastrophic forgetting. In order to maintain the model's ability to classify old classes in the incremental stage, the present invention adopts a parameter protection strategy. The feature extractor trained on the samples in the basic stage will be frozen, and in each incremental stage, the same frozen feature extractor will be used for all training samples to obtain their corresponding feature vectors. The structural diagram of the feature extractor is shown in Figure 3 and Figure 4 shown.
[0053] Among them, the prototype enhancement module in step 3 is specifically as follows. The present invention adopts the episode meta-learning paradigm to deal with the situation where there are few new class data in the incremental stage. Each episode in has a support set and a query set, and samples are selected for each class as training data. Using the feature extractor module, the corresponding representation of each support set sample is obtained. The prototype of the class is obtained by averaging all representations of samples in each class in the support set. The network structure is as follows Figure 5 As shown, the prototype p of the i-th class i From (21), we can get:
[0054]
[0055] Where M represents all the data in the support set of class i, Represents the parameters in the feature extractor. are all samples belonging to the i-th class, p i is the prototype of the ith class.
[0056] There is a certain relationship between different prototypes. However, the prototype calculated by (21) cannot capture the information of the relationship between classes. The present invention uses a self-attention mechanism to enhance the prototype to capture such relevant information. The prototype of each class is used as the input of the self-attention model. By using self-attention, each prototype can focus on the information of different prototypes from different positions. In particular, for new classes with little data, the prototype usually contains a lot of noise. It can be reduced by information aggregation and make the prototype more expressive.
[0057] In the self-attention mechanism, the prototype relationship is represented by the matrix Q = W Q ·p i and K = W K ·p i The coefficient matrix of the i-th and j-th prototypes is α ij From (22), we can get:
[0058]
[0059] where p i and p j Represent the prototypes of the i-th and j-th categories respectively. Q and W K are different linear transformations, d k is the dimension of the prototype. α is the correlation coefficient matrix.
[0060] Update each prototype according to the correlation coefficient matrix. By inputting the prototype into the self-attention mechanism, we can obtain the enhanced prototype. Equation (23) shows the enhanced prototype of the i-th class.
[0061] p i ′=p i +W V (p i )·α ij (twenty three)
[0062] where p i ′ is the updated new prototype, W V is a linear transformation.
[0063] The distance-based classifier module in step 3 is as follows: samples are classified according to their distance from the prototype. Samples belong to the class that is closest to their prototype. Metric learning requires that the two objects being compared must belong to the same feature space. Therefore, the samples in the query set must first pass through the feature extractor module and the prototype enhancement module. After prediction, three loss functions are defined, namely, sample classification loss, prototype non-overlapping loss, and knowledge distillation loss, and various loss function combinations are used to update the model at each stage.
[0064] Among them, the sample classification loss of the distance-based classifier module in step 3 is specifically as follows, and the loss function measures the degree of correct classification of the sample. Determine the distance between each sample and the prototype, and select the prototype closest to the sample as its label. Usually, we use the conventional cross-entropy loss function to measure the quality of the classification strategy. However, unlike the conventional cross entropy, the present invention uses a distance metric to represent the degree of proximity to each class, rather than the probability of the network output. Since the distances are all positive numbers, the smallest distance represents the most likely category. However, in the softmax step of the cross entropy function, the class to which it belongs has the highest probability. Therefore, the distance is negative so that the score obtained by the negative distance after softmax is the largest.
[0065]
[0066]
[0067] Where y is the true value, x i is a sample in the query set, and N is the number of samples in the query set. j represents the prototypes that have been seen, and k represents the number of prototypes.
[0068] Among them, the prototype non-overlapping loss of the distance-based classifier module in step 3 is specifically as follows: as new classes appear in the incremental stage, their prototypes may overlap with the prototypes of the old classes in the metric space. Once overlap occurs, the model's distance-based classification ability will drop sharply. Therefore, in the incremental stage, the prototype of the new class should be kept as far away from the prototype of the old class as possible. The model can highly distinguish between new and old categories. The present invention uses Euclidean distance to measure the distance between the old prototype and the new prototype. A nonlinear monotone decreasing function is used as the loss function, and the closest distance between the prototypes is used as the independent variable. Therefore, when the loss is optimized, the minimum distance between the prototypes will increase, and then all distances will increase.
[0069]
[0070] Among them C i-1 represents the number of categories in the i-1th stage, C i Represents the number of all categories in stage i.
[0071] Among them, the knowledge distillation loss of the distance-based classifier module in step 3 is as follows. In class incremental learning, in addition to using replay-based methods to combat catastrophic forgetting, regularization-based methods can also be used. Among the regularization-based methods, the most widely used is knowledge distillation. Knowledge distillation was originally designed for model compression. In order to make the lightweight model as capable as a large model as possible, the output of the large model is used as a soft label to guide the lightweight model. In FSCIL, the model of the previous stage is regarded as a teacher model, and the model of the current stage is regarded as a student model. The distance is calculated to obtain the prediction result and divided by the temperature hyperparameter. Then, the softmax function is used to obtain the prediction probability, which is used as a soft label. The maximum value in the soft label still represents the category of the sample, while other values can reflect the relationship between different categories. Equations (27) and (28) are used to obtain the soft labels of the previous stage and the current stage. The soft label of the teacher model only contains the categories it has seen before. Therefore, in order to preserve the student model's memory of old categories, equation (29) compares the similarity of categories seen by the teacher model in the previous stage. Since soft labels contain more information than ordinary one-hot labels, the output of the student model should be not only close to the true label, but also as close as possible to the soft label of the teacher model. Through equations (27) and (28), two sets of probability scores are obtained. The KL (Kullback-Leibler) divergence is used to evaluate the approximation between the two sets of probability distributions. By optimizing the KL divergence, the output of the student model is as close as possible to the output of the teacher model so that knowledge can be transferred between stages. Through knowledge distillation, it is ensured that the model is still able to classify old categories in the incremental stage.
[0072]
[0073]
[0074]
[0075] in and Represent the outputs of the teacher model and the student model respectively. T is the temperature hyperparameter, C i-1 Indicates the number of categories in the i-1th stage.
[0076] In the base phase, (25) is selected as the loss function, where the parameters that need to be updated are those in the feature extractor and the self-attention mechanism. In the incremental phase, (30) is used as the loss function, where the parameters of the feature extractor module are fixed and only the parameters in the prototype enhancement module are updated.
[0077] l all = l c+l p +l kd (30)
[0078] It should be noted that the above embodiments are not intended to limit the protection scope of the present invention, and equivalent changes or substitutions made on the basis of the above technical solutions all fall within the protection scope of the claims of the present invention.
Claims
1. A network intrusion detection method based on a small sample class incremental learning strategy, comprising the following steps: Step 1: Data collection: Use the network packet capture tool wireshark or tcpdump to capture the network traffic to be detected and save it in pcap file format. Use the traffic feature extraction tool CICFlowMeter to parse the pcap file traffic data, convert it into the model input format, and save it as a csv file. Step 2: Data preprocessing, preprocessing the data collected in step 1; Step 3: Deep learning model training. The Few-shot class incremental learning-network intrusion detection (FSCIL-NID) model is trained. The FSCIL-NID model mainly consists of three modules, namely the feature extractor module, the prototype enhancement module and the distance-based classifier module. The training is divided into two stages. In the basic stage, the parameters of the first two modules are trained. In each subsequent incremental stage, the feature extractor module is fixed and only the prototype enhancement module is trained. The distance-based classifier is non-parametric and uses the nearest neighbor classifier for prediction. The model is trained using a public dataset. Step 4: Result output. Based on the FSCIL-NID model trained in step 3, the target network traffic data is input and the intrusion detection classification result is output.
2. The network intrusion detection method based on small sample class incremental learning strategy according to claim 1 is characterized in that: Step 2 is as follows: data preprocessing only requires digitization. Data normalization is implemented by the BatchNormal layer of the feature extractor module, so there is no need to adopt global normalization. A binarization technique called one-hot encoding method is used to convert the original features into numerical values so that the subsequent network can process these features.
3. The network intrusion detection method based on small sample class incremental learning strategy according to claim 1 is characterized in that: Step 3 is as follows: FSCIL includes a basic stage and multiple incremental stages. In the basic stage, each category has enough training data. In the incremental stage, the amount of training data for new categories is small. The trained model should be able to classify all categories it has seen. Each stage of FSCIL is regarded as a task, {T0,T1,...,T n }, the categories to be classified for each task are considered as {C0,C1,...,C n }, T0 represents the basic task, {T1,...,T n } represents n incremental tasks, ΔC i represents the new category in the i-th task, C0=△C0, Corresponding to {T0,T1,...,T n } training set, Corresponding to {T0,T1,...,T n } test set, using the episode meta-learning paradigm to solve the few-sample scenarios encountered in incremental tasks, Contains a support set and a queryset i∈[0,n], similarly, Metric learning is used to predict the label of the sample. During the prediction process, p i ,i∈[0,n] represents the prototypes of all categories in the i-th task. The FSCIL-NID model is divided into a feature extractor module, a prototype enhancement module and a distance-based classifier module. The model training uses the public dataset CIC-IDS2017.
4. The network intrusion detection method based on small sample class incremental learning strategy according to claim 3 is characterized in that: The feature extractor module is specifically as follows: the feature extractor is designed to extract features from the support set and the query set. When new categories appear, the difficulty faced by class incremental learning is that the network must be retrained so that the model can adapt to new categories. The feature extractor trained with samples in the basic stage will be frozen, and in each incremental stage, the same frozen feature extractor is used for all training samples to obtain their corresponding feature vectors.
5. The network intrusion detection method based on small sample class incremental learning strategy according to claim 3 is characterized in that: The prototype enhancement module is as follows: It adopts the episode meta-learning paradigm to deal with the situation where there are few new class data in the incremental stage. Each episode in has a support set and a query set, and selects samples for each category as training data. Using the feature extractor module, the corresponding representation of each support set sample is obtained. The prototype of the class is obtained by averaging all representations of samples in each class in the support set. The prototype p of the i-th class is i From (1), we can get: Where M represents all the data in the support set of class i, represents the parameters in the feature extractor, are all samples belonging to the i-th class, p i is the prototype of the i-th class, In the self-attention mechanism, the prototype relationship is represented by the matrix Q = W Q ·p i and K = W K ·p i Multiply them together, which is a correlation coefficient matrix, the coefficient matrix α of the i-th and j-th prototypes ij From (2), we can get: where p i and p j Represent the prototypes of the i-th and j-th categories, W Q and W K are different linear transformations, d k is the dimension of the prototype, α is the correlation coefficient matrix, Update each prototype according to the correlation coefficient matrix, and obtain the enhanced prototype by inputting the prototype into the self-attention mechanism. Equation (3) shows the enhanced prototype of the i-th category, p i ′=p i +W V (p i )·α ij (3) where p i ′ is the updated new prototype, W V is a linear transformation.
6. The network intrusion detection method based on small sample class incremental learning strategy according to claim 3 is characterized in that: The distance-based classifier module is as follows: samples are classified according to the distance from the prototype, and the samples belong to the class that is closest to their prototype. Metric learning requires that the two being compared must belong to the same feature space. Therefore, the samples in the query set must first pass through the feature extractor module and the prototype enhancement module. After prediction, three loss functions are defined, namely sample classification loss, prototype non-overlapping loss, and knowledge distillation loss. Various loss function combinations are used to update the model at each stage.
7. The network intrusion detection method based on small sample class incremental learning strategy according to claim 6 is characterized in that: The sample classification loss is as follows. This loss function measures the degree of correct classification of the sample, determines the distance between each sample and the prototype, and selects the prototype closest to the sample as its label. In the softmax step of the cross entropy function, the class to which it belongs has the highest probability. Therefore, the distance is negative so that the score obtained by the negative distance after softmax is the largest. Where y is the true value, x i is the sample in the query set, N is the number of samples in the query set, and p j represents the prototypes that have been seen, and k represents the number of prototypes.
8. The network intrusion detection method based on small sample class incremental learning strategy according to claim 6 is characterized in that: The prototype non-overlapping loss is as follows: the Euclidean distance is used to measure the distance between the old prototype and the new prototype, a nonlinear monotonically decreasing function is used as the loss function, and the closest distance between the prototypes is used as the independent variable. Therefore, when the loss is optimized, the minimum distance between the prototypes will increase, and then all distances will increase. Among them C i-1 represents the number of categories in the i-1th stage, C i Represents the number of all categories in stage i.
9. The network intrusion detection method based on small sample class incremental learning strategy according to claim 6 is characterized in that: The knowledge distillation loss is as follows: KL (Kullback-Leibler) divergence is used to evaluate the approximation between the two sets of probability distributions. By optimizing the KL divergence, the output of the student model is as close as possible to the output of the teacher model so that knowledge can be transferred between stages. Through knowledge distillation, it is ensured that the model can still classify old categories in the incremental stage. in and denote the outputs of the teacher model and the student model respectively, T is the temperature hyperparameter, and C i-1 represents the number of categories in the i-1th stage, In the basic stage, (5) is selected as the loss function, where the parameters that need to be updated are those in the feature extractor and the self-attention mechanism. In the incremental stage, (10) is used as the loss function, where the parameters of the feature extractor module are fixed and only the parameters in the prototype enhancement module are updated. l all =l c +l p +l kd (10)。
Citation Information
Patent Citations
Small sample network intrusion detection incremental learning classification method based on branch strategy
CN117095243A
Small sample increment radiation source individual identification method based on knowledge distillation and graph model
CN117496228A
Network traffic detection method and system based on meta-learning framework and oriented to Internet of Things security
CN117692181A
Cited By
Industrial Internet of Things intrusion detection method based on deep learning
CN119172159A
Malicious encrypted traffic detection method and system based on incremental learning
CN119316233A
A method and system for detecting malicious encrypted traffic based on incremental learning
CN119316233B
