A Network Traffic Anomaly Detection System and Method Based on Adversarial Masking
By designing adversarial attack algorithms targeting network traffic characteristics, generating adversarial examples and combining them with an encoder network, the problem of invalid data generation by random masking models is solved, thereby improving the model training efficiency and detection accuracy of network traffic anomaly detection.
Patent Information
- Application Number
- CN202211391596.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-08
- Publication Date
- 2025-10-28
- Estimated Expiration
- 2042-11-08
AI Technical Summary
Existing random masking models may generate invalid data in network traffic anomaly detection, resulting in low model learning efficiency and low detection accuracy, and lack of effective utilization of adversarial examples.
We design an adversarial attack algorithm targeting network traffic characteristics. By generating adversarial mask generation modules to produce more challenging fake samples for the model, and combining them with encoder networks and feature vector evaluation modules, we can improve model training efficiency and detection accuracy.
The generated adversarial examples can effectively improve the training efficiency and detection performance of the model. By jointly training the adversarial mask generation module and the encoder network, richer latent features can be captured, thereby improving the detection performance of the classification model.
Smart Images

Figure CN115589329B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of network traffic anomaly detection, and in particular to a network traffic anomaly detection system and method based on adversarial masking. Background Technology
[0002] With the rapid development of machine learning, machine learning-based network anomaly detection models have become the mainstream solution. By extracting features from traffic and classifying them using detectors, they significantly improve the detection performance of network anomaly detection systems, overcoming the shortcomings of traditional network traffic anomaly detection systems, such as unstable detection, low processing efficiency, and poor adaptability. Recent research has revealed the vulnerability of machine learning models, making them susceptible to being fooled by carefully crafted examples. Therefore, to effectively address the threat of adversarial examples, considerable work has focused on improving the robustness of network anomaly detection models.
[0003] However, research on leveraging adversarial examples to improve the accuracy of network anomaly detection models remains scarce. Because it is difficult to collect large amounts of labeled data samples in this field, some studies have opted to use random masking models as a pre-processing task to better learn sample features. While random masking models act as data augmentation, it is unknown which class of real sample data manifold the generated fake samples belong to, which may lead to ineffective learning of the pre-processing model. Although researchers in image recognition have recently begun to utilize adversarial targets to improve the representation learning ability of image encoders, the application of adversarial examples in network traffic anomaly detection has not yet been studied. Furthermore, network traffic features differ from image features; not every feature is continuous. Therefore, designing a unique adversarial example generation algorithm specific to the field of network security is particularly crucial.
[0004] In their Chinese invention patent application "A Deep Learning Model Optimization Method Based on Data Defense" (application number: CN202010712774.2), Chen Zhenyu et al. optimized their model to counter adversarial example attacks. Their data-level defense strategy primarily involved injecting adversarial examples into the training dataset during the training phase and then retraining the model, or modifying and reconstructing the samples during the prediction phase and inputting the transformed adversarial examples into the original model for prediction. They used open-source adversarial example generation tools to generate adversarial examples for the test model and the target dataset, comparing the success rate of the model on the specified dataset before and after adversarial example generation. However, this invention falls under the category of optimizing the training model or prediction phase using adversarial examples in the field of image recognition.
[0005] Therefore, those skilled in the art are dedicated to developing a new method for detecting network traffic anomalies and providing a unique adversarial sample generation algorithm in the field of network security, overcoming the problem that the above-mentioned random masking model may generate invalid data. Summary of the Invention
[0006] In view of the above-mentioned deficiencies of the prior art, the technical problem to be solved by the present invention is how to overcome the problem that random masking models may generate invalid data. By designing an adversarial attack algorithm targeting network traffic characteristics and introducing the adversarial attack into the masking generation model, more challenging fake samples are generated for the model, thereby helping the preceding model learn richer potential information, thus improving the efficiency of model training and detection accuracy.
[0007] To achieve the above objectives, the present invention provides a network traffic anomaly detection system based on adversarial masking, the system comprising an upstream pre-model and a downstream classification and detection model;
[0008] The pre-model includes an adversarial mask generation module, an encoder network, a feature vector evaluation module, and a mask vector evaluation module; the encoder network is trained in the upstream pre-model.
[0009] The classification and detection model includes the trained encoder network and a classifier; the classifier is trained only while keeping the weights of the encoder network unchanged to obtain the final classification model; the classification model performs classification prediction on the test dataset.
[0010] Furthermore, the adversarial mask generation module receives an original dataset consisting of original samples and generates adversarial samples of the manifold of the original samples that are far removed from the input.
[0011] The encoder network receives the adversarial samples generated by the adversarial mask generation module, and extracts the hidden features in the adversarial samples from the manually set proxy task by leveraging the nonlinear feature extraction capability of the deep neural network.
[0012] The feature vector evaluation module is connected to the encoder network, which restores the latent features into a feature form with the same dimension as the original sample, and uses the reconstruction error to measure the distance between the adversarial sample and the original sample.
[0013] The mask vector evaluation module is also connected to the encoder network to predict the location of the latent features.
[0014] Furthermore, the adversarial mask generation module includes an autoencoder, which in turn includes an encoder and a decoder. The input original sample is processed by the encoder to obtain latent features, and then the latent features are restored to a reconstructed sample with the same dimension as the original sample by the decoder. The reconstructed sample is the adversarial sample.
[0015] Furthermore, the feature vector evaluation module and the mask vector evaluation module are built in parallel.
[0016] This invention also provides a method for detecting network traffic anomalies based on adversarial masks, the method comprising the following steps:
[0017] Step 1: Preprocess the original dataset; the original dataset is network data including continuous and discrete features, composed of original samples; for the continuous features, transform them to the range of 0 to 1 using the min-max method; for the discrete features, convert them to numerical form using one-hot encoding; take 10% of the original dataset as the training dataset, and the remaining 90% as the test dataset; denote the preprocessed original dataset as... in in, Represents the set of real numbers with dimension d;
[0018] Step 2: Construct an adversarial mask generation module, which includes an autoencoder; extract the original samples from the training dataset as the training set of the autoencoder, and use the reconstruction error as the loss function of the autoencoder;
[0019] Let the autoencoder be denoted as I, and the training dataset as x, then the corresponding loss function... for:
[0020]
[0021] Here, I is equivalent to a function expression, and I(x) represents the output result when the input of the function expression is x; in In the diagram, the 2 at the bottom right indicates the value of the second norm of the vector xI(x), and the 2 at the top indicates the square of the second norm.
[0022] After the autoencoder has been trained, the loss function is used as a criterion for judging whether a sample is abnormal. If the reconstruction error of the original sample is higher than a preset threshold, it is judged as an abnormal sample; otherwise, it is a normal sample.
[0023] Step 3: Apply a pre-designed adversarial attack algorithm to generate a corresponding adversarial sample for each of the original samples in the training dataset;
[0024] Step 4: Complete the training and construction of the encoder network, feature vector evaluation module, and mask vector evaluation module;
[0025] Step 5: Connect the classifier to the pre-trained encoder network. Train only the classifier while keeping the weights of the encoder network unchanged to obtain the final classification model. The classification model then performs classification prediction on the test dataset.
[0026] Furthermore, in step 3, the adversarial attack algorithm is as follows:
[0027] Assume the original dataset is x = (x c ,x s ), where x c =(x1,x2,…,x k ), representing the continuous feature composed of k elements, while x s =(x k+1 ,x k+2 ,…,x d Let ), representing the discrete feature composed of dk elements; assuming the perturbation range is ε and the number of iterations is N, the adversarial attack algorithm for the training dataset can be expressed as:
[0028]
[0029]
[0030]
[0031] The asterisk (*) on x indicates that the data feature has been artificially manipulated. The above c * This represents the continuous features in the original dataset that have been artificially modified; The value below indicates the number of iterations in the current calculation; 0 indicates that the calculation was performed 0 times. In this context, 'n' represents the number of calculations. In this context, n+1 represents n+1 calculations; α represents the perturbation range for a single calculation, which is generally α = ε / N, within the interval [0,1]; sign represents a mathematical sign function, i.e., when x>0, sign(x) = 1; when x =0, sign(x) = 0; when x<0, sign(x) = -1; Indicates the gradient. `clip` is a truncation function that truncates the modified data. Limited to the range [x c +ε,x c -ε]; n belongs to the range [0, N-1] and gradually increases; symbol The sign is determined based on whether the original sample is abnormal. If the input original sample is abnormal, the sign is a minus sign; otherwise, it is a plus sign. is the loss function for the training dataset.
[0032] Furthermore, random feature modification is introduced into the adversarial attack algorithm. That is, for k consecutive features, p consecutive features are randomly selected as modifiable items using a uniform distribution, while the remaining kp consecutive features remain unchanged.
[0033] The expression for the adversarial attack algorithm after incorporating the random feature modification is as follows:
[0034]
[0035]
[0036]
[0037] After generating the adversarial example x * Then, the mask vector m can be expressed as:
[0038]
[0039] in, p in * This refers to the portion of continuous features in the original dataset that has been artificially modified. The XOR operation is represented by x. * This refers to the dataset composed of the adversarial samples after the random feature changes are introduced.
[0040] Furthermore, the randomly shuffled adversarial samples x * The encoder network e and the feature vector evaluation module s are used as new training datasets to train the new training dataset. f and the mask vector evaluation module s m The weight parameters; the encoder network e after training is denoted as the encoder network f;
[0041] The adversarial sample x * The latent feature vector z is obtained after compression by the encoder network e; the mask vector evaluation module s m Evaluate which feature of the input vector is modified, assuming the latent feature vector z is used as the mask vector evaluation module s. m When the input is received, the mask vector evaluation module s m The output is represented as Then the mask vector loss function It can be expressed by the following formula:
[0042]
[0043] Since m is also a d-dimensional vector, therefore m j This represents the value of the j-th feature in m;
[0044] Let the feature vector evaluation module s f Reconstruct the hidden feature vector z The corresponding objective function The expression is:
[0045]
[0046] Where x is the original dataset;
[0047] The encoder network e and the feature vector evaluation module s f and the mask vector evaluation module s m The following loss functions can be used Conduct joint training:
[0048]
[0049] Wherein, γ is used to control and The proportion between them.
[0050] Furthermore, the classifier g is connected to the encoder network f, and only the classifier g is trained while keeping the weights of the encoder network f unchanged, to obtain the final classification model.
[0051] The loss function of the classification model for:
[0052]
[0053] Among them, y n This represents the true labels in the test dataset. This represents the label predicted by the classifier g.
[0054] Furthermore, accuracy, precision, recall, and F1-score are used as evaluation metrics to assess the detection performance of the classification model on the test dataset.
[0055] The network traffic anomaly detection system and method based on adversarial masking provided by this invention has at least the following technical effects:
[0056] 1. In the field of network anomaly detection, labeled data is extremely scarce. Data augmentation using a random mask model with an empirical marginal distribution of the dataset can improve the model's detection performance. However, during the feature representation learning process, due to the uncertainty of the random mask, the sample may become too close to the original manifold space in which it resides, thus rendering the learned sample features ineffective. Therefore, the technical solution proposed in this invention uses unsupervised learning algorithms and adversarial attack algorithms to transform the random mask into a controllable adversarial mask, causing the original sample to move towards the classification boundary, thereby generating training samples that are more difficult to learn.
[0057] 2. The technical solution proposed in this invention uses adversarial examples generated from the training set as a new training set to train the encoder, enabling it to capture more representative latent spatial features, and finally apply them to downstream tasks to improve the detection performance of the classification model.
[0058] The following will further explain the concept, specific structure, and technical effects of the present invention in conjunction with the accompanying drawings, so as to fully understand the purpose, features, and effects of the present invention. Attached Figure Description
[0059] Figure 1 A schematic diagram of the adversarial sample generation process provided in a preferred embodiment of the present invention;
[0060] Figure 2 This is a framework diagram of an adversarial mask anomaly detection model provided in a preferred embodiment of the present invention. Detailed Implementation
[0061] The following description, with reference to the accompanying drawings, illustrates several preferred embodiments of the present invention to make its technical content clearer and easier to understand. The present invention can be embodied in many different forms, and the scope of protection of the present invention is not limited to the embodiments mentioned herein.
[0062] This invention provides a network traffic anomaly detection system based on adversarial masking, comprising an upstream pre-model and a downstream classification and detection model (e.g., Figure 2 (As shown).
[0063] The pre-model includes an adversarial mask generation module, an encoder network, a feature vector evaluation module, and a mask vector evaluation module; the encoder network will be trained in the upstream pre-model.
[0064] The classification and detection model includes a trained encoder network and a classifier; the classifier is trained only while keeping the weights of the encoder network unchanged to obtain the final classification model; the classification model makes classification predictions on the test dataset.
[0065] The adversarial mask generation module receives the original dataset consisting of the original samples and generates adversarial examples of the manifold that are far removed from the original samples in the input, such as... Figure 1 As shown. Unlike random mask generators that use the empirical marginal distribution of sample features to randomly replace some features to achieve sample augmentation, this adversarial mask generation module mainly generates adversarial examples that are far removed from the manifold of the original input sample. Network traffic samples differ from common image samples in that not all features are variable. When modifying features, certain network protocol specifications and specific functional constraints must be met. The generated adversarial examples must satisfy two conditions: first, only continuous features are changed and discrete features cannot be changed; second, the sample's score passing through the detector is changed in the opposite direction, causing the detector to misjudge the sample. Specifically, if the original output score of the original sample is high, then, under the premise of satisfying relevant feature constraints, some variable features are modified to reduce the output score of the sample, and vice versa. In the technical solution provided by this invention, the core of the adversarial mask generation module is an autoencoder, which consists of an encoder and a decoder. First, the original dataset composed of original samples is passed through the encoder to obtain latent features, and then the decoder is used to restore the latent features to reconstructed samples with the same dimensions as the original samples. Latent layers with lower dimensions than the input and output layers encourage the model to learn the compressed representation characteristics of the data and distinguish whether a sample is normal or not by the reconstruction error between the input sample and the reconstructed sample. Borrowing from basic iterative adversarial attack algorithms in supervised learning in the image domain, attacks on unsupervised algorithms also employ iterative methods, but with modifications to the corresponding loss function.
[0066] The encoder network receives adversarial examples generated by the adversarial mask generation module. Leveraging the nonlinear feature extraction capabilities of deep neural networks, it extracts latent features from the adversarial examples from the manually configured proxy task. The latent information extracted in the autoencoder is then used in downstream classification and detection models to achieve better prediction performance.
[0067] The feature vector evaluation module connects to the encoder network, similar to the decoder in a regular autoencoder. It restores the latent features to feature forms with the same dimensions as the original samples and uses the reconstruction error to measure the distance between the adversarial samples and the original samples.
[0068] The mask vector evaluation module is also connected to the encoder network. Similar to the feature vector evaluation module, the proxy task of this module is to predict the location of the mask features generated by the adversarial mask generation module.
[0069] The feature vector evaluation module and the mask vector evaluation module are built in parallel.
[0070] This invention also provides a network traffic anomaly detection method based on adversarial masks. First, the network anomaly detection dataset is preprocessed. Then, an adversarial mask generation model is built, and a pre-designed adversarial attack algorithm is applied to generate adversarial examples. Following this, an encoder that learns latent features is constructed, and then a feature vector evaluation module and a mask vector evaluation module are built in parallel. At this point, the pre-model is complete, and network parameter training can begin through backpropagation. After pre-training, the trained encoder and classifier are connected to form a classification and detection module. Only the classifier is trained while keeping the encoder weights unchanged, thus obtaining the final classification and detection model.
[0071] The method specifically comprises the following steps:
[0072] Step 1: The network anomaly detection dataset used in this embodiment of the invention is the NSL-KDD public network security dataset. Data preprocessing is performed on the original dataset. In the data preprocessing stage, samples of four different attack types are first marked as anomalous samples, while normal samples remain unchanged. The original dataset consists of network data including continuous and discrete features, composed of original samples. For continuous features, the min-max method is used to transform them into the range of 0 to 1; for discrete features, one-hot encoding is used to convert them into numerical form. 10% of the original dataset is used as the training dataset, and the remaining 90% is used as the test dataset. The preprocessed original dataset is denoted as... in in, Represents the set of real numbers with dimension d;
[0073] Step 2: Construct an adversarial mask generation module, which includes an autoencoder; extract the original samples from the training dataset as the training set for the autoencoder, and use the reconstruction error as the loss function of the autoencoder;
[0074] Let I denote the autoencoder and x denote the training dataset, then the corresponding loss function is... for:
[0075]
[0076] Here, I is equivalent to a function expression, and I(x) represents the output result when the input of the function expression is x; in In the diagram, the 2 at the bottom right indicates the value of the second norm of the vector xI(x), and the 2 at the top indicates the square of the second norm.
[0077] After the autoencoder has been trained, the loss function is used as a metric to determine whether a sample is abnormal. If the reconstruction error of the original sample is higher than a pre-set threshold, it is determined to be an abnormal sample; otherwise, it is a normal sample.
[0078] Step 3: Apply a pre-designed adversarial attack algorithm to generate a corresponding adversarial sample for each original sample in the training dataset;
[0079] Step 4: Complete the training and construction of the encoder network, feature vector evaluation module, and mask vector evaluation module;
[0080] Step 5: Connect the classifier to the pre-trained encoder network. Train only the classifier while keeping the weights of the encoder network unchanged to obtain the final classification model. The classification model then performs classification predictions on the test dataset.
[0081] In step 3, the adversarial attack algorithm is as follows:
[0082] Assume the original dataset is x = (x c ,x s ), where x c =(x1,x2,…,x k ), representing a continuous feature composed of k elements, while x s =(x k+1 ,x k+2 ,…,x d Let ), representing a discrete feature composed of dk elements; assuming the perturbation range is ε and the number of iterations is N, the adversarial attack algorithm for the training dataset can be expressed as:
[0083]
[0084]
[0085]
[0086] The asterisk (*) on x indicates that the data feature has been artificially manipulated. The above c * This represents continuous features in the original dataset that have been artificially modified. The value below indicates the number of iterations in the current calculation; 0 indicates that the calculation was performed 0 times. In this context, 'n' represents the number of calculations. In this context, n+1 represents n+1 calculations; α represents the perturbation range for a single calculation, which is generally α = ε / N, within the interval [0,1]; sign represents a mathematical sign function, i.e., when x>0, sign(x) = 1; when x =0, sign(x) = 0; when x<0, sign(x) = -1; Indicates the gradient. `clip` is a truncation function that truncates the modified data. Limited to the range [x c +ε,x c -ε]; n belongs to the range [0, N-1] and gradually increases; symbol The sign is determined based on whether the original sample is abnormal. If the input original sample is abnormal, the sign is a minus sign; otherwise, it is a plus sign. The loss function for the training dataset.
[0087] For a network traffic feature, the dimensions of the continuous features are fixed. In order to enable the subsequent encoder module to learn richer potential information, random feature modification is introduced. That is, for k continuous features, p continuous features are randomly selected as modifiable items using a uniform distribution, while the remaining kp continuous features remain unchanged.
[0088] The expression for the adversarial attack algorithm after introducing random feature modifications is as follows:
[0089]
[0090]
[0091]
[0092] After generating adversarial examples x * Then, the mask vector m can be expressed as:
[0093]
[0094] in, p in * This represents the portion of continuous features in the original dataset that have been artificially modified. The XOR operation is represented by x. * This represents a dataset composed of adversarial examples after random feature changes have been introduced.
[0095] Among them, the adversarial samples x are randomly shuffled * The encoder network e and the feature vector evaluation module s are used as new training datasets to train the new training dataset. f and mask vector evaluation module s mThe weight parameters; the encoder network e after training is denoted as encoder network f;
[0096] adversarial example x * The latent feature vector z is obtained after compression by the encoder network e; the mask vector evaluation module s m Evaluate which feature of the input vector is modified, assuming the latent feature vector z is used as the mask vector to evaluate module s. m When inputting, the mask vector evaluation module s m The output is represented as Then the mask vector loss function It can be expressed by the following formula:
[0097]
[0098] Since m is also a d-dimensional vector, therefore m j This represents the value of the j-th feature in m;
[0099] Let eigenvector evaluation module s f Reconstruct the latent feature vector z The corresponding objective function The expression is:
[0100]
[0101] Where x is the original dataset;
[0102] Encoder network e and feature vector evaluation module s f and mask vector evaluation module s m The following loss functions can be used Conduct joint training:
[0103]
[0104] Wherein, γ is used to control and The proportion between them.
[0105] In this method, the classifier g is connected to the encoder network f. While keeping the weights of the encoder network f unchanged, only the classifier g is trained to obtain the final classification model.
[0106] Loss function of classification model for:
[0107]
[0108] Among them, y n This represents the true labels in the test dataset. This represents the label predicted by classifier g.
[0109] Among them, accuracy, precision, recall, and F1-score are used as evaluation metrics to evaluate the detection performance of the classification model on the test dataset.
[0110] This experiment uses the PyTorch machine learning framework to train the detection model and implement the adversarial mask anomaly detection algorithm. All experiments were run on an NVIDIA GeForce RTX 3060 Laptop GPU.
[0111] Table 1 below compares the performance of different anomaly detection methods on the NSL-KDD public dataset, with the best experimental results shown in bold:
[0112]
[0113] VIME is a method for learning data representations using random masks. As shown in Table 1, under the condition that the training and test sets are identical, the anomaly detection method proposed in this invention achieves the best results across all evaluation metrics, effectively solving the problem of how to efficiently augment network anomaly detection data to improve model performance.
[0114] The preferred embodiments of the present invention have been described in detail above. It should be understood that those skilled in the art can make numerous modifications and variations based on the concept of the present invention without creative effort. Therefore, all technical solutions that can be obtained by those skilled in the art based on the concept of the present invention through logical analysis, reasoning, or limited experimentation on the basis of existing technology should be within the scope of protection defined by the claims.
Claims
1. A network traffic anomaly detection system based on adversarial masking, characterized in that, The system includes an upstream pre-model and a downstream classification and detection model; The pre-model includes an adversarial mask generation module, an encoder network, a feature vector evaluation module, and a mask vector evaluation module; the encoder network is trained in the upstream pre-model. The classification and detection model includes the trained encoder network and a classifier; the classifier is trained only while keeping the weights of the encoder network unchanged to obtain the final classification model; the classification model performs classification prediction on the test dataset. The adversarial mask generation module receives an original dataset consisting of original samples and generates adversarial samples of the manifold of the original samples that are far removed from the input. The encoder network receives the adversarial samples generated by the adversarial mask generation module, and extracts the hidden features in the adversarial samples from the manually set proxy task by leveraging the nonlinear feature extraction capability of the deep neural network. The feature vector evaluation module is connected to the encoder network, which restores the latent features into a feature form with the same dimension as the original sample, and uses the reconstruction error to measure the distance between the adversarial sample and the original sample. The mask vector evaluation module is also connected to the encoder network to predict the location of latent features; The adversarial mask generation module includes an autoencoder, which in turn includes an encoder and a decoder. The encoder obtains latent features from the input original sample, and the decoder restores the latent features to a reconstructed sample with the same dimension as the original sample. The reconstructed sample is the adversarial sample.
2. The network traffic anomaly detection system based on adversarial masking as described in claim 1, characterized in that, The feature vector evaluation module and the mask vector evaluation module are built in parallel.
3. A method for detecting network traffic anomalies based on adversarial masking, using the network traffic anomaly detection system based on adversarial masking as described in any one of claims 1-2, characterized in that, The method includes the following steps: Step 1: Preprocess the original dataset; the original dataset is network data including continuous and discrete features, composed of original samples; for the continuous features, transform them to the range of 0 to 1 using the min-max method; for the discrete features, convert them to numerical form using one-hot encoding; take 10% of the original dataset as the training dataset, and the remaining 90% as the test dataset; denote the preprocessed original dataset as... ,in ,in, Indicates the dimension size as The set of real numbers; Step 2: Construct an adversarial mask generation module, which includes an autoencoder; extract the original samples from the training dataset as the training set of the autoencoder, and use the reconstruction error as the loss function of the autoencoder; The automatic encoder is denoted as The training dataset is denoted as Then the corresponding loss function for: in, It is equivalent to a function expression. This indicates that when the input of the function expression is The output result at that time; In the middle, the 2 at the bottom right indicates finding the vector. The value of the second norm, where the 2 above represents the square of the second norm; After the autoencoder has been trained, the loss function is used as a criterion for judging whether a sample is abnormal. If the reconstruction error of the original sample is higher than a preset threshold, it is judged as an abnormal sample; otherwise, it is a normal sample. Step 3: Apply a pre-designed adversarial attack algorithm to generate a corresponding adversarial sample for each of the original samples in the training dataset; Step 4: Complete the training and construction of the encoder network, feature vector evaluation module, and mask vector evaluation module; Step 5: Connect the classifier to the pre-trained encoder network. Train only the classifier while keeping the weights of the encoder network unchanged to obtain the final classification model. The classification model then performs classification prediction on the test dataset.
4. The network traffic anomaly detection method based on adversarial masking as described in claim 3, characterized in that, In step 3, the adversarial attack algorithm is as follows: Assume the original dataset is ,in , representing The continuous feature composed of elements, and , indicating by The discrete feature composed of elements; let the perturbation range be... The number of iterations is The adversarial attack algorithm for the training dataset can be expressed as: Among them, The asterisk (*) indicates that the data features have been artificially manipulated. The above This represents the continuous features in the original dataset that have been artificially modified; The value below indicates the number of iterations in the current calculation; 0 indicates that the calculation was performed 0 times. In Representative calculation Second-rate; In Representative calculation Second-rate; Indicates the perturbation range for a single calculation. This range is within the interval [0,1]. Represents a mathematical symbolic function, that is, when , ;when , ;when ; Indicates the gradient. , This is a truncation function, its purpose is to truncate the modified data. Limited to the scope [ , Among them; belong Within the range, and gradually increasing; symbol The sign is determined based on whether the original sample is abnormal. If the input original sample is abnormal, the sign is a minus sign; otherwise, it is a plus sign. is the loss function for the training dataset.
5. The network traffic anomaly detection method based on adversarial masking as described in claim 4, characterized in that, The adversarial attack algorithm introduces random feature changes, that is, for The continuous features are randomly selected from them using a uniform distribution. The aforementioned continuous features are considered as modifiable items, and the remaining ones... The continuous features remain unchanged; The expression for the adversarial attack algorithm after incorporating the random feature modification is as follows: After generating the adversarial examples Next, the mask vector It can be represented as: in, In This refers to the portion of continuous features in the original dataset that has been artificially modified. This represents the XOR operation. This refers to the dataset composed of the adversarial samples after the random feature changes are introduced.
6. The network traffic anomaly detection method based on adversarial masking as described in claim 5, characterized in that, The adversarial samples were randomly shuffled. The encoder network was trained using the new training dataset. and the feature vector evaluation module and the mask vector evaluation module The weight parameters; the encoder network after training. The encoder network is denoted as [name of network]. ; The adversarial sample Through the encoder network The hidden feature vector is obtained after compression. The mask vector evaluation module Evaluate which feature of the input vector is modified, assuming that when the latent feature vector... As the mask vector evaluation module When the input is received, the mask vector evaluation module The output is represented as Then the mask vector loss function It can be expressed by the following formula: Among them, due to Too dimensional vector, therefore It means that in The Middle The value of each feature; Let the feature vector evaluation module be... The hidden feature vector Restructuring The corresponding objective function The expression is: in, The original dataset; The encoder network and the feature vector evaluation module and the mask vector evaluation module The following loss functions can be used Conduct joint training: in, It is used to control and The proportion between them.
7. The network traffic anomaly detection method based on adversarial masking as described in claim 6, characterized in that, The classifier Connected to the encoder network Following this, while ensuring the encoder network Without changing the weights, only the classifier The model is trained to obtain the final classification model; The loss function of the classification model for: in, This represents the true labels in the test dataset. The classifier The predicted label.
8. The network traffic anomaly detection method based on adversarial masking as described in claim 7, characterized in that, Accuracy, precision, recall, and F1-score are used as evaluation metrics to assess the detection performance of the classification model on the test dataset.
Citation Information
Patent Citations
Deep learning model optimization method based on data defense
CN111881027A