An internet of things intrusion detection method based on multi-scale dilated attention and federated learning

By introducing a federated learning method with multi-scale dilated attention and mutual information aggregation mechanism into IoT intrusion detection, high-quality soft tags are generated, which solves the problems of poor soft tag quality and poor adaptability to non-independent and identically distributed scenarios, improves detection performance and reduces communication overhead.

CN122394933APending Publication Date: 2026-07-14ZHENGZHOU UNIVERSITY OF LIGHT INDUSTRY

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
ZHENGZHOU UNIVERSITY OF LIGHT INDUSTRY
Filing Date
2026-05-09
Publication Date
2026-07-14

Smart Images

  • Figure CN122394933A_ABST
    Figure CN122394933A_ABST
Patent Text Reader

Abstract

The application provides an Internet of Things intrusion detection method based on multi-scale expansion attention and federated learning, each client trains a multi-scale expansion attention and convolutional neural network classifier-discriminator model based on a private labeled data set and an open unlabeled data set, and obtains filtered soft labels by using the trained classifier-discriminator model; a center server receives the filtered soft labels uploaded by the clients, calculates the dynamic weight of each client by using a mutual information aggregation mechanism, and generates global soft labels by weighting and fusing the filtered soft labels by using the dynamic weight; the center server distributes the global soft labels to all the clients, each client takes the global soft labels as teacher labels, takes a local classifier model as a student model, and performs knowledge distillation training by using an open unlabeled data set to obtain a local classifier model after knowledge distillation. The application improves the detection robustness and overall accuracy of attacks, and reduces the calculation overhead.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the technical field of IoT intrusion detection, and more particularly to an IoT intrusion detection method based on federated learning. Background Technology

[0002] Due to the limitations of machine learning algorithms in intrusion detection, researchers have attempted to introduce deep learning algorithms for better performance. For example, an intrusion detection system based on 1D convolutional neural networks (1D CNN) extracts spatial hierarchical features from network traffic and then uses fully connected layers for binary anomaly detection and multi-class attack classification. A hybrid model combining parallel convolutional neural networks and long short-term memory networks (LSTM) (ASPCNNLSTM) extracts spatial features in parallel by converting network traffic into grayscale spectral images, uses LSTM to capture temporal dependencies, and combines a hybrid AOA-SCA algorithm to optimize feature selection and GAN to balance the dataset. A hybrid CNN-GRU deep learning architecture utilizes GRU layers to capture long temporal dependencies and handles class imbalance through SMOTE, achieving higher computational efficiency than traditional LSTM and excellent generalization performance. Deep learning-based intrusion detection methods have excellent detection performance, but they rely on a central entity to process data collected by various devices and usually need to share raw data with third parties. This data often contains users' private information, which has obvious limitations: First, centralized deep learning strategies need to integrate data, and training with shared data is prone to privacy leaks; second, analyzing network packets, system parameters and other data requires a large amount of computation and resources.

[0003] To address the privacy leaks and data silos inherent in centralized deep learning, federated learning technology has been widely applied in IoT intrusion detection, becoming a core technology for privacy-preserving intrusion detection. Federated learning employs a distributed training model, distributing training tasks to various IoT clients. Clients train models using local data, without uploading raw data; they only upload the trained model parameters to a central server. The server then uses an aggregation algorithm to merge the model parameters from each client into a global model and distribute it, achieving the privacy goal of data being usable but invisible. Compared to centralized intrusion detection methods, federated learning-based intrusion detection methods do not share data, offering strong privacy protection. However, limitations remain: there is a risk of reconstructing the original data using parameters; detection performance is slightly lower than centralized intrusion detection; and federated learning models typically have a large parameter size and high communication overhead, hindering practical deployment.

[0004] To address the high communication overhead of traditional federated learning, the industry has further integrated knowledge distillation technology with federated learning, proposing an IoT intrusion detection scheme based on federated distillation. The core of this scheme is to use soft tags (logits) output by the client model instead of model parameters for transmission. The server aggregates the soft tags from each client to generate a global soft tag, which is then distributed to the clients for local training, thus reducing communication overhead. While the fusion of traditional distillation technology and federated learning has achieved some success in reducing communication costs, it still faces significant performance limitations in non-independent, identically distributed data environments. Traditional methods have weak client-side feature extraction capabilities, only able to identify common local knowledge (such as common attack / traffic features). As a result, the generated soft labels contain a large number of low-quality labels, leading to a high similarity between global logits and local private label information. This makes it difficult to provide new knowledge, resulting in limited prediction accuracy of the final learned classification model. The local data distribution of each client exhibits a highly non-independent and identically distributed (Non-IID) property, causing significant differences between the uploaded prediction results. Traditional aggregation mechanisms (such as the FedAvgM aggregation algorithm) often fail to effectively integrate these distribution differences, failing to fully retain the specific knowledge learned by the client's local model. The poor adaptability of highly non-independent and identically distributed scenarios can easily lead to bias or distortion in the aggregation results, and even cause the global model performance to be worse than that of centralized training, further reducing the final prediction accuracy. This problem is more pronounced in tasks with highly sensitive data distribution, such as intrusion detection. Summary of the Invention

[0005] To address the technical problems of poor quality of soft tags generated by existing methods and poor adaptability to highly non-independent and identically distributed (Non-IID) scenarios, this invention proposes an IoT intrusion detection method based on multi-scale dilated attention and federated learning. This method alleviates the privacy risks and overhead issues of parameter transmission in traditional federated learning IoT intrusion detection while improving the robustness and overall accuracy of attack detection.

[0006] To achieve the above objectives, the technical solution of the present invention is implemented as follows:

[0007] An IoT intrusion detection method based on multi-scale dilated attention and federated learning, comprising the following steps:

[0008] S1: Acquire IoT traffic datasets and perform data partitioning and preprocessing to obtain a private labeled dataset for each client, an open unlabeled dataset shared by all clients, and a test dataset;

[0009] S2: Each client builds a classifier-discriminator model based on multi-scale dilated attention and convolutional neural networks;

[0010] S3: Each client trains the classifier-discriminator model based on its own private labeled dataset and the open unlabeled dataset shared by all clients, and uses the trained classifier-discriminator model to obtain filtered soft labels and upload them to the central server.

[0011] S4: The central server receives the filtered soft tags uploaded by the client, calculates the dynamic weight of each client using the mutual information aggregation mechanism, and uses the dynamic weight to perform weighted fusion of the filtered soft tags to generate global soft tags.

[0012] S5: The central server distributes global soft labels to all clients. Each client uses the global soft labels as teacher labels and the local classifier model as student models. It uses the open unlabeled dataset to perform knowledge distillation training to obtain the local classifier model after knowledge distillation.

[0013] S6: Repeat steps S3 to S5 for multiple rounds of iterative training until the accuracy tends to stabilize or reaches the preset maximum number of rounds. After testing the trained local classifier model with the test dataset, apply it to IoT intrusion detection.

[0014] Furthermore, acquire IoT traffic datasets and perform data segmentation and preprocessing, including:

[0015] Data partitioning: Select traffic data from K IoT devices in the original IoT traffic dataset. Split the traffic data of each IoT device into L single-category subsets according to traffic category. Select B traffic data records in each single-category subset to construct a simplified subset of each single category. Integrate all simplified subsets of each single category to obtain a simplified dataset of all categories. Divide the simplified datasets of all categories into privately labeled datasets, open unlabeled datasets, and test datasets according to a fixed ratio.

[0016] Preprocessing: Min-max normalization is used to scale the flow feature values ​​to the [0,1] interval; the flow features are split into two-dimensional feature matrices according to time windows.

[0017] Furthermore, the classifier-discriminator models all adopt a CNN architecture based on multi-scale dilated attention, and the number of neurons in the output layer of the classifier and discriminator is different;

[0018] The improved CNN architecture based on multi-scale dilated attention includes, in sequence, a first convolutional layer, a second convolutional layer, a third convolutional layer, a fourth convolutional layer, a fifth convolutional layer, a multi-scale dilated attention module, a sixth convolutional layer, a seventh convolutional layer, an eighth convolutional layer, a dropout layer, a flattening layer, a first fully connected layer, and a second fully connected layer, with the second fully connected layer serving as the output layer. The classifier output layer has L neurons, corresponding to L traffic categories, and the discriminator output layer has 2 neurons, corresponding to high / low confidence samples.

[0019] Furthermore, the processing steps of the multi-scale dilatation attention module include:

[0020] For the input features of the multi-scale dilated attention module, queries are obtained for each attention head h through linear projection and attention head partitioning. ,key Sum Assign different expansion rates to each head ;

[0021] Querying each head after partitioning ,key Sum Based on the assigned expansion rate and the predefined sliding window size Perform sliding window dilation attention calculations to obtain the self-attention output for each head. ;

[0022] Output the attention of each head The channel dimensions are concatenated to obtain concatenated features. The concatenated multi-scale features are then input into a linear layer to obtain the output of the multi-scale dilated attention module.

[0023] Furthermore, step S3 specifically includes:

[0024] S31: Each client uses a private labeled dataset to perform local supervised training on the classifier model, and uses the trained classifier model to perform forward propagation on the open unlabeled dataset to obtain the initial soft label and confidence of each open sample;

[0025] S32: Each client constructs a discriminator training set based on the confidence of each open sample obtained in step S31, and uses the discriminator training set to perform local supervised training on the discriminator model, so that the discriminator has the ability to distinguish between high / low confidence samples.

[0026] S33: Each client uses the trained discriminator model to filter the initial soft tags obtained in step S31, and obtains the filtered soft tags.

[0027] Furthermore, each client constructs a discriminator training set based on the confidence score of each open sample obtained in step S31, including:

[0028] Initialize empty set ;

[0029] Screening for open samples with low confidence: If , If the confidence threshold is used, then the sample Add the corresponding one-hot tag to the collection. ,

[0030] Adding high-confidence private samples: adding privately labeled datasets All samples and their corresponding one-hot labels are added to the set. The final discriminator training set is obtained. .

[0031] Furthermore, each client uses the trained discriminator model to filter the initial soft labels obtained in step S31, including:

[0032] The trained discriminator model is used to perform forward propagation on the open unlabeled dataset to obtain the probability that the open sample predicted by the discriminator model belongs to a high / low confidence sample. The confidence level of the sample is determined based on the probability of the open sample belonging to a high / low confidence sample. The initial soft labels are filtered according to the confidence level of the sample. The original soft labels of high confidence samples are retained as the filtered soft labels. The soft labels of low-confidence samples are set to uniform distribution vectors.

[0033] Furthermore, a mutual information aggregation mechanism is used to calculate the dynamic weight of each client, including:

[0034] Calculate the average distribution of soft tags for a single client: Take the average of all open sample soft tags for the i-th client to obtain the average distribution of soft tags for that client. ;

[0035] Calculate the preliminary global average distribution: Take the average of the average distributions across all clients to obtain the preliminary global soft tag distribution. ;

[0036] Calculate mutual information values: Calculate the mutual information between the average distribution of each client and the global preliminary soft tag distribution.

[0037] ;

[0038] in, For entropy, This indicates that the k-th client is in category The average predicted probability on For joint entropy;

[0039] Calculate dynamic weights: Normalize the mutual information values ​​to obtain the dynamic weights for each client. .

[0040] Furthermore, dynamic weights are used to weight and fuse the filtered soft tags to generate global soft tags, including:

[0041] ;

[0042] ;

[0043] in, It is the softmax function at distillation temperature T.

[0044] Furthermore, when training the classifier model locally using a privately labeled dataset, the probability of a sample belonging to multiple traffic categories is used as the output, and cross-entropy loss is employed to update the model weights using gradient descent.

[0045] When the discriminator model is trained locally using the discriminator training set, the probability that a sample belongs to a high / low confidence sample is used as the output. Binary cross-entropy loss is used, and the model weights are updated by gradient descent.

[0046] The beneficial effects of this invention are as follows:

[0047] This invention designs an improved CNN model based on multi-scale dilated attention. By extracting multi-scale spatiotemporal features of traffic flow, it enhances feature representation and improves generalization under semi-supervised management, while reducing computational overhead. A multi-scale dilated attention module is embedded into the original CNN model, capturing short-term or long-term timescales of IoT traffic data through parallel convolutions with different dilation rates. This overcomes the limitations of the original CNN's single-scale receptive field, alleviates the inability to effectively capture cross-scale dependencies, and better adapts to the complexity and heterogeneity of IoT data. Furthermore, this model is used as both a classifier and discriminator network, fully utilizing unlabeled data to generate high-quality soft labels that have learned new knowledge, further improving intrusion detection accuracy.

[0048] This invention designs a semi-supervised federated learning knowledge distillation framework based on mutual information aggregation. Building upon high-quality soft labels provided by the client, dynamic weights are calculated to adaptively weight client contributions, thereby generating higher-quality global soft labels, improving aggregation accuracy, avoiding the negative impact of data heterogeneity on the global model, and ensuring compatibility with soft label transmission, further reducing communication overhead. Combined with knowledge distillation, unlabeled data is fully utilized to achieve semi-supervised learning, improve model generalization, and verify superior detection performance under privacy protection. Attached Figure Description

[0049] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0050] Figure 1 This invention presents an overall framework for IoT intrusion detection based on multi-scale dilated attention and federated learning.

[0051] Figure 2 This invention relates to an improved CNN architecture based on Multi-Scale Dilated Attention (MSDA).

[0052] Figure 3 This is a structural diagram of the multiscale dilated attention mechanism (MSDA) of the present invention.

[0053] Figure 4 This invention provides a semi-supervised federated learning framework based on knowledge distillation. Detailed Implementation

[0054] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0055] In real-world IoT network environments, malicious traffic and attacks frequently occur, posing challenges to intrusion detection, including privacy and security, detection accuracy, and communication overhead. Therefore, this invention proposes an IoT intrusion detection method based on multi-scale dilated attention and federated learning. First, the original training data for each client is divided into a private dataset with hard labels for local supervised training, and an unlabeled open dataset for soft label generation, knowledge distillation, and a test dataset for evaluating the global model's performance. Each client uses its private dataset to locally train an improved CNN model embedding multi-scale dilated attention, thereby enhancing its perception of different scale features of IoT traffic data. Simultaneously, the discriminator uses a known or unknown sample differentiation mechanism to further filter unknown samples in the open dataset, improving the quality of soft labels. Clients make predictions on the open dataset, the classifier generates initial soft labels, and after filtering by the discriminator, high-quality logits are obtained. Subsequently, all clients upload their soft labels to a central server. The server employs a mutual information aggregation strategy, calculating mutual information weights based on the correlation between each client's soft label distribution and the global average distribution, automatically measuring and weighting client contributions to generate global soft labels, which are then broadcast to all clients. Finally, multiple rounds of knowledge distillation training are performed: both the client and server update their respective models using the open dataset and global soft labels. The intrusion detection performance and communication overhead of the global model are evaluated on the test dataset. The overall architecture is as follows: Figure 1 As shown.

[0056] An IoT intrusion detection method based on multi-scale dilated attention and federated learning, such as Figure 1 As shown, the steps are as follows:

[0057] S1: Acquire IoT traffic datasets and perform data partitioning and preprocessing to obtain a private labeled dataset for each client, an open unlabeled dataset shared by all clients, and a test dataset.

[0058] Specifically, this involves acquiring IoT traffic datasets and performing data segmentation and preprocessing, including:

[0059] Data partitioning: Select traffic data from K IoT devices in the original IoT traffic dataset. Split the traffic data of each IoT device into L single-category subsets according to traffic category. Select B traffic data records in each single-category subset to construct a simplified subset of the single category. Integrate all simplified subsets of the single category to obtain a simplified dataset of all categories. Divide the simplified datasets of all categories into privately labeled datasets, open unlabeled datasets, and test datasets according to a fixed ratio.

[0060] Preprocessing: min-max normalization is used to scale the flow feature values ​​to the [0,1] interval to eliminate the difference in feature dimensions; the flow features are split into two-dimensional feature matrices according to the time window to adapt to the input channel requirements of the improved CNN model.

[0061] In this embodiment of the application, it is assumed that there are K clients in the environment, each client There are two datasets, one of which is a privately labeled dataset. Open, unlabeled dataset shared with all clients ; This indicates that the k-th client uses the i-th sample from the privately labeled dataset. This is the traffic label corresponding to this sample. Let j represent the j-th open sample in the open unlabeled dataset. , This refers to the number of samples. Furthermore, each customer has a classifier model constructed using a CNN architecture improved based on Multi-Scale Dilated Attention (MSDA). and discriminator model .

[0062] S2: Each client constructs a classifier model based on multi-scale dilated attention and a convolutional neural network, as well as a discriminator model based on the same two principles. To better capture multi-scale spatiotemporal dependencies in network traffic data for IoT intrusion detection tasks, this invention introduces a multi-scale dilated attention (MSDA) mechanism into the client's local model. This mechanism uses different dilation rates in different attention heads to sparsely sample keys and values ​​within a sliding window, thereby simultaneously extracting local fine-grained anomaly patterns and global long-distance correlation patterns, while significantly reducing computational complexity.

[0063] Specifically, in this method, the classifier and discriminator are based on the same CNN architecture improved by multi-scale dilated attention (MSDA), such as... Figure 2 As shown, only the number of neurons in the output layer is different; the specific network structure is as follows:

[0064] The system consists of, in sequence, a first convolutional layer, a second convolutional layer, a third convolutional layer, a fourth convolutional layer, a fifth convolutional layer, a multi-scale dilated attention module, a sixth convolutional layer, a seventh convolutional layer, an eighth convolutional layer, a dropout layer, a flatten layer, a first fully connected layer, and a second fully connected layer (output layer). The classifier output layer has L neurons, corresponding to L traffic categories, and the discriminator output layer has 2 neurons, corresponding to high / low confidence samples.

[0065] In this embodiment, the classifier network and discriminator network have the same structure except for the output layer. Each model has 8 convolutional layers to effectively extract feature maps of traffic packet features, and two fully connected layers to output the model's prediction results. The first convolutional layer has 23 input channels, equal to the number of input rows. Each of the first four convolutional layers has 64 convolutional kernels with a kernel size of 3. Each of the last four convolutional layers has 128 kernels with the same kernel size as the first four layers. Finally, the output of the last convolutional layer is flattened and classified using two fully connected layers. The last layer of the classifier network and discriminator network has 11 and 2 neurons, respectively, as shown below. Figure 2 As shown.

[0066] Unlike multi-scale global attention mechanisms in computer vision, the Multi-Scale Dilated Attention (MSDA) of this invention first performs self-attention computation by sparsely selecting keys and values ​​within a window centered on the query patch through sliding window dilation. Subsequently, different dilation rates are assigned to different heads in a multi-head mechanism to achieve block-level multi-scale feature fusion. This design is suitable for resource-constrained federated learning scenarios on IoT devices, retaining the long-range modeling capabilities of the Transformer while significantly reducing computational overhead through sparsity and dilation operations. Figure 3 As shown.

[0067] Specifically, the processing procedure of the multi-scale dilatation attention module is as follows:

[0068] A. For the input features of the multi-scale dilated attention module, firstly, three feature matrices—query Q, key K, and value V—are obtained through linear projection; then, the channels of query Q, key K, and value V are divided into H subspaces, each subspace corresponding to an attention head, denoted as query Q. ,key Sum Define the size of the sliding window. Assign different expansion rates to each head To achieve receptive fields of different scales;

[0069] B. Querying each head after partitioning ,key Sum Perform sliding window dilated attention (SWDA) according to the assigned dilation rate:

[0070] First, with query any position in query vector Centered on the sliding window, within a range of size, according to the expansion rate Sparse sampling key Sum The corresponding position yields the adopted key. Sum The set of sampled coordinates is as follows: ,in, , This is the relative offset index within the window, used to represent the position relative to the center. Position offset;

[0071] Furthermore, calculate the position within the window. Attention output: A zero-padding strategy is used for the query positions of feature edges to ensure that the size of the output feature is consistent with that of the input.

[0072] Furthermore, queries for each head Perform the above operation at all positions to obtain the self-attention output of each head. ;

[0073] C. Output the attention of each head splicing along the channel dimension ( The multi-scale feature information corresponding to different expansion rates is fused to obtain the concatenated features. The concatenated multi-scale features are then input into a linear layer to obtain the output of MSDA. .

[0074] S3: Each client trains the classifier-discriminator model based on its own private labeled dataset and the open unlabeled dataset shared by all clients, and uses the trained classifier-discriminator model to obtain filtered soft labels and upload them to the central server.

[0075] S31: Each client uses a private labeled dataset to perform local supervised training on the classifier model, and uses the trained classifier model to perform forward propagation on the open unlabeled dataset to obtain the initial soft label and confidence of each open sample;

[0076] Each client uses a private labeled dataset to perform local supervised training on the classifier model. The trained classifier model is then used for forward propagation on the open unlabeled dataset to obtain the initial soft label and confidence score for each open sample. The overall framework is a semi-supervised federated learning system based on knowledge distillation. Figure 4 As shown.

[0077] Specifically, each client performs locally supervised training of the classifier model using a privately owned labeled dataset: the client employs the Adam optimizer (learning rate set to 0.0001), with a batch size of 100, and performs 5 local training epochs in each communication round (3 epochs in the first round to accelerate initial convergence). During training, the cross-entropy loss function is used as the hard-label supervised loss to directly optimize the real labels in the private dataset. Through locally supervised training of the classifier model, the classifier can learn discriminative features of known attack categories, which is beneficial for generating high-quality soft labels for the open dataset later. The model weights are updated using gradient descent, as shown in the following formula:

[0078] ;

[0079] in, The learning rate of the classifier model. The loss function of the classifier model gradient, This represents the predicted output of the classifier. The mapping function representing the classifier model. For traffic tags.

[0080] Specifically, the trained classifier model is used to perform forward propagation on the open unlabeled dataset to obtain the initial soft label and confidence score for each open sample, as shown in the following formula:

[0081]

[0082]

[0083] in, The initial soft label for the j-th open sample is a probability vector consisting of L probability values ​​indicating that the sample belongs to L types of traffic. This means taking the maximum probability value in the probability vector as the confidence level. Let be the confidence level of the j-th open sample.

[0084] S32: Each client constructs a discriminator training set based on the confidence level of each open sample obtained in step S31, and uses the discriminator training set to perform local supervised training on the discriminator model, so that the discriminator has the ability to distinguish between high / low confidence samples.

[0085] Specifically, each client constructs a discriminator training set based on the confidence score of each open sample obtained in step S31, including:

[0086] First, initialize the empty set. ;

[0087] Furthermore, screen for open samples with low confidence: if , If the confidence threshold is used, then the sample Add the corresponding one-hot tag to the collection. The process is as follows:

[0088] ;

[0089] Furthermore, high-confidence private samples are added: the privately labeled dataset is... All samples and their corresponding one-hot labels are added to the set. The process is as follows:

[0090] .

[0091] Specifically, the discriminator model is trained under local supervision using the discriminator training set: the discriminator adopts the same 1D CNN structure as the classifier, uses the Adam optimizer (learning rate set to 0.0001), a batch size of 100, and performs 3 local training rounds (discri_rounds=3) in each communication round. During training, the binary cross-entropy loss function (BCEWithLogitsLoss) is used as the supervised loss to optimize known / unknown samples. Through local supervised training of the discriminator model, the discriminator can effectively distinguish between known and unknown samples in the open dataset, and uniformly distribute the soft labels of low-confidence samples, thereby significantly improving the quality of soft labels uploaded to the server and providing more reliable input for subsequent mutual information aggregation and knowledge distillation. The process is as follows:

[0092]

[0093] in, The learning rate of the discriminator model. The loss function of the discriminator model gradient, The discriminator model predicts the output. For one-hot real labels.

[0094] S33: Each client uses the trained discriminator model to filter the initial soft tags obtained in step S31, and obtains the filtered soft tags.

[0095] Specifically, each client uses the trained discriminator model to filter the initial soft labels obtained in step S31, including: performing forward propagation on the open unlabeled dataset using the trained discriminator model to obtain the probability that the open sample predicted by the discriminator model belongs to a high / low confidence sample; determining the confidence level of the sample based on the probability that the open sample belongs to a high / low confidence sample; filtering the initial soft labels (the classifier's prediction on the client's private dataset) based on the confidence level of the samples; and retaining the original soft labels for high-confidence samples as the filtered soft labels. The details are as follows:

[0096] First, the trained discriminator model is used to perform forward propagation on the open unlabeled dataset to obtain the discriminator model's discrimination results:

[0097]

[0098] in, For the discriminator model to open samples The probability output (two-dimensional vector) of belonging to high / low confidence samples. Defined as the index of the maximum value of the probability output vector, if These are high-confidence samples. This is a low-confidence sample.

[0099] The specific process is as follows: The discriminator checks open samples... Perform forward propagation to obtain a scalar logits, which is then activated by a sigmoid function to obtain probability values. Then, arg max() (or an equivalent threshold check) is used to convert it into a binary decision label. :

[0100] If the discriminator determines that the sample is a known sample (high confidence), then Preserve the original soft labels output by the classifier. .

[0101] If the discriminator determines that the sample is an unknown sample (low confidence), then Set its soft label to a uniform distribution vector Therefore, the role of arg max() here is to make a decision on the binary classification output of the discriminator, obtain a filtering flag of 0 or 1, and further determine whether the "known" standard is met through an independent discriminator model, thereby achieving the purification of soft labels.

[0102] Furthermore, the initial soft labels are filtered based on the prediction confidence of the discriminator model: low-confidence samples are set to 0, while high-confidence samples retain their original soft labels.

[0103] ;

[0104] Here, "0" is used to indicate that the soft label is set to a uniformly distributed vector. Then, each client uploads the soft label of the unlabeled open data to the central server.

[0105] S4: The central server receives the filtered soft tags uploaded by the client, calculates the dynamic weight of each client using the mutual information aggregation mechanism, and uses the dynamic weight to perform weighted fusion of the filtered soft tags to generate global soft tags.

[0106] The shared global model and existing local model for each client are emphasized for the next weight update. The goal is to optimally utilize the currently trained model on a single local device, minimizing the overall training loss by aggregating the global model using each client's private dataset. This can be defined as:

[0107] ;

[0108] in, Indicates the current model exist The loss calculated on the k-th client sample includes the client classifier loss, the client discriminator loss, and the federated knowledge distillation training loss, where K is the total number of participating clients. The total number of data samples for the customer. It is the size of The client's local data sample index set, It is the single-sample loss of the i-th sample.

[0109] Traditional FedAvg uses a certain percentage of data volume. Weighted aggregation of client model parameters essentially uses global gradients. Updating the global model is necessary, but in highly Non-IID scenarios, simply weighting by data volume can be biased by low-quality clients, leading to a decline in global model performance. This invention uses mutual information dynamic weights instead of traditional data volume weights to achieve better minimization of the total global loss at the soft label level.

[0110] Specifically, after receiving all the soft tags uploaded by clients, the server uses a mutual information aggregation mechanism to calculate the dynamic weight of each client, including:

[0111] First, calculate the average distribution of soft tags for a single client: take the average of all open sample soft tags for the i-th client to obtain the average distribution of soft tags for that client.

[0112]

[0113] Furthermore, calculate the preliminary global average distribution: average the average distribution of all clients to obtain the preliminary global soft tag distribution.

[0114]

[0115] Furthermore, calculate the mutual information value: calculate the mutual information between the average distribution of each client and the global preliminary soft tag distribution:

[0116]

[0117] in, For entropy, This indicates that the k-th client is in category The average predicted probability on Let be the joint entropy.

[0118] Furthermore, the dynamic weights are calculated: the mutual information values ​​are normalized to obtain the dynamic weights for each client.

[0119] .

[0120] Clients with high mutual information values ​​predict distributions with richer and more representative information, thus receiving higher weights and generating higher-quality global soft labels. This strategy further reduces communication overhead by transmitting only logits instead of model parameters. This weighting ensures that information-rich clients dominate the aggregation. Finally, global soft labels are generated and distributed through weighted fusion for knowledge distillation. This mechanism, combined with mutual information-driven federated learning, is applied to soft label distillation scenarios and further enhanced by a discriminator to improve label quality.

[0121] Specifically, dynamic weights are used to weight and fuse the filtered soft tags to generate global soft tags. Its main function is to dynamically weight client contributions, replacing the simple average aggregation of traditional FedAvg. This includes:

[0122] First, a weighted fusion process is used to generate global soft tags: soft tags from all clients are weighted and fused according to dynamic weights, and the tag distribution is adjusted using a softmax distillation function to obtain the final global soft tags.

[0123]

[0124]

[0125] in, It is the softmax function at distillation temperature T.

[0126]

[0127] When distillation temperature At this time, the distribution of each category of the global soft label becomes more acute, and the information entropy decreases; when the distillation temperature... At this point, the distribution of global soft labels across categories tends to become more uniform, and information entropy increases. The purpose of entropy reduction aggregation is to accelerate the training of semi-supervised federated learning models based on knowledge distillation and improve the model's training stability under conditions of non-independent and identically distributed private data.

[0128] This strategy prioritizes aggregating models with high information gain, significantly reducing communication overhead and improving convergence speed in non-IID scenarios. This process is repeated in each communication round, ensuring that aggregation dynamically adapts to non-IID heterogeneity, while transmitting only logits significantly reduces communication overhead.

[0129] S5: The central server distributes global soft labels to all clients. Each client uses the global soft labels as teacher labels and its local classifier model as student models. Knowledge distillation training is performed using open, unlabeled datasets to obtain the knowledge-distilled local classifier model. Each client considers itself a student and uploads its predicted labels for unlabeled open data to the central server. The global soft labels aggregated by the central server then act as teachers, with each local client model undergoing distillation training using unlabeled open data with global soft labels.

[0130] After global soft labels are broadcast to each client, they are used for knowledge distillation training on both the client and server sides, improving the efficiency of utilizing open datasets and the model's generalization ability. Knowledge distillation training is performed using an open, unlabeled dataset. The client uses the global soft labels as the teacher model and the local classifier model as the student model. The client uses the Adam optimizer (learning rate set to 0.0001), with a batch size of 100, and performs 10 distillation training rounds (dist_rounds=10) in each communication round. During training, the model output logits and the global soft labels (probability distribution) sent by the server are compared using the cross-entropy loss function. The local model weights are then updated using gradient descent, as shown in the formula:

[0131]

[0132] Among them, there are , .

[0133] S6: Repeat steps S3 to S5 for multiple rounds of iterative training until the accuracy stabilizes or the preset maximum number of rounds is reached. After testing the trained local classifier model using a test dataset, apply it to IoT intrusion detection.

[0134] During training, this invention uses communication rounds as the iteration unit, performing a fixed number of rounds of training (comm_cnt=100). Each round sequentially executes: ① client-side local supervised training and soft label generation; ② knowledge distillation training based on global soft labels. Since global convergence judgment is complex in federated learning scenarios, this paper uses a fixed number of communication rounds as the training termination condition. Simultaneously, after each round, the server-side global model is evaluated using a test dataset to monitor performance changes. Training is considered complete when the test accuracy stabilizes or reaches the preset maximum number of rounds.

[0135] Experiments and Analysis:

[0136] Part 1: Selection of Experimental Datasets: In the field of IoT intrusion detection, experimental datasets typically have the following characteristics: First, the data sources are highly scenario-based and heterogeneous, often collected from diverse devices such as cameras and sensors in real or highly simulated environments to reflect the fragmented nature of the IoT ecosystem; second, the attack traffic coverage is comprehensive, including not only conventional network attacks such as DDoS and port scanning, but also focusing on malicious behaviors unique to IoT, such as vulnerability exploitation of weak protocols and botnet proliferation; third, the data feature engineering is complex, requiring the extraction of multi-dimensional features such as temporal, statistical, and protocol semantics from the original network flow to effectively characterize the subtle differences between normal and abnormal device states; finally, annotation quality and data balance often face challenges. Due to the relative scarcity of real attack samples, datasets often need to be constructed by injecting attacks in a controlled environment, and class imbalance must be properly addressed to support model training.

[0137] The N-BaIoT dataset is a public dataset proposed by Yisroel Mirsky et al. in 2018. It comprises nine subsets collected from nine IoT devices, such as doorbells and cameras. Seven of these IoT devices exhibit 11 traffic types: one type of benign traffic and ten types of attack traffic. The other two devices exhibit six traffic types: one type of benign traffic and five types of attack traffic. The dataset contains over 7 million instances, from which 115 statistical features covering dimensions such as packet size, timing, and bandwidth have been extracted. These features are finely labeled according to specific devices and attack types, and are defined within five recent time windows: 100 ms, 500 ms, 1.5 s, 10 s, and 1 min. These features can be quickly calculated, meeting the requirements for real-time detection of malicious traffic packets. Due to its high simulation of real-world threat scenarios, this dataset has become a key standard for validating and comparing the performance of detection models and is widely used in the field of IoT intrusion detection.

[0138] Part Two: Data Preprocessing

[0139] (1) Data Partitioning: In IoT deployment environments, a large number of IoT devices participate in federated learning training. Training directly on the original N-BaloT dataset would consume a significant amount of computational resources, and the client data is typically not independent and identically distributed. Therefore, a new dataset, mini-N-BaIoT, was created, consisting of 11 traffic categories from 9 IoT devices. The subset of the original dataset containing the nine IoT devices was then divided into... . Based on traffic categories, it is divided into Each subset, which means each subset Traffic data containing only one category, in each subset Select 1000 traffic data records as The dataset was ultimately divided into private, open, and test datasets in a 70%, 10%, and 20% ratio, respectively. One client.

[0140] 1) Scenario 1: The private dataset D^P is sorted according to its classification label and divided into 2K... di Two shards are allocated to each client, with the size being the quotient of the two shards.

[0141] 2) Scenario 2: In this scenario, the Dirichlet distribution is used. In the experiment, set up =0.1, where The smaller the value, the higher the data heterogeneity.

[0142] (2) Normalization: The traffic features in each dimension of the dataset vary greatly. In order to train our model more effectively, we use min-max normalization to scale the feature values ​​to between 0 and 1.

[0143] (3) Two-dimensionalization: Each sample has 115 features, which are divided into five parts according to the time window. The vectorized features of a sample are further divided into five parts, and the vectors are passed into a matrix with 5 columns and 23 rows, which is then input into the improved CNN model.

[0144] Part Three: Evaluation Indicators

[0145] The research content of this invention is mainly evaluated from two aspects: communication cost and intrusion detection effectiveness. The communication cost of federated learning intrusion detection is evaluated by the total amount of data transmitted. Intrusion detection effectiveness is evaluated by accuracy, precision, and recall. Evaluation is based on scores.

[0146] (1) Evaluation indicators of communication costs:

[0147] To evaluate the communication cost of federated learning intrusion detection, this invention employs a total data transmission volume evaluation model.

[0148]

[0149] in, Indicates the total number of communication rounds. This represents the amount of data uploaded per round. The total amount of data uploaded by the statistical model is used to measure the cumulative communication cost throughout the entire training process.

[0150] (2) Evaluation indicators of intrusion detection effectiveness

[0151] To evaluate the effectiveness of intrusion detection, this invention introduces accuracy, precision, recall, and... Evaluation is based on scores.

[0152] Accuracy is an important metric for evaluating the effectiveness of intrusion detection. It is calculated by determining the proportion of correctly predicted labels in the test set relative to the total number of labels in the test set. The formula is shown in the figure below:

[0153]

[0154] In this context, TP represents a true positive, TN represents a true negative, FP represents a false positive, and FN represents a false negative.

[0155] Precision is a key performance indicator for evaluating intrusion detection effectiveness. It is quantitatively expressed as the proportion of samples identified as attacks by the system that are actually genuine attacks. Higher precision indicates a lower false positive rate, meaning the system can more reliably distinguish between legitimate traffic and malicious attacks. The calculation formula is shown below:

[0156]

[0157] Recall reflects the proportion of attack samples that are successfully detected across all time periods. A high recall rate means fewer false negatives, i.e., most attacks can be detected. Its calculation formula is shown below:

[0158]

[0159] The score is a weighted harmonic mean of precision and recall, used to balance false positives and false negatives. It is more representative than precision alone when the data is class imbalanced. Its calculation formula is shown below:

[0160]

[0161] for Classification tasks, accuracy, precision, recall and Scores can be calculated using a macro average, which is the arithmetic mean of all categories.

[0162] Part Four: Experiment Setup

[0163] To verify the effectiveness of the proposed method, this invention simulates and evaluates two scenarios with different degrees of non-independent and identically distributed characteristics. Scenario 1 partially reflects device differences, while Scenario 2 most closely resembles real-world IoT heterogeneity. In both scenarios, the number of clients is 89, and the private data distribution of each client is non-independent and identically distributed, differing only in the data partitioning method. Scenario 1 has fewer traffic categories and a larger number of traffic samples per tag. Scenario 2 uses the Dirichlet function (…). =0.1) Segmenting the private dataset. The client model applies an improved CNN model to extract multi-scale features from traffic packets. The classifier and discriminator use the same architecture, differing only in the output layer, where the classifier's output layer has a dimension of 11 and the discriminator's output layer has a dimension of 2. Each model contains eight convolutional layers and a multi-scale dilated attention mechanism, as well as two fully connected layers for outputting the model's predictions. The number of convolutional kernels in layers 1 to 8 are 64, 64, 64, 64, 128, 128, 128, and 128, respectively. Multi-scale dilated attention is introduced after the fifth convolutional layer, with a kernel size of 3×3. The federated learning training used in this invention is built on the PyTorch framework. The system includes a server-side and multiple client modules, which respectively implement core functions such as local multi-scale dilated attention model training, soft label uploading, global mutual information aggregation, knowledge distillation, and model updating. The communication process is completed through local simulation, ensuring no data leakage between clients, achieving privacy protection, and conforming to the basic principles of distributed training in federated learning. To make the experimental evaluation clearer, this section describes the experimental environment and details.

[0164] (1) Experimental environment: Intel(R) Core(TM) i7-9700 CPU @ 3.00GHZ processor, Intel(R) UHD Graphics 630 graphics card, 32G memory, operating system is Windows 11, software is PyCharm, version 2024.2.1, deep learning framework is PyTorch, language is Python, version 3.8.0.

[0165] (2) Experimental Details: During client-side model training, the optimizer, batch size, number of epochs per round, and learning rate were set to Adam optimizer, 100, 5, and 0.0001, respectively. The threshold for judging sample confidence levels was... No fixed value was set; the threshold value was not specified. Configured as client-side mutual information aggregation.

[0166] Part 5, Comparative Analysis Experiment:

[0167] As shown in Table 1, the proposed method outperforms other methods in the tested evaluation metrics. It's important to note that FD's detection accuracy is relatively low in the two highly non-independent and identically distributed scenarios designed for the experiment, at 12.84% and 53.81%, respectively. This is because the environment is non-independent and identically distributed, client traffic categories are fewer, and the data distribution differs from the global distribution, affecting the distillation training effect. FD's optimal detection performance is obtained from a single client; therefore, the FD method can be considered ineffective in non-independent and identically distributed scenarios. In contrast, DS-FL's detection accuracy is higher than FD, indicating that introducing unlabeled open datasets improves detection performance to some extent. However, in scenario 2, due to the more uneven distribution of data samples and labels in highly non-independent and identically distributed scenarios, the prediction quality for unlabeled open datasets decreases, leading to distillation training failure and a sharp drop in detection performance. As a traditional federated learning algorithm, FL exhibits good detection performance. However, it has some limitations: on the one hand, a large number of model gradient parameters need to be uploaded during training, significantly increasing communication costs and hindering the actual deployment of the model; on the other hand, the FL method is also vulnerable to reverse engineering attacks, where attackers can use the uploaded gradients to deduce the original data. In comparison, the detection performance of this invention in this scenario is significantly superior to existing methods. Its main advantages are: 1. A dynamic discriminator mechanism filters low-confidence samples, reducing the number of uploaded samples and improving the quality of uploaded soft labels. 2. An improved CNN based on a multi-scale dilated attention mechanism enhances the extraction capability of traffic features and improves the quality of soft labels. 3. A mutual information aggregation strategy actively deweights some clients during the aggregation process, improving the global soft label accuracy and enhancing distillation robustness. Multilayer Perceptron (MLP) and LSTM, as centralized intrusion detection algorithms, showed generally average performance compared to the proposed improved CNN model in the two scenarios designed in this experiment. MLP, due to its simple structure, strong generalization ability, and stable training process, outperforms LSTM in intrusion detection tasks. Furthermore, since this invention communicates based on predictions from unlabeled open datasets, it avoids the direct uploading of model gradients and parameters, reducing communication overhead and thus improving security while maintaining performance.

[0168] Table 1 Comparison of Algorithm Results on Datasets

[0169]

[0170] Table 2 compares the test accuracy of each method under different communication rounds. The results show that this invention achieves excellent performance with fewer training rounds and consistently outperforms other methods throughout the training process. Specifically, when FL reaches 200 training rounds, the test accuracy reaches 56.69% and 63.24% respectively, but still does not reach the maximum accuracy, and the model training speed is slow. While FD converges relatively quickly throughout the training process, the results are not ideal, hovering around 12.84% and 53.81% respectively, and the upper limit of detection performance cannot be improved by increasing the number of training rounds. DS-FL improves its accuracy as training progresses, reaching 39.92% and 24.05% after 200 rounds, but still far lower than the method of this invention. Although DS-FL has a faster convergence speed, its accuracy is low, and the accuracy does not increase with further model training. In contrast, the method of this invention achieves 66.02% and 56.66% accuracy in the first 10 rounds, and approaches the final accuracy within 100 rounds, demonstrating extremely fast convergence speed. At 200 rounds, the method of this invention achieves test accuracies of 85.46% and 83.73%, respectively, both higher than FL, DS-FL, MLP, and LSTM algorithms. Furthermore, although MLP's convergence speed is higher than the algorithm proposed in this invention in the early stages of training, its accuracy is still lower. LSTM, due to its large number of parameters, is prone to the gradient vanishing problem during training, resulting in significantly lower accuracy than MLP in this scenario. Since MLP and LSTM are centralized learning models, their communication overhead is not considered in the computation.

[0171] Table 2 Comparison of Top-Acc test accuracy with other methods for different communication rounds

[0172]

[0173] Table 3 lists the communication overhead for each method. The FL algorithm requires uploading model parameters to the server in each training round, while the communication overhead of the other three distillation algorithms depends only on the output dimension of the model, significantly reducing communication costs. The total communication overhead of the FL algorithm reaches 1745.06MB in scenario 1 and 1700.12MB in scenario 2, limiting its applicability in low-bandwidth environments. The FD and DS-FL algorithms significantly reduce communication costs by uploading prediction results instead of model parameters. For example, FD uploads the average prediction for each label, but it quickly reaches the highest accuracy, with a communication cost of 0.01MB in scenario 1 and only 0.13MB in scenario 2. The DS-FL algorithm uploads the predicted logits from the unlabeled open dataset, with a communication cost of 45.26MB in scenario 1 and 46.65MB in scenario 2, and test accuracies of 39.92% and 24.05%, respectively. This indicates that while the DS-FL method improves model performance and reduces communication costs to some extent by introducing unlabeled open datasets, its model accuracy remains low. In contrast, the method presented in this chapter achieves superior communication efficiency while ensuring high testing accuracy. Since the client uploads soft tags filtered by the discriminator, the communication overhead is further reduced compared to the DS-FL algorithm. In scenario 1, the method of this invention achieves a communication cost of only 13.27 MB and an accuracy of 85.46%; in the more challenging scenario 2, the communication cost is only 15.92 MB and the accuracy reaches 83.73%, both outperforming the DS-FL algorithm. The algorithm proposed in this chapter balances high accuracy with low communication cost, making it more advantageous in resource-constrained environments and providing a superior solution for federated learning IoT intrusion detection.

[0174] Table 3 Comparison of Communication Overhead and Top-Acc

[0175]

[0176] In summary, to address the issues of privacy breaches, high communication overhead, and highly heterogeneous non-independent identically distributed (Non-IID) data in IoT intrusion detection, this invention proposes a federated learning IoT intrusion detection method based on multi-scale dilated attention. This method introduces an open unlabeled dataset and utilizes a classifier and discriminator trained locally on the client side to collaboratively generate high-quality soft labels. To further enhance feature representation, this invention embeds a multi-scale dilated attention mechanism on top of the original convolutional neural network, improving the ability to perceive complex intrusions and overcoming the limitations of single-scale convolution, thereby further improving the quality of soft labels and overall detection robustness. Uploading soft labels to the server protects data privacy and reduces communication overhead. The server uses a mutual information aggregation mechanism to dynamically weight client contributions, generating and distributing global soft labels, enabling knowledge distillation training between the client and server, and effectively utilizing unlabeled data to improve model generalization ability. Experimental results show that, under the premise of privacy protection, the proposed method achieves detection accuracies of 85.46% and 83.73% in two simulation environments, respectively, while saving communication overhead. The proposed algorithm can achieve faster convergence speed and higher detection accuracy with lower communication overhead, meeting the detection requirements of IoT intrusion detection systems. Although the proposed method has achieved good performance, there is still room for improvement. Future work can consider further strengthening privacy protection by integrating blockchain or differential privacy technologies. These directions will promote the in-depth application of federated learning in the field of IoT intrusion detection.

[0177] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. An IoT intrusion detection method based on multi-scale dilated attention and federated learning, characterized in that, The steps are as follows: S1: Acquire IoT traffic datasets and perform data partitioning and preprocessing to obtain a private labeled dataset for each client, an open unlabeled dataset shared by all clients, and a test dataset; S2: Each client builds a classifier-discriminator model based on multi-scale dilated attention and convolutional neural networks; S3: Each client trains the classifier-discriminator model based on its own private labeled dataset and the open unlabeled dataset shared by all clients, and uses the trained classifier-discriminator model to obtain filtered soft labels and upload them to the central server. S4: The central server receives the filtered soft tags uploaded by the client, calculates the dynamic weight of each client using the mutual information aggregation mechanism, and uses the dynamic weight to perform weighted fusion of the filtered soft tags to generate global soft tags. S5: The central server distributes global soft labels to all clients. Each client uses the global soft labels as teacher labels and the local classifier model as student models. It uses the open unlabeled dataset to perform knowledge distillation training to obtain the local classifier model after knowledge distillation. S6: Repeat steps S3 to S5 for multiple rounds of iterative training until the accuracy tends to stabilize or reaches the preset maximum number of rounds. After testing the trained local classifier model with the test dataset, apply it to IoT intrusion detection.

2. The IoT intrusion detection method based on multi-scale dilated attention and federated learning according to claim 1, characterized in that, Acquire IoT traffic datasets and perform data partitioning and preprocessing, including: Data partitioning: Select traffic data from K IoT devices in the original IoT traffic dataset. Split the traffic data of each IoT device into L single-category subsets according to traffic category. Select B traffic data records in each single-category subset to construct a simplified subset of each single category. Integrate all simplified subsets of each single category to obtain a simplified dataset of all categories. Divide the simplified datasets of all categories into privately labeled datasets, open unlabeled datasets, and test datasets according to a fixed ratio. Preprocessing: Min-max normalization is used to scale the flow feature values ​​to the [0,1] interval; the flow features are split into two-dimensional feature matrices according to time windows.

3. The IoT intrusion detection method based on multi-scale dilated attention and federated learning according to claim 2, characterized in that, The classifier-discriminator models all adopt a CNN architecture based on multi-scale dilated attention, and the number of neurons in the output layer of the classifier and discriminator is different. The improved CNN architecture based on multi-scale dilated attention includes, in sequence, a first convolutional layer, a second convolutional layer, a third convolutional layer, a fourth convolutional layer, a fifth convolutional layer, a multi-scale dilated attention module, a sixth convolutional layer, a seventh convolutional layer, an eighth convolutional layer, a dropout layer, a flattening layer, a first fully connected layer, and a second fully connected layer, with the second fully connected layer serving as the output layer. The classifier output layer has L neurons, corresponding to L traffic categories, and the discriminator output layer has 2 neurons, corresponding to high / low confidence samples.

4. The IoT intrusion detection method based on multi-scale dilated attention and federated learning according to claim 3, characterized in that, The processing steps of the multi-scale dilatational attention module include: For the input features of the multi-scale dilated attention module, queries are obtained for each attention head h through linear projection and attention head partitioning. ,key Sum Assign different expansion rates to each head ; Querying each head after partitioning ,key Sum Based on the assigned expansion rate and the predefined sliding window size Perform sliding window dilation attention calculations to obtain the self-attention output for each head. ; Output the attention of each head The channel dimensions are concatenated to obtain concatenated features. The concatenated multi-scale features are then input into a linear layer to obtain the output of the multi-scale dilated attention module.

5. The IoT intrusion detection method based on multi-scale dilated attention and federated learning according to any one of claims 1-4, characterized in that, Step S3 specifically includes: S31: Each client uses a private labeled dataset to perform local supervised training on the classifier model, and uses the trained classifier model to perform forward propagation on the open unlabeled dataset to obtain the initial soft label and confidence of each open sample; S32: Each client constructs a discriminator training set based on the confidence of each open sample obtained in step S31, and uses the discriminator training set to perform local supervised training on the discriminator model, so that the discriminator has the ability to distinguish between high / low confidence samples. S33: Each client uses the trained discriminator model to filter the initial soft tags obtained in step S31, and obtains the filtered soft tags.

6. The IoT intrusion detection method based on multi-scale dilated attention and federated learning according to claim 5, characterized in that, Each client constructs a discriminator training set based on the confidence score of each open sample obtained in step S31, including: Initialize empty set ; Screening for open samples with low confidence: If , If the confidence threshold is used, then open samples will be used. Add the corresponding one-hot tag to the collection. , Adding high-confidence private samples: adding privately labeled datasets All samples and their corresponding one-hot labels are added to the set. The final discriminator training set is obtained. .

7. The IoT intrusion detection method based on multi-scale dilated attention and federated learning according to claim 6, characterized in that, Each client uses the trained discriminator model to filter the initial soft labels obtained in step S31, including: The trained discriminator model is used to perform forward propagation on the open unlabeled dataset to obtain the probability that the open sample predicted by the discriminator model belongs to a high / low confidence sample. The confidence level of the sample is determined based on the probability of the open sample belonging to a high / low confidence sample. The initial soft labels are filtered according to the confidence level of the sample, and the original soft labels of high confidence samples are retained as the filtered soft labels. The soft labels of low-confidence samples are set to uniform distribution vectors.

8. The IoT intrusion detection method based on multi-scale dilated attention and federated learning according to claim 7, characterized in that, The dynamic weight of each client is calculated using a mutual information aggregation mechanism, including: Calculate the average distribution of soft tags for a single client: Take the average of all open sample soft tags for the i-th client to obtain the average distribution of soft tags for that client. ; Calculate the preliminary global average distribution: Take the average of the average distributions across all clients to obtain the preliminary global soft tag distribution. ; Calculate mutual information values: Calculate the mutual information between the average distribution of each client and the global preliminary soft tag distribution. ; in, For entropy, This indicates that the k-th client is in category The average predicted probability on For joint entropy; Calculate the dynamic weights: Normalize the mutual information values ​​to obtain the dynamic weights for each client. .

9. The IoT intrusion detection method based on multi-scale dilated attention and federated learning according to claim 8, characterized in that, The filtered soft tags are weighted and fused using dynamic weights to generate global soft tags. include: ; ; in, It is the softmax function at distillation temperature T.

10. The IoT intrusion detection method based on multi-scale dilated attention and federated learning according to claim 9, characterized in that, When training the classifier model locally using a privately labeled dataset, the probability of a sample belonging to multiple traffic categories is used as the output, cross-entropy loss is employed, and the model weights are updated using gradient descent. When the discriminator model is trained locally using the discriminator training set, the probability that a sample belongs to a high / low confidence sample is used as the output. Binary cross-entropy loss is used, and the model weights are updated by gradient descent.