A malicious traffic detection device and method for counteracting label noise
By dividing the data sets, filtering clean samples, performing data augmentation in the malicious traffic detection system, and using semi-supervised learning and contrast learning, the malicious traffic detection accuracy problem caused by the training set containing label noise is solved, and high accuracy and generalization performance under high noise conditions are achieved.
Patent Information
- Application Number
- CN202310148063.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-22
- Publication Date
- 2025-04-15
- Estimated Expiration
- 2043-02-22
AI Technical Summary
The existing malicious traffic detection system is difficult to accurately detect malicious traffic when the training set contains label noise, and the existing methods have limited effectiveness when processing noisy data.
Two networks with the same model structure are pre-trained by dividing the traffic dataset with label noise into two subsets, and clean samples are screened based on cross prediction and Jensen-Shannon divergence. The noise samples are treated as unlabeled samples, data augmentation is performed through the random forest feature importance algorithm, and the model is further improved and fine-tuned using semi-supervised learning and contrast learning.
Under high noise conditions, the accuracy and generalization performance of malicious traffic detection models are improved, effectively reducing the impact of noise labels on model training.
Smart Images

Figure CN116192500B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of malicious traffic detection, and provides a malicious traffic detection device and method for combating label noise. Background Art
[0002] Network traffic is the main carrier for information interaction and transmission in cyberspace. As an effective active defense technology in the field of malicious traffic detection, anomaly detection technology based on network traffic can identify network traffic patterns and promptly discover abnormal traffic patterns and attack behaviors in network traffic, which is of great significance for maintaining the security of cyberspace.
[0003] However, current malicious traffic detection systems are usually based on models trained by deep learning, and training models requires a large amount of labeled data. It is time-consuming and laborious to obtain high-quality labeled data. In order to reduce costs, many malicious traffic datasets use crowdsourcing, automated systems and other methods to label training data. These labeling methods often produce a large number of incorrect labels. In addition, factors such as insufficient information, expert errors and coding errors may also cause labels to be contaminated.
[0004] In order to reduce the impact of label noise on model training, researchers have proposed some methods.
[0005] In the paper "MentorNet: Learning Data-Driven Curriculum for Very Deep Neural Networks on Corrupted Labels", a label noise filtering algorithm based on smalllosstrick is proposed. It is based on the assumption that models often give priority to fitting clean samples, so that samples with smaller training losses are regarded as clean samples, and samples with larger training losses are regarded as noise samples. However, this method simply discards the filtered noise data and does not make full use of the training data.
[0006] The paper "Enhancing Robustness of On-Line Learning Models on Highly Noisy Data" proposes a noise data filter based on the idea of model voting. It uses multiple classifiers to predict the training data at the same time. Data with different prediction results are regarded as noise data, and the noise labels are corrected by majority voting. However, this method relies on a large number of clean data sets when training the initial classifier, which is contrary to the reality, and there is still data that cannot be corrected in this method.
[0007] The paper "UNICON: Combating Label Noise Through Uniform Selection and Contrastive Learning" proposed a classifier based on semi-supervised and contrastive learning ideas. First, the data was preliminarily divided based on the small loss trick, and the noise data was enhanced. Combined with the semi-supervised and contrastive learning ideas, the data distribution of the noise data was learned. This method has been successful in the field of CV, but it cannot be directly used in the field of traffic detection. Due to the difference between traffic data and image data, conventional data enhancement methods are not effective. Summary of the invention
[0008] In view of the above-mentioned prior art problems, the purpose of the present invention is to provide a malicious traffic detection device that resists label noise. The system can solve the problem that the trained model is difficult to accurately detect malicious traffic when the training set contains label noise. The traffic data set is learned from multiple angles such as supervised learning, semi-supervised learning and comparative learning to analyze the characteristics of malicious traffic samples to the greatest extent. The data set containing label noise is divided into two subsets, and two networks with the same model structure are pre-trained respectively; the subsets are cross-input into the model for prediction, and clean samples are preliminarily screened based on the prediction error; the noise samples are regarded as unlabeled samples, and the functional and non-functional features of the samples are calculated according to the random forest feature importance algorithm. Based on the assumption that the feature values of the same attack samples will be disturbed within a certain range, the traffic data is enhanced; unsupervised learning and comparative learning are used for the samples after data enhancement, and the pre-trained model is further improved and fine-tuned to realize the detection of malicious traffic under high noise conditions.
[0009] In order to achieve the above object, the present invention adopts the following technical solution:
[0010] The present invention provides a malicious traffic detection device for resisting label noise, comprising the following devices:
[0011] Model pre-training module: divide the traffic data set containing label noise into subset 1 and subset 2, and pre-train two models with the same network structure to obtain model 1 and model 2;
[0012] Sample selection module: The pre-trained model is used to cross-predict the two dataset subsets, and the prediction error is calculated based on the Jensen-Shannon divergence to preliminarily screen clean samples and noise samples;
[0013] Data enhancement module: The filtered noise samples are regarded as unlabeled samples, and the functional and non-functional features of the samples are obtained according to the random forest feature importance algorithm. Based on the principle that the feature values of the same type of attack samples will be disturbed within a certain range, the traffic samples are enhanced.
[0014] Semi-supervised and contrastive learning training module: Calculate the semi-supervised loss and contrastive learning loss of Model 1 and Model 2, so that the model can learn the data distribution of the noise traffic samples and is not affected by the noise label memory. Finally, fine-tune the model through the screened clean samples to obtain a malicious traffic detection model with good generalization performance.
[0015] In the above device, the specific implementation steps of the model pre-training module are as follows:
[0016] S1: By random sampling, the traffic data set containing label noise is divided into two non-intersecting subsets, namely, subset 1 and subset 2.
[0017] S2: Define the model structure so that the model has two outputs: a projection layer and a classification layer, where
[0018] The input traffic data passes through the hidden layer in the neural network and is output to the projection layer to obtain a fixed-dimensional feature representation. Based on the feature representation, the feature similarity between the positive sample pair and the negative sample pair is calculated to obtain the comparative learning error.
[0019] The input traffic data passes through the hidden layer of the neural network and is output to the classification layer of model 1 and model 2 at the same time. The average of the prediction results of the two models is taken as the prediction probability of each category. The supervised learning error is calculated based on the output probability value and the actual label of the clean sample. Before the model training starts, the supervised learning error is used to initialize the model parameters through Gaussian distribution;
[0020] S3: Based on the constructed model structure, Model 1 and Model 2 with the same structure are initialized. The divided subsets are input into the two models respectively. The training does not exceed 10 epochs, so that Model 1 and Model 2 can preliminarily learn the distribution of data.
[0021] Through the above steps, supervised learning errors are used to pre-train Model 1 and Model 2, and the models are fine-tuned after semi-supervised and contrastive learning training.
[0022] In the above device, the sample selection module is specifically implemented in the following steps:
[0023] S1: Through cross-prediction, model 1 trained on subset 1 is used to predict subset 2, and model 2 trained on subset 2 is used to predict subset 1. The predicted results are compared with the given labels to calculate the Jensen-Shannon loss, which is referred to as JS loss.
[0024] S2: Get the JS loss of all samples and calculate the loss cutoff value. The number of samples below the cutoff value is considered as clean samples.
[0025] S3: Use a unified selection mechanism to select samples, calculate the filtering ratio R = number of samples below the cutoff value / total number of samples, select NR / C samples from each category as clean samples, if the total number of samples in this category is less than NR / C, then select all samples in this category as clean samples, where N represents the total number of samples and C represents the total number of categories;
[0026] In the above device, the data enhancement module is specifically implemented in the following steps:
[0027] S1: Based on the random forest feature importance algorithm, the feature importance of each type of clean samples screened out is calculated. The union of the top five features of each type of sample feature importance is taken as the functional features, and the rest are non-functional features. The mean and variance of each feature are calculated;
[0028] S2: The filtered noise samples are regarded as unlabeled samples, and strong data enhancement and weak data enhancement are performed on the same noise samples at the same time, so that the two samples obtained after enhancement are mutually positive sample pairs, and the enhanced sample and other samples are mutually negative sample pairs;
[0029] The noise samples are strongly enhanced. The operation is as follows: keep the functional feature value unchanged, multiply the non-functional feature by a Gaussian distribution random value with a mean of 1 and a variance of 2 times the feature variance to obtain the value after strong data enhancement, and concatenate it with the functional feature to obtain a strongly enhanced sample;
[0030] The noise samples are weakly enhanced, and the operation is as follows: keep the functional feature value unchanged, multiply the non-functional feature by a Gaussian distribution random value with a mean of 1 and a variance equal to the feature variance to obtain the value after weak data enhancement, and concatenate it with the functional feature to obtain a weakly enhanced sample.
[0031] In the above device, the specific implementation steps of the semi-supervised and contrastive learning training module are as follows:
[0032] S1: Based on the idea of semi-supervised learning, strongly enhanced samples and weakly enhanced samples are input into Model 1 and Model 2 respectively at the same time, and the average of the results of the two models is taken as the final prediction result. For weakly enhanced data, the predicted result is used as the pseudo label of the weakly enhanced sample; for strongly enhanced data, Model 1 and Model 2 are used to predict the probability of each category at the same time, and the average of the results of the two models is taken as the predicted probability, and the cross entropy loss of the predicted probability and the pseudo label is used as the semi-supervised loss of Model 1 and Model 2;
[0033] S2: Based on the idea of contrastive learning, strong data enhancement and weak data enhancement are performed on the same noise sample at the same time. The two samples obtained after enhancement are positive sample pairs, and the similarity between positive samples is used as the numerator of contrastive learning loss; the enhanced sample and other samples are negative sample pairs, and the sum of all similarities is used as the denominator of contrastive learning loss. The specific formula is as follows, where sim represents the calculation of the cosine similarity between the two, and κ represents the temperature coefficient. The role of the temperature coefficient is to adjust the degree of attention to difficult samples. The larger the temperature coefficient, the smoother the logits curve, and the smaller the temperature coefficient, the steeper the logits curve. i and z j represents sample i and sample j, exp represents the exponential function with the natural constant e as the base, B represents the value of a batch size, l i,j represents the contrastive learning loss of two samples i and j that are mutually positive pairs, L c Represents the common contrastive learning loss of all samples in a batch:
[0034]
[0035]
[0036] S3: The semi-supervised loss and contrast loss obtained by S1 and S2 are used as the loss function of model 1 and model 2. The model back-propagates and updates the parameters to reduce the loss value as much as possible, so that the model can learn the distribution of unlabeled noise data as much as possible.
[0037] S4: Use the clean samples selected by the sample selection module as data for supervised learning, and further fine-tune the parameters of Model 1 and Model 2 to improve the prediction accuracy of the model.
[0038] The present invention also provides a malicious traffic detection method for resisting label noise, comprising the following steps:
[0039] S1: Divide the traffic data with label noise into two subsets, and pre-train the models with the same network structure to obtain Model 1 and Model 2;
[0040] S2: Predict the two subsets crosswise through the pre-trained model 1 and model 2, calculate the prediction error based on the JS loss, and preliminarily screen the clean samples;
[0041] S3: The filtered noise samples are regarded as unlabeled samples. The functional and non-functional features of the samples are obtained according to the random forest feature importance algorithm. Based on the principle that the feature values of the same type of attack samples will be disturbed within a certain range, data enhancement is performed on the traffic samples.
[0042] S4: Calculate the semi-supervised loss and contrastive learning loss of Model 1 and Model 2, so that the model can learn the data distribution of the noise traffic samples and is not affected by the noise label memory. Finally, fine-tune the model through the screened clean samples to obtain a malicious traffic detection model with good generalization performance.
[0043] In the above method, step 1 specifically includes the following steps:
[0044] S1.1: By random sampling, the traffic data set containing label noise is divided into two non-intersecting subsets, namely, subset 1 and subset 2.
[0045] S1.2: Define the model structure so that the model has two outputs: a projection layer and a classification layer, where
[0046] The input traffic data passes through the hidden layer in the neural network and is output to the projection layer to obtain a fixed-dimensional feature representation. Based on the feature representation, the feature similarity between the positive sample pair and the negative sample pair is calculated to obtain the comparative learning error.
[0047] The input traffic data passes through the hidden layer of the neural network and is output to the classification layer of model 1 and model 2 at the same time. The average of the prediction results of the two models is taken as the prediction probability of each category. The supervised learning error is calculated based on the output probability value and the actual label of the clean sample. Before the model training starts, the supervised learning error is used to initialize the model parameters through Gaussian distribution;
[0048] S1.3: Based on the constructed model structure, initialize Model 1 and Model 2 with the same structure. The divided subsets are input into the two models respectively. The training does not exceed 10 epochs, so that Model 1 and Model 2 can preliminarily learn the distribution of data.
[0049] In the above method, step 2 specifically includes the following steps:
[0050] S2.1: Through cross-prediction, use model 1 trained on subset 1 to predict subset 2, and use model 2 trained on subset 2 to predict subset 1. Calculate Jensen-Shannon loss by comparing the predicted results with the given labels. Jensen-Shannon loss is referred to as JS loss.
[0051] S2.2: Get the JS loss of all samples and calculate the loss cutoff value. The number of samples below the cutoff value is considered as clean samples.
[0052] S2.3: Select samples using a unified selection mechanism, calculate the filtering ratio R = number of samples below the cutoff value / total number of samples, select NR / C samples from each category as clean samples, if the total number of samples in this category is less than NR / C, then select all samples in this category as clean samples, where N represents the total number of samples and C represents the total number of categories;
[0053] In the above method, step 3 is specifically as follows:
[0054] S3.1: Based on the random forest feature importance algorithm, the feature importance of each type of clean sample is calculated, and the union of the top five features of each type of sample feature importance is taken as the functional feature, and the rest are non-functional features. The mean and variance of each feature are calculated;
[0055] S3.2: The filtered noise samples are regarded as unlabeled samples, and strong data enhancement and weak data enhancement are performed on the same noise samples at the same time, so that the two samples obtained after enhancement are positive sample pairs to each other, and the enhanced sample and other samples are negative sample pairs to each other;
[0056] The noise samples are strongly enhanced. The operation is as follows: keep the functional feature value unchanged, multiply the non-functional feature by a Gaussian distribution random value with a mean of 1 and a variance of 2 times the feature variance to obtain the value after strong data enhancement, and concatenate it with the functional feature to obtain a strongly enhanced sample;
[0057] The noise samples are weakly enhanced, and the operation is as follows: keep the functional feature value unchanged, multiply the non-functional feature by a Gaussian distribution random value with a mean of 1 and a variance equal to the feature variance to obtain the value after weak data enhancement, and concatenate it with the functional feature to obtain a weakly enhanced sample.
[0058] In the above method, the specific steps of step 4 are as follows:
[0059] S4.1: Based on the idea of semi-supervised learning, strongly enhanced samples and weakly enhanced samples are input into Model 1 and Model 2 respectively, and the average of the results of the two models is taken as the final prediction result. For weakly enhanced data, the predicted result is used as the pseudo-label of the weakly enhanced sample; for strongly enhanced data, Model 1 and Model 2 are used to predict the probability of each category at the same time, and the average of the results of the two models is taken as the predicted probability, and the cross entropy loss of the predicted probability and the pseudo-label is used as the semi-supervised loss of Model 1 and Model 2;
[0060] S4.2: Based on the idea of contrastive learning, strong data enhancement and weak data enhancement are performed on the same noise sample at the same time. The two samples obtained after enhancement are positive sample pairs, and the similarity between positive samples is used as the numerator of contrastive learning loss; the enhanced sample and other samples are negative sample pairs, and the sum of all similarities is used as the denominator of contrastive learning loss. The specific formula is as follows, where sim represents the calculation of the cosine similarity between the two, and κ represents the temperature coefficient. The role of the temperature coefficient is to adjust the degree of attention to difficult samples. The larger the temperature coefficient, the smoother the logits curve, and the smaller the temperature coefficient, the steeper the logits curve. i and z j represents sample i and sample j, exp represents the exponential function with the natural constant e as the base, B represents the value of a batch size, l i,j represents the contrastive learning loss of two samples i and j that are mutually positive pairs, L c Represents the common contrastive learning loss of all samples in a batch:
[0061]
[0062]
[0063] S4.3: The semi-supervised loss and contrast loss obtained by S1 and S2 are used as the loss function of model 1 and model 2. The model back-propagates and updates the parameters to reduce the loss value as much as possible, so that the model can learn the distribution of unlabeled noise data as much as possible.
[0064] S4.4: Use the clean samples selected by the sample selection module as data for supervised learning, and further fine-tune the parameters of Model 1 and Model 2 to improve the prediction accuracy of the model.
[0065] Compared with the prior art, the present invention has the following beneficial effects:
[0066] First, when pre-training a model, the same model and training data are often used, which will cause the model to have a certain memory of noise data. This invention divides the data set into two non-intersecting subsets by random sampling, and cross-trains the model to minimize the impact of the model's memory of noise data;
[0067] Second, the invention proposes a simple and effective unified selection mechanism to ensure the class balance between the selected clean samples. Through empirical analysis, it can be found that class balance helps to generate higher quality pseudo labels for samples;
[0068] 3. The invention further reduces the risk of label noise memory by using contrast loss to perform unsupervised learning, which in turn improves the performance of sample separation; BRIEF DESCRIPTION OF THE DRAWINGS
[0069] Figure 1 It is the overall architecture diagram of the present invention. DETAILED DESCRIPTION
[0070] The present invention will be further described below in conjunction with the accompanying drawings and specific implementation methods.
[0071] A malicious traffic detection device for combating label noise includes the following devices:
[0072] Model pre-training module: Divide the traffic dataset containing label noise into subset 1 and subset 2, and pre-train two models with the same network structure to obtain Model 1 and Model 2.
[0073] Sample selection module: The pre-trained model is used to cross-predict two dataset subsets, and the prediction error is calculated based on the Jensen-Shannon divergence to preliminarily screen clean samples and noise samples.
[0074] Data enhancement module: The filtered noise samples are regarded as unlabeled samples, and the functional and non-functional features of the samples are obtained according to the random forest feature importance algorithm. Based on the assumption that the feature values of the same type of attack samples will be perturbed within a certain range, data enhancement is performed on the traffic samples.
[0075] Semi-supervised and contrastive learning training module: Based on the idea of unsupervised learning, the two sample models after data enhancement should predict the same results. Based on the idea of contrastive learning, the two samples after data enhancement are positive sample pairs, and the distance between them should be as small as possible; all other samples are negative sample pairs, and the distance between them should be as large as possible. Thus, the semi-supervised loss and contrastive learning loss are obtained, so that the model can learn the data distribution of the noise traffic samples and is not affected by the memory of the noise labels. Finally, the model is fine-tuned by the screened clean samples to obtain a malicious traffic detection model with good generalization performance.
[0076] In the above technical solution, the specific implementation steps of the model pre-training module are as follows:
[0077] S1: By random sampling, the traffic data set containing label noise is divided into two non-intersecting subsets, namely, subset 1 and subset 2.
[0078] S2: Define the model structure so that the model has two outputs: a projection layer and a classification layer, where
[0079] The input traffic data passes through the hidden layer in the neural network and is output to the projection layer to obtain a fixed-dimensional feature representation. Based on the feature representation, the feature similarity between the positive sample pair and the negative sample pair is calculated to obtain the comparative learning error.
[0080] The input traffic data passes through the hidden layer of the neural network and is output to the classification layer of model 1 and model 2 at the same time. The average of the prediction results of the two models is taken as the prediction probability of each category. The supervised learning error is calculated based on the output probability value and the actual label of the clean sample. Before the model training starts, the model parameters are initialized through Gaussian distribution.
[0081] S3: Based on the constructed model structure, Model 1 and Model 2 with the same structure are initialized. The divided subsets are input into the two models respectively. The training does not exceed 10 epochs, so that Model 1 and Model 2 can preliminarily learn the distribution of data.
[0082] In the above technical solution, the specific implementation steps of the sample selection module are as follows:
[0083] S1: Through cross-prediction, model 1 trained on subset 1 is used to predict subset 2, and model 2 trained on subset 2 is used to predict subset 1. The predicted results are compared with the given labels to calculate the Jensen-Shannon loss, which is referred to as JS loss.
[0084] S2: Get the JS loss of all samples and calculate the loss cutoff value. The number of samples below the cutoff value is considered as clean samples.
[0085] S3: Use a unified selection mechanism to select samples, calculate the filtering ratio R = number of samples below the cutoff value / total number of samples, select NR / C samples from each category as clean samples, if the total number of samples in this category is less than NR / C, then all samples in this category are selected as clean samples, where N represents the total number of samples and C represents the total number of categories.
[0086] In the above technical solution, the specific implementation steps of the data enhancement module are as follows:
[0087] S1: Based on the random forest feature importance algorithm, the feature importance of each type of clean samples screened out is calculated. The union of the top five features of each type of sample feature importance is taken as the functional features, and the rest are non-functional features. The mean and variance of each feature are calculated;
[0088] S2: The filtered noise samples are regarded as unlabeled samples, and strong data enhancement and weak data enhancement are performed on the same noise samples at the same time, so that the two samples obtained after enhancement are mutually positive sample pairs, and the enhanced sample and other samples are mutually negative sample pairs;
[0089] The noise samples are strongly enhanced. The operation is as follows: keep the functional feature value unchanged, multiply the non-functional feature by a Gaussian distribution random value with a mean of 1 and a variance of 2 times the feature variance to obtain the value after strong data enhancement, and concatenate it with the functional feature to obtain a strongly enhanced sample;
[0090] The noise samples are weakly enhanced, and the operation is as follows: keep the functional feature value unchanged, multiply the non-functional feature by a Gaussian distribution random value with a mean of 1 and a variance equal to the feature variance to obtain the value after weak data enhancement, and concatenate it with the functional feature to obtain a weakly enhanced sample.
[0091] In the above technical solution, the specific implementation steps of the semi-supervised and contrastive learning training module are as follows:
[0092] S1: Based on the idea of semi-supervised learning, the strongly enhanced samples and weakly enhanced samples are input into Model 1 and Model 2 respectively, and the average of the two model results is taken as the final prediction result. For weakly enhanced data, the model prediction result is used as the pseudo label of the weakly enhanced sample; for strongly enhanced data, the probability of predicting each category is obtained through the model, and the cross entropy loss of the predicted probability and the pseudo label is used as the semi-supervised loss of Model 1 and Model 2;
[0093] S2: Based on the idea of contrastive learning, strong data enhancement and weak data enhancement are performed on the same noise sample at the same time. The two samples obtained after enhancement are regarded as positive sample pairs, and the similarity between the two is used as the numerator of contrastive learning loss; the enhanced sample and other samples are regarded as negative sample pairs, and the sum of all similarities is used as the denominator of contrastive learning loss;
[0094] S3: Use the clean samples selected by the sample selection module as data for supervised learning to fine-tune the model prediction.
[0095] The present invention also provides a malicious traffic detection method against label noise, which is divided into four parts: model pre-training module, sample selection module, data enhancement module and semi-supervised and contrastive learning module. The method mainly includes the following steps:
[0096] S1: Divide the traffic data with label noise into two subsets and pre-train the models with the same network structure respectively;
[0097] S2: Use the pre-trained model to cross-predict the two subsets, calculate the prediction error based on the JS loss, and preliminarily screen clean samples;
[0098] S3: The filtered noise samples are regarded as unlabeled samples. The functional and non-functional features of the samples are obtained according to the random forest feature importance algorithm. Based on the assumption that the feature values of the same type of attack samples will be disturbed within a certain range, data enhancement is performed on the traffic samples.
[0099] S4: Based on the idea of semi-supervised learning, the model predicts the enhanced data sample results to be consistent; based on the idea of contrastive learning, the model predicts the enhanced sample results to be closer, and other negative samples to the results to be more deviated; finally, the model is fine-tuned through the screened clean samples.
Claims
1. A malicious traffic detection device against label noise, characterized in that: Includes the following devices: Model pre-training module: divide the traffic data set containing label noise into subset 1 and subset 2, and pre-train two models with the same network structure to obtain model 1 and model 2; Sample selection module: The pre-trained model is used to cross-predict the two dataset subsets, and the prediction error is calculated based on the Jensen-Shannon divergence to preliminarily screen clean samples and noise samples; Data enhancement module: The filtered noise samples are regarded as unlabeled samples, and the functional and non-functional features of the samples are obtained according to the random forest feature importance algorithm. Based on the principle that the feature values of the same type of attack samples will be disturbed within a certain range, the traffic samples are enhanced. Semi-supervised and contrastive learning training module: Calculate the semi-supervised loss and contrastive learning loss of Model 1 and Model 2, so that the model can learn the data distribution of the noise traffic samples and is not affected by the noise label memory. Finally, fine-tune the model through the screened clean samples to obtain a malicious traffic detection model with good generalization performance. The specific implementation steps of the model pre-training module are as follows: S1: By random sampling, the traffic data set containing label noise is divided into two subsets without intersection, and subset 1 and subset 2 are obtained; S2: Define the model structure so that the model has two outputs: a projection layer and a classification layer, where The input traffic data passes through the hidden layer in the neural network and is output to the projection layer to obtain a fixed-dimensional feature representation. Based on the feature representation, the feature similarity between the positive sample pair and the negative sample pair is calculated to obtain the comparative learning error. The input traffic data passes through the hidden layer of the neural network and is output to the classification layer of model 1 and model 2 at the same time. The average of the prediction results of the two models is taken as the prediction probability of each category. The supervised learning error is calculated based on the output probability value and the actual label of the clean sample. Before the model training starts, the supervised learning error is used to initialize the model parameters through Gaussian distribution; S3: Based on the constructed model structure, Model 1 and Model 2 with the same structure are initialized. The divided subsets are input into the two models respectively. The training does not exceed 10 epochs, so that Model 1 and Model 2 can preliminarily learn the distribution of data.
2. According to claim 1, a malicious traffic detection device against label noise is characterized in that: The specific implementation steps of the sample selection module are as follows: S1: Through cross-prediction, model 1 trained on subset 1 is used to predict subset 2, and model 2 trained on subset 2 is used to predict subset 1. The predicted results are compared with the given labels to calculate the Jensen-Shannon loss, which is referred to as JS loss. S2: Get the JS loss of all samples and calculate the loss cutoff value. The number of samples below the cutoff value is considered as clean samples. S3: Use a unified selection mechanism to select samples, calculate the filtering ratio R = number of samples below the cutoff value / total number of samples, select NR / C samples from each category as clean samples, if the total number of samples in this category is less than NR / C, then all samples in this category are selected as clean samples, where N represents the total number of samples and C represents the total number of categories.
3. The malicious traffic detection device against label noise according to claim 1, characterized in that: The specific implementation steps of the data enhancement module are as follows: S1: Based on the random forest feature importance algorithm, the feature importance of each type of clean samples screened out is calculated. The union of the top five features of each type of sample feature importance is taken as the functional features, and the rest are non-functional features. The mean and variance of each feature are calculated; S2: The filtered noise samples are regarded as unlabeled samples, and strong data enhancement and weak data enhancement are performed on the same noise samples at the same time, so that the two samples obtained after enhancement are mutually positive sample pairs, and the enhanced sample and other samples are mutually negative sample pairs; The noise samples are strongly enhanced. The operation is as follows: keep the functional feature value unchanged, multiply the non-functional feature by a Gaussian distribution random value with a mean of 1 and a variance of 2 times the feature variance to obtain the value after strong data enhancement, and concatenate it with the functional feature to obtain a strongly enhanced sample; The noise samples are weakly enhanced, and the operation is as follows: keep the functional feature value unchanged, multiply the non-functional feature by a Gaussian distribution random value with a mean of 1 and a variance equal to the feature variance to obtain the value after weak data enhancement, and concatenate it with the functional feature to obtain a weakly enhanced sample.
4. The malicious traffic detection device against label noise according to claim 1, characterized in that: The specific implementation steps of the semi-supervised and contrastive learning training module are as follows: S1: Based on the idea of semi-supervised learning, strongly enhanced samples and weakly enhanced samples are input into Model 1 and Model 2 respectively at the same time, and the average of the results of the two models is taken as the final prediction result. For weakly enhanced data, the predicted result is used as the pseudo label of the weakly enhanced sample; for strongly enhanced data, Model 1 and Model 2 are used to predict the probability of each category at the same time, and the average of the results of the two models is taken as the predicted probability, and the cross entropy loss of the predicted probability and the pseudo label is used as the semi-supervised loss of Model 1 and Model 2; S2: Based on the idea of contrastive learning, strong data enhancement and weak data enhancement are performed on the same noise sample at the same time. The two samples obtained after enhancement are positive sample pairs, and the similarity between positive samples is used as the numerator of contrastive learning loss; the enhanced sample and other samples are negative sample pairs, and the sum of all similarities is used as the denominator of contrastive learning loss. The specific formula is as follows: Where sim means calculating the cosine similarity between the two. Represents the temperature coefficient. The function of the temperature coefficient is to adjust the degree of attention to difficult samples. The larger the temperature coefficient, the smoother the logits curve, and the smaller the temperature coefficient, the steeper the logits curve. and represents sample i and sample j, exp represents the exponential function with the natural constant e as the base, and B represents the value of a batch size. represents the contrastive learning loss of two samples i and j that are mutually positive pairs, Represents the common contrastive learning loss of all samples in a batch; S3: The semi-supervised loss and contrast loss obtained by S1 and S2 are used as the loss function of model 1 and model 2. The model back-propagates and updates the parameters to reduce the loss value as much as possible, so that the model can learn the distribution of unlabeled noise data as much as possible. S4: Use the clean samples selected by the sample selection module as data for supervised learning, and further fine-tune the parameters of Model 1 and Model 2 to improve the prediction accuracy of the model.
5. A malicious traffic detection method against label noise, characterized in that: The following steps are involved: S1: Divide the traffic data with label noise into two subsets, and pre-train the models with the same network structure to obtain Model 1 and Model 2; S2: Predict the two subsets crosswise through the pre-trained model 1 and model 2, calculate the prediction error based on the JS loss, and preliminarily screen the clean samples; S3: The filtered noise samples are regarded as unlabeled samples. The functional and non-functional features of the samples are obtained according to the random forest feature importance algorithm. Based on the principle that the feature values of the same type of attack samples will be disturbed within a certain range, data enhancement is performed on the traffic samples. S4: Calculate the semi-supervised loss and contrastive learning loss of Model 1 and Model 2, so that the model can learn the data distribution of the noise traffic samples and is not affected by the memory of the noise labels. Finally, fine-tune the model through the screened clean samples to obtain a malicious traffic detection model with good generalization performance. Step 1 specifically includes the following steps: S1.1: By random sampling, the traffic data set containing label noise is divided into two non-intersecting subsets, namely, subset 1 and subset 2. S1.2: Define the model structure so that the model has two outputs: a projection layer and a classification layer, where The input traffic data passes through the hidden layer in the neural network and is output to the projection layer to obtain a fixed-dimensional feature representation. Based on the feature representation, the feature similarity between the positive sample pair and the negative sample pair is calculated to obtain the comparative learning error. The input traffic data passes through the hidden layer of the neural network and is output to the classification layer of model 1 and model 2 at the same time. The average of the prediction results of the two models is taken as the prediction probability of each category. The supervised learning error is calculated based on the output probability value and the actual label of the clean sample. Before the model training starts, the supervised learning error is used to initialize the model parameters through Gaussian distribution; S1.3: Based on the constructed model structure, initialize Model 1 and Model 2 with the same structure. The divided subsets are input into the two models respectively. The training does not exceed 10 epochs, so that Model 1 and Model 2 can preliminarily learn the distribution of data.
6. A malicious traffic detection method against label noise according to claim 5, characterized in that: Step 2 specifically includes the following steps: S2.1: Through cross-prediction, use model 1 trained on subset 1 to predict subset 2, and use model 2 trained on subset 2 to predict subset 1. Calculate Jensen-Shannon loss by comparing the predicted results with the given labels. Jensen-Shannon loss is referred to as JS loss. S2.2: Get the JS loss of all samples and calculate the loss cutoff value. The number of samples below the cutoff value is considered as clean samples. S2.3: Use a unified selection mechanism to select samples, calculate the filtering ratio R = number of samples below the cutoff value / total number of samples, select NR / C samples from each category as clean samples, if the total number of samples in this category is less than NR / C, then select all samples in this category as clean samples, where N represents the total number of samples and C represents the total number of categories.
7. The method for detecting malicious traffic against label noise according to claim 5, characterized in that: Step 3 is as follows: S3.1: Based on the random forest feature importance algorithm, the feature importance of each type of clean sample is calculated, and the union of the top five features of each type of sample feature importance is taken as the functional feature, and the rest are non-functional features. The mean and variance of each feature are calculated; S3.2: The filtered noise samples are regarded as unlabeled samples, and strong data enhancement and weak data enhancement are performed on the same noise samples at the same time, so that the two samples obtained after enhancement are positive sample pairs to each other, and the enhanced sample and other samples are negative sample pairs to each other; The noise samples are strongly enhanced. The operation is as follows: keep the functional feature value unchanged, multiply the non-functional feature by a Gaussian distribution random value with a mean of 1 and a variance of 2 times the feature variance to obtain the value after strong data enhancement, and concatenate it with the functional feature to obtain a strongly enhanced sample; The noise samples are weakly enhanced, and the operation is as follows: keep the functional feature value unchanged, multiply the non-functional feature by a Gaussian distribution random value with a mean of 1 and a variance equal to the feature variance to obtain the value after weak data enhancement, and concatenate it with the functional feature to obtain a weakly enhanced sample.
8. The method for detecting malicious traffic against label noise according to claim 5, characterized in that: Step 4 The specific steps are as follows: S4.1: Based on the idea of semi-supervised learning, strongly enhanced samples and weakly enhanced samples are input into Model 1 and Model 2 respectively, and the average of the results of the two models is taken as the final prediction result. For weakly enhanced data, the predicted result is used as the pseudo-label of the weakly enhanced sample; for strongly enhanced data, Model 1 and Model 2 are used to predict the probability of each category at the same time, and the average of the results of the two models is taken as the predicted probability, and the cross entropy loss of the predicted probability and the pseudo-label is used as the semi-supervised loss of Model 1 and Model 2; S4.2: Based on the idea of contrastive learning, strong data enhancement and weak data enhancement are performed on the same noise sample at the same time. The two samples obtained after enhancement are positive sample pairs, and the similarity between positive samples is used as the numerator of contrastive learning loss; the enhanced sample and other samples are negative sample pairs, and the sum of all similarities is used as the denominator of contrastive learning loss. The specific formula is as follows: Where sim means calculating the cosine similarity between the two. Represents the temperature coefficient. The function of the temperature coefficient is to adjust the degree of attention to difficult samples. The larger the temperature coefficient, the smoother the logits curve. The smaller the temperature coefficient, the steeper the logits curve. and represents sample i and sample j, exp represents the exponential function with the natural constant e as the base, and B represents the value of a batch size. represents the contrastive learning loss of two samples i and j that are mutually positive pairs, Represents the common contrastive learning loss of all samples in a batch; S4.3: The semi-supervised loss and contrast loss obtained by S1 and S2 are used as the loss function of model 1 and model 2. The model back-propagates and updates the parameters to reduce the loss value as much as possible, so that the model can learn the distribution of unlabeled noise data as much as possible. S4.4: Use the clean samples selected by the sample selection module as data for supervised learning, and further fine-tune the parameters of Model 1 and Model 2 to improve the prediction accuracy of the model.