Vehicle intrusion detection system and method based on Hybrid EfficientNet model

Through the Hybrid EfficientNet model combined with the vehicle intrusion detection system of MBConv and FusedMBConv modules, the shortcomings of the existing system in detecting complex and dynamic network environments are solved, and efficient and accurate vehicle intrusion detection is achieved, meeting the real-time and resource limitations of the on-board environment. .

CN119106712BActive Publication Date: 2025-01-03CHANGCHUN UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411547477.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-01
Publication Date
2025-01-03
Estimated Expiration
2044-11-01

AI Technical Summary

Technical Problem

The existing vehicle intrusion detection system is difficult to effectively detect unknown and mutated attacks when facing complex and dynamic vehicle network environments, and due to model complexity and computing resource limitations, it is difficult to achieve real-time response and efficient processing.

Method used

Using a vehicle intrusion detection system based on the Hybrid EfficientNet model, this model combines the core ideas of EfficientNet and the MBConv and FusedMBConv modules to significantly reduce the amount of parameters and calculation complexity through the adaptive global pooling layer and attention mechanism, and improve the efficiency of the model and accuracy.

Benefits of technology

It realizes high accuracy and fast response vehicle intrusion detection, can operate effectively in resource-constrained vehicle environments, meet real-time detection requirements, and improves the generalization ability and accuracy of the model through detailed preprocessing and feature selection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119106712B_ABST
    Figure CN119106712B_ABST
Patent Text Reader

Abstract

The present invention belongs to the field of vehicle networking and communication security technology, and relates to a vehicle intrusion detection system and method based on a Hybrid EfficientNet model, wherein the system is obtained by training the Hybrid EfficientNet model; wherein the Hybrid EfficientNet model includes an initial convolution layer, a backbone network, an adaptive global pooling layer, a Flatten layer, a discard layer, a hidden layer, and a classification layer; the backbone network is composed of 1 FusedMBConv module and 15 MBConv modules, and the MBConv module includes an expansion layer, a depth-separable convolution module, a channel and spatial attention mechanism, and a projection layer; a residual connection is used inside the MBConv module; the system has an excellent ability to detect abnormal traffic, achieves high accuracy, as well as efficient processing capability and fast response speed, meets the convenient operation requirements in a vehicle environment, and effectively solves the technical problem that the existing intrusion detection model is complex and inconvenient and cannot be directly deployed in a resource-constrained vehicle network environment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of vehicle networking and communication security technology, and specifically, relates to a vehicle intrusion detection system and method based on a Hybrid EfficientNet model. Background Art

[0002] With the rapid development of modern intelligent connected vehicles, the in-vehicle network system has become an important part of the vehicle's functions. Through the in-vehicle network, vehicles can not only exchange information with the external environment, but also perform a number of high-tech applications such as autonomous driving, remote diagnosis, and Internet of Vehicles services. However, with the increasing openness and complexity of in-vehicle networks, the network security threats faced by vehicles are also increasing. Cyber ​​attackers can remotely invade the in-vehicle network, causing abnormalities in the in-vehicle system, loss of control of vehicle functions, and even endangering driving safety.

[0003] Early intrusion detection systems mainly used rule-based strategies to determine whether there is an intrusion through pre-set anomaly detection rules and network behavior patterns. This type of system relies on expert knowledge and manually defined rules, and has the advantages of simple implementation and accurate detection. However, with the increasing complexity of vehicle networks and the diversification of attack methods, rule-based intrusion detection systems have gradually exposed the following shortcomings: (1) Unable to cope with unknown attacks (rules can only detect pre-defined known attacks, and are ineffective against variant attacks and unknown attacks); (2) High maintenance costs and difficulty in coping with dynamic network environments (vehicle network environments are complex and highly real-time, and systems based on fixed rules lack flexibility and are difficult to adapt to dynamic network changes).

[0004] In recent years, with the rapid development of machine learning and deep learning technologies, researchers have begun to try to apply these intelligent technologies to vehicle network intrusion detection systems. Machine learning-based intrusion detection systems automatically learn normal behavior patterns by analyzing historical data to identify abnormal behaviors. However, the existing deep learning-based vehicle network intrusion (also known as vehicle intrusion) detection technology still has some shortcomings and challenges, mainly manifested in model complexity and computing resource limitations, data imbalance problems, real-time and high throughput requirements. For example, the ResNet-152 model proposed by He et al. (He, K., Zhang, X., Ren, S., & Sun, J. (2016). Deep residual learning for image recognition. In Proceedings of the IEEE conference on computer vision and pattern recognition) contains more than 60 million parameters and is difficult to run in real time in a resource-constrained vehicle environment. In addition, vehicle intrusion detection systems need to respond quickly to potential security threats. However, many existing deep learning models, such as LSTM (Long Short-Term Memory) networks (Hochreiter, S., & Schmidhuber, J. (1997). Long short-term memory. Neural computation, 9(8), 1735-1780), can effectively process sequence data, but their recursive structure leads to slow inference speed and is difficult to meet the real-time requirements of vehicle systems. Although some lightweight models such as MobileNet (Howard, AG, Zhu, M., Chen, B., Kalenichenko, D., Wang, W., Weyand, T., ... & Adam, H. (2017). Mobilenets: Efficient convolutional neural networks for mobile vision applications. arXiv preprintarXiv:1704.04861.) have been proposed, these models are mainly optimized for image processing tasks on mobile devices and may not achieve ideal detection performance when processing vehicle network data. Furthermore, some existing models are not efficient in feature extraction. For example, conventional convolutional neural networks may extract a large number of redundant or irrelevant features when processing vehicle network data, which increases the computational overhead and may affect detection accuracy.Therefore, it is necessary to provide an advanced network structure that significantly reduces the number of parameters and computational complexity while maintaining the expressiveness of the model. Summary of the invention

[0005] In view of the above technical problems and defects, the present invention provides a vehicle intrusion detection system based on the Hybrid EfficientNet model. The Hybrid EfficientNet model combines the core idea of ​​EfficientNet with a variety of advanced network structures, such as MBConv (Mobile Inverted Bottleneck Convolution) and FusedMBConv (Fused Mobile Inverted Bottleneck Convolution) models. These structures can significantly reduce the number of parameters and computational complexity while maintaining the expressiveness of the model.

[0006] To achieve the above object, the present invention adopts the following technical solution:

[0007] A vehicle intrusion detection system based on a Hybrid EfficientNet model, wherein the system is obtained by training the Hybrid EfficientNet model; wherein the Hybrid EfficientNet model includes an initial convolution layer, a backbone network, an adaptive global pooling layer, a Flatten layer, a discard layer, a hidden layer, and a classification layer; the data input to the input layer of the Hybrid EfficientNet model is an image with three channels, and the image is processed by the initial convolution layer, which is a two-dimensional convolution layer for extracting low-level features of the input image, performing batch normalization and SiLU activation function processing on the data after standard convolution operation, and then outputting the output data, and the output data is selected to enter the backbone network for further feature extraction according to the configuration parameters;

[0008] The backbone network consists of 1 FusedMBConv module and 15 MBConv modules. The backbone network sets the parameter t. If t=1, the FusedMBConv module is used to process the data; if t≠1, the MBConv module is used to process the data. The specific parameter configuration is as follows:

[0009] t,c,n,s,CBAM;

[0010] 1, 16, 1, 1, 0; FusedMBConv;

[0011] 4, 24, 2, 2, 0; MBConv;

[0012] 4, 40, 2, 2, 0; MBConv;

[0013] 4, 80, 3, 2, 1; MBConv;

[0014] 6,112,3,1,1;MBConv;

[0015] 6, 192, 4, 2, 1; MBConv;

[0016] 6,320,1,1,1;MBConv;

[0017] Where c: indicates the number of output channels of the module; n: indicates the number of times the module is repeated; s: indicates the stride of the module; CBAM: indicates whether the CBAM module is used, 1 indicates the use of the CBAM attention mechanism, and 0 indicates that the CBAM attention mechanism is not used;

[0018] The FusedMBConv module is used to expand and fuse input features. It first performs a 3x3 standard convolution to extract spatial information and expand the number of channels. It then performs batch normalization and SiLU activation function processing. For the output after activation, it determines whether the expansion rate is equal to 1. If the expansion rate is 1, it is directly output; if the expansion rate is greater than 1, it continues to perform a 1x1 convolution, and then performs batch normalization before output;

[0019] The MBConv module includes an expansion layer, a depth-separable convolution module, a channel and spatial attention mechanism, and a projection layer; the expansion layer is used to expand the number of channels of the input features, the number of output channels in the expansion layer is determined by the expansion factor t and the number of input channels, and the data after the expansion convolution is processed by batch normalization and SiLU activation function;

[0020] The depthwise separable convolution module is divided into depthwise convolution and pointwise convolution. The number of input channels of depthwise convolution is the number of channels after expansion, and the number of output channels is consistent with the number of input channels. The stride s is 1 or 2, which is set in the parameter configuration. The number of input channels of pointwise convolution is the number of output channels of depthwise convolution, and the number of output channels c is set in the parameter configuration, which is the same as the original number of channels or the number of channels after expansion.

[0021] The channel and space attention mechanism includes a channel attention mechanism and a space attention mechanism, wherein the channel attention mechanism is used to multiply the generated channel attention coefficient with the original feature to obtain an enhanced channel feature; the space attention mechanism is used to multiply the generated space attention coefficient with the input feature map to obtain a final enhanced space feature;

[0022] The projection layer is used to adjust the number of channels of the feature map to ensure that the number of channels between different modules matches, and then output after batch normalization operation;

[0023] The MBConv module uses residual connection inside. When the number of input channels of the MBConv module is the same as the number of output channels and the stride s is 1, the residual connection is used to directly add the input of the module to the output of the module.

[0024] The adaptive global pooling layer is used to compress the spatial dimension of the feature map into a fixed output size while keeping the channel information unchanged, thereby generating a global feature vector;

[0025] The Flatten layer is used to convert the multi-dimensional feature map into a one-dimensional vector;

[0026] The hidden layer is the first fully connected layer, and the expanded feature vector is gradually compressed into a vector required for classification through the first fully connected layer;

[0027] The classification layer is the second fully connected layer, which is used to map the extracted high-dimensional global features to the probability space of the output category to complete the classification task of vehicle intrusion detection.

[0028] As a preferred embodiment of the present invention, the convolution kernel size of the initial convolution layer is 3x3, and the stride is 2; the number of output channels of the expansion layer is 6 times the number of input channels, and is expanded by 1x1 convolution with a stride of 1 and padding of 0; the depthwise convolution is 3x3 convolution, and the point-by-point convolution is 1x1 convolution; the projection layer effectively adjusts the number of channels of the feature map through a 1×1 convolution operation with a stride of 1 and no padding; the spatial dimension of the output of the adaptive global pooling layer is fixed to (1, 1); the first fully connected layer performs a linear transformation, and after the linear transformation, the SiLU activation function is used; the discard rate of the discard layer is set to 0.2.

[0029] As a preferred embodiment of the present invention, the channel attention mechanism applies global average pooling and global maximum pooling to the feature map to obtain two different global information representations; then the two features obtained are processed by two 1x1 convolutional layers, and a nonlinear transformation is introduced by a ReLU activation function; then, the two processed feature maps are added and a channel attention coefficient is generated by a Sigmoid activation function; finally, the generated channel attention coefficient is multiplied by the original feature to obtain an enhanced channel feature; after completing the channel attention processing, the feature map is further processed by a spatial attention mechanism.

[0030] As a preferred embodiment of the present invention, the spatial attention mechanism performs average pooling and maximum pooling operations on the feature map on the channel to generate two spatial feature maps; then the two spatial feature maps are spliced ​​together and processed through a 3x3 convolution layer, and a spatial attention coefficient is generated through a Sigmoid activation function; finally, the generated spatial attention coefficient is multiplied by the input feature map to obtain the final enhanced spatial feature.

[0031] As a preferred embodiment of the present invention, the specific steps of training the Hybrid EfficientNet model are:

[0032] Step S1. Select the vehicle data set Car-Hacking as the vehicle internal data set, and convert it into a data form that can be processed by the Hybrid EfficientNet model by preprocessing the data;

[0033] As a preferred embodiment of the present invention, step S1 specifically includes the following steps:

[0034] Step S101. Sampling the original Car-Hacking dataset;

[0035] For the labels ‘R’, ‘Fuzzy’, ‘RAM’, ‘Gear’, and ‘DoS’ in the vehicle data, sampling is performed at the ratio of 30%, 60%, 65%, 65%, and 70%, respectively;

[0036] Step S102: Perform outlier detection on the sampled data set after dimensionality reduction;

[0037] An improved Autoencoder model is used to perform dimensionality reduction processing, compressing high-dimensional data into a low-dimensional latent space to generate low-dimensional features, and then an isolation forest algorithm is applied to perform outlier detection; batch normalization and Dropout layers are added to the improved Autoencoder model;

[0038] Step S103. Oversampling;

[0039] Use SMOTE to oversample the samples labeled 'Fuzzy' to the average number of samples of the labels 'RPM', 'Gear', and 'DoS'; then, for each generated sample, use ADASYN to dynamically adjust the generation ratio of synthetic samples;

[0040] Step S104: performing feature selection;

[0041] The feature selection method based on mutual information screens out features with mutual information scores higher than 0.2;

[0042] Step S105. After completing feature selection, the selected features are standardized and scaled;

[0043] First, the selected features are normalized to convert the feature values ​​to the range of [0, 1]. Second, a normalization method based on quantile transformation is used to map the data samples to the range of [0, 255] to adapt to the image format.

[0044] Step S2. converting the data set processed in step S1 into multiple sets of image data sets according to the labels;

[0045] The data samples are converted into data blocks according to the timestamp and feature size of the dataset, and then the data blocks are converted into images, and the training dataset and test dataset are divided proportionally;

[0046] Step S3: The training data set and test data set processed in step S2 are passed into the built HybridEfficientNet model for training.

[0047] As a preferred embodiment of the present invention, the improved Autoencoder model includes an input layer arranged in sequence; a first fully connected layer, with 256 neurons, a relu activation function; a first normalization layer; a first Dropout layer, with a ratio of 0.3; a second fully connected layer, with 128 neurons, a relu activation function; a second normalization layer; a second Dropout layer, with a ratio of 0.3; a third fully connected layer, with 64 neurons, a relu activation function; a third normalization layer; a third Dropout layer, with a ratio of 0.3; a fourth fully connected layer, with 32 neurons, a relu activation function, the fourth fully connected layer is a bottleneck layer, which is the last layer of the encoder; a fifth fully connected layer, with 64 neurons, a relu activation function; a fourth normalization layer; a sixth fully connected layer, There are 128 neurons and relu activation function; the fifth batch normalization layer; the seventh fully connected layer has 256 neurons and relu activation function; the sixth batch normalization layer; the eighth fully connected layer is the last layer of the decoder, which outputs a reconstructed data with the same dimension as the input data; the hyperparameters of network training are set as follows: batch size is 256 and the maximum number of iterations is 100 rounds.

[0048] As a preferred embodiment of the present invention, the specific steps of step S2 are: 9 important features are selected, namely CAN ID and DATA[0]-DATA[7], every 27 consecutive samples are grouped into a data block, each data block contains 9×27=243 eigenvalues, and the 243 eigenvalues ​​are reshaped into a 9x9x3 three-dimensional array, the format of the three-dimensional array corresponds to the height, width and color channels in the image, and is used as the input of the image data.

[0049] As a preferred embodiment of the present invention, when the step S3 is trained, the processed data is input into the HybridEfficientNet model. Before the model is finally trained and evaluated, the data set and the Hybrid EfficientNet model are first called by the tree-shaped Parzen estimator hyperparameter optimization method to find the best hyperparameter combination suitable for the Hybrid EfficientNet model; after obtaining the optimal hyperparameter combination, the obtained optimal hyperparameter combination is evaluated.

[0050] The present invention provides a vehicle intrusion detection method based on a Hybrid EfficientNet model, the method comprising the following steps:

[0051] Step 1. Receive CAN traffic data in real time;

[0052] Step 2. Preprocess the CAN traffic data, normalize it and convert it into image data;

[0053] Step 3. Input the converted image data into the vehicle intrusion detection system based on the Hybrid EfficientNet model described above;

[0054] Step 4. The vehicle intrusion detection system based on the Hybrid EfficientNet model identifies and classifies the CAN traffic data received in real time and outputs the classification results;

[0055] Step 5. Based on the classification results, determine the intrusion detection results.

[0056] Advantages and beneficial effects of the present invention:

[0057] (1) The present invention designs a vehicle intrusion detection system based on the Hybrid EfficientNet model. The system has excellent ability to detect abnormal traffic, can distinguish various attack categories, and achieves high accuracy, as well as efficient processing capabilities and fast response speed (the average batch processing time is 7.68 milliseconds and the memory usage is 15.6MB). It meets the convenient operation requirements in the vehicle environment and effectively solves the technical problem that the existing intrusion detection model is complex and inconvenient and cannot be directly deployed in the resource-constrained vehicle network environment.

[0058] (2) The Hybrid EfficientNet neural network model provided by the present invention combines the core ideas of EfficientNet with a variety of advanced network structures, such as MBConv (Mobile Inverted Bottleneck Convolution) and FusedMBConv (Fused Mobile Inverted Bottleneck Convolution). These structures can significantly reduce the number of parameters and computational complexity while maintaining the expressive power of the model.

[0059] (3) The present invention uses both MBConv and FusedMBConv modules, and flexibly selects them according to the requirements of different layers to balance efficiency and performance. In the MBConv module, the standard convolution is decomposed into depthwise convolution and point-by-point convolution, which greatly reduces the computational complexity. By introducing the CBAM (Convolutional Block Attention Module) attention mechanism, the model's perception of key features is enhanced, and the model's attention to important features is improved, thereby improving the performance and generalization ability of the model.

[0060] (4) The present invention not only optimizes the model training process, but also helps technicians intuitively evaluate and understand the model performance through detailed visualization methods, such as confusion matrix and training curve, thereby achieving efficient and accurate vehicle intrusion detection tasks.

[0061] (5) The data is preprocessed before model training. A multi-level sampling strategy is introduced during preprocessing to balance various types of sample data in a more refined manner, effectively retain the differences between categories, reduce the risk of information loss, and improve the representativeness and sampling quality of the data set.

[0062] (6) The present invention compresses high-dimensional data into a low-dimensional latent space through an improved Autoencoder dimensionality reduction model for the sampled data set, thereby enhancing the feature extraction capability and enabling the Isolation Forest Algorithm to more efficiently and accurately distinguish normal points from abnormal points, perform anomaly detection, and reduce the interference of redundant information and noise that may exist in the high-dimensional feature space. Moreover, since Batch Normalization and Dropout layers are added to the improved Autoencoder network, and an early stopping strategy is used to monitor the loss of the validation set, over-training of the model can be effectively avoided.

[0063] (7) In order to solve the problem of class imbalance in the data set, the present invention adopts an oversampling technology that combines SMOTE and ADASYN. Compared with the traditional SMOTE method, after adding ADASYN, the system can dynamically adjust the sampling strategy according to the sample distribution, reduce the possibility of generating new samples that are too concentrated, enhance the adaptability to complex data distribution, ensure the balance of data and the representativeness of synthetic samples, so that the classifier's learning ability for each category is significantly improved, effectively reduce the deviation in the training process, and improve the generalization ability and accuracy of the model.

[0064] (8) The present invention introduces a feature selection method based on mutual information, which effectively removes noise features or redundant features and retains only the features that significantly contribute to the target variable. This method can further optimize the model performance and improve the model training efficiency while ensuring the accuracy.

[0065] (9) The present invention conducts a comprehensive evaluation on the performance of the lightweight neural network model of Hybrid EfficientNet (including indicators such as accuracy, recall rate, and F1 score). The results show that the model has a good performance of 100% in terms of accuracy, precision, recall rate, and F1 score. It has a good performance in vehicle intrusion detection and can accurately identify malicious traffic in the Internet of Vehicles to ensure the safety of vehicle driving. BRIEF DESCRIPTION OF THE DRAWINGS

[0066] By referring to the following description in conjunction with the accompanying drawings, and with a more comprehensive understanding of the present invention, other objects and results of the present invention will become more clear and easy to understand. In the accompanying drawings:

[0067] Figure 1 It is a schematic diagram of the overall architecture of the Hybrid EfficientNet model of the present invention;

[0068] Figure 2 It is a flow chart of the data preprocessing process of the present invention. DETAILED DESCRIPTION

[0069] In order to enable those skilled in the art to better understand the technical solution and advantages of the present invention, the present application is described in detail below in conjunction with the accompanying drawings, but it is not intended to limit the protection scope of the present invention.

[0070] In order to cope with the complexity and inconvenience of operation of the current vehicle intrusion detection system, this embodiment provides a vehicle intrusion detection system based on the Hybrid EfficientNet model. The system combines the lightweight advantages of EfficientNet and advanced hybrid network technology. After special design, it can not only efficiently and accurately distinguish normal traffic from attack traffic, but also meet the convenient operation requirements in the vehicle environment, significantly improve the processing speed and accuracy, and improve the security of the vehicle network. The vehicle intrusion detection system based on the Hybrid EfficientNet model is described in detail below.

[0071] like Figure 1 As shown, the vehicle intrusion detection system based on the Hybrid EfficientNet model provided in this embodiment is obtained by training the Hybrid EfficientNet model; wherein the Hybrid EfficientNet model includes an initial convolution layer (ConvBNActivation), a backbone network, an adaptive global pooling layer (AdaptiveAvgPool), a Flatten layer, a discard layer, a hidden layer, and a classification layer; in addition, the system integrates a hyperparameter optimization function, and uses the Hyperopt library to automatically adjust the batch size, the number of training rounds, and the learning rate to further improve the performance of the model.

[0072] The data input to the input layer of the Hybrid EfficientNet model is a 224x224 pixel image with three channels (RGB). The _make_divisible function is called to adjust the number of channels to ensure that the number of channels is a multiple of 8, thereby optimizing the computational efficiency. The image is then processed by the initial convolution layer (ConvBNActivation); the initial convolution layer is a two-dimensional convolution layer (Conv2d), which is used to extract low-level features of the input image, such as edges, textures, etc. The convolution kernel size of the initial convolution layer is 3x3, and the stride is 2 (stride=2), which reduces the spatial dimension of the input image by half. After the standard convolution operation, the data is batch normalized (BatchNorm2d). The role of batch normalization is to standardize the output features of each channel so that its mean is close to 0 and its variance is close to 1, which can accelerate the training process of the model and make the model more stable to avoid the problem of gradient disappearance or explosion; the output after batch normalization will be processed through a SiLU activation function (also known as Swish Function), the activation function introduces nonlinear transformation, enhances the expressiveness of the model, and enables the model to learn more complex features and patterns;

[0073] After completing the preliminary convolution, batch normalization and activation function processing, the output data will enter the backbone network of the model for further feature extraction according to the configuration parameters. The backbone network consists of 1 FusedMBConv module and 15 MBConv modules. Each module further performs complex operations on the input data to extract higher-level features and gradually reduce the spatial dimension. At the same time, the number of channels of the feature map is increased so that the model can more effectively represent the deep information in the image. The backbone network sets the parameter t. If t=1, the FusedMBConv module is used to process the data; if t≠1, the MBConv module is used to process the data. The specific parameter configuration is as follows:

[0074] t,c,n,s,CBAM;

[0075] 1, 16, 1, 1, 0; FusedMBConv;

[0076] 4, 24, 2, 2, 0; MBConv;

[0077] 4, 40, 2, 2, 0; MBConv;

[0078] 4, 80, 3, 2, 1; MBConv;

[0079] 6,112,3,1,1;MBConv;

[0080] 6, 192, 4, 2, 1; MBConv;

[0081] 6,320,1,1,1;MBConv;

[0082] Among them, c: represents the number of output channels of the module; n: represents the number of times the module is repeated; s: represents the stride of the module; CBAM: represents whether the CBAM module (channel and attention mechanism) is used, 1 represents the use of the CBAM attention mechanism, and 0 represents the non-use of the CBAM attention mechanism;

[0083] The FusedMBConv module is the main module of the shallow network. It is an improved convolution module, which is mainly used to expand and fuse input features. The module combines the operations of convolution, batch normalization and activation function, and integrates spatial and channel information through a single standard convolution.

[0084] Specifically, the FusedMBConv module first performs a 3x3 standard convolution, which is used to extract spatial information and is also responsible for expanding the number of channels (the expansion of the number of channels is directly completed by the 3x3 convolution in order to capture more feature information); after the convolution operation is completed, the output is batch normalized to normalize the activation value of each channel, and then a nonlinear transformation is introduced through the SiLU activation function, so that the model can learn more complex features and patterns. Determine whether the expansion rate is equal to 1. If the expansion rate is 1, the FusedMBConv module only performs a 3x3 standard convolution, followed by batch normalization and SiLU activation and output; if the expansion rate is greater than 1, continue to perform 1x1 convolution to further adjust the input channel, and then perform batch normalization (BatchNorm2d) to ensure that the output of the module can remain stable in terms of value.

[0085] The MBConv module is the main module of the deep network. In addition to the standard convolution and activation operations, it also contains a CBAM (Channel and Spatial Attention Mechanism, also known as Attention Module). The channel and spatial attention mechanism dynamically adjusts the importance of each feature channel, making the network pay more attention to key features while reducing dependence on unimportant features.

[0086] Specifically, the MBConv module includes an expansion layer, a depth-separable convolution module, a channel and spatial attention mechanism, and a projection layer; the expansion layer expands the number of channels of the input feature through 1x1 convolution to ensure that more features can be processed in subsequent convolution operations. The number of input channels in the expansion layer depends on the input, and the number of output channels is determined by the expansion factor t and the number of input channels. The expansion factor t=4, the number of input channels will be expanded to 4 times, usually 6 times the number of input channels, and expanded through 1x1 convolution, with a stride of 1 and padding of 0; after the expansion convolution, the data is also processed by batch normalization and SiLU activation function to ensure that the model can converge stably and quickly;

[0087] The depthwise separable convolution module is divided into depthwise convolution and pointwise convolution. The depthwise convolution is 3x3 convolution. Each convolution kernel only acts on a single channel of the input feature, which greatly reduces the computational cost. The number of input channels is the number of channels after expansion, and the number of output channels is the same as the number of input channels. The stride s is 1 or 2 (set in the parameter configuration), which determines whether the size of the output feature map will be reduced. If the stride is 1, the size of the feature map remains unchanged. If it is 2, the size of the output feature map is halved. The padding is 1. The pointwise convolution is 1x1 convolution. After the depthwise convolution, a 1x1 convolution is used to integrate the features of each position together. The number of input channels is the input channel of the depthwise convolution. The number of output channels is the same as the original number of channels or the number of channels after expansion (the point-by-point convolution restores the number of channels after expansion to the number of output channels c specified in the parameter configuration, which is the final output result), the stride is 1, and the padding is 0; the channel and spatial attention mechanism includes a channel attention mechanism and a spatial attention mechanism, and the channel attention mechanism applies global average pooling and global maximum pooling to the feature map to obtain two different global information representations; then, the two obtained features are processed by two 1x1 convolution layers, and a nonlinear transformation is introduced by a ReLU activation function; then, the two processed feature maps are added and a channel attention coefficient is generated by a Sigmoid activation function; finally, the generated channel attention coefficient is multiplied by the original feature to obtain an enhanced channel feature; after completing the channel attention processing, the feature map is further processed by the spatial attention mechanism;

[0088] The spatial attention mechanism performs average pooling and maximum pooling operations on the feature map on the channel to generate two spatial feature maps; then the two spatial feature maps are spliced ​​together and processed through a convolution layer (3x3 convolution layer), and a spatial attention coefficient is generated through a Sigmoid activation function; finally, the generated spatial attention coefficient is multiplied with the input feature map to obtain the final enhanced spatial feature;

[0089] The projection layer effectively adjusts the number of channels of the feature map through a 1×1 convolution operation to ensure that the number of channels between different modules matches and achieve effective transmission and fusion of information. Specifically, the projection layer first applies a 1×1 convolution with a stride of 1 and no padding to adjust the number of channels of the feature map from the expanded number of channels to the output number of channels required by the module. This process not only integrates cross-channel information and improves the feature representation capability, but also optimizes the computational efficiency of the model by reducing the number of parameters and computational complexity. Subsequently, batch normalization (BatchNorm2d) is performed to ensure that the activation values ​​of the feature map remain numerically stable, accelerate the training process of the model and improve its stability. The design of the projection layer ensures seamless connection of feature maps between different modules, promotes the model's ability to capture complex features, and thus enhances the overall performance and accuracy of the vehicle intrusion detection system.

[0090] The MBConv module of the backbone network uses residual connections. When the number of input channels of the module is the same as the number of output channels and the stride is 1, the model will use residual connections to add the input of the module directly to the output of the module to form a skip connection, thereby retaining some of the original information and enhancing the training effect of the model. After processing all FusedMBConv and MBConv modules, the spatial size of the feature map has been significantly reduced, while the number of channels has increased, forming a higher level of image features;

[0091] In this embodiment, the backbone network uses FusedMBConv and MBConv modules in combination, the purpose is to extract multi-level features at different stages; in the first few layers of the model, the FusedMBConv module is used to extract basic features, which is conducive to reducing the computational complexity; and in deeper layers, the MBConv module is used to enhance the modeling ability of channel and spatial information through the attention mechanism; this combined design can ensure the lightweight of the model while improving its adaptability to complex scenarios (such as different intrusion behavior patterns in vehicle intrusion detection), especially in scenarios requiring high-precision detection, the CBAM attention mechanism in the MBConv module can significantly improve the model's attention to important features. Through the operation of the above-mentioned multiple Fused MBConv and MBConv modules, the spatial dimension of the feature map will gradually shrink from the original input (224, 224) to (112, 112) and (56, 56) after several convolution modules, until the final output feature map size becomes (7, 7). In this process, the model can gradually extract higher-level semantic features, which contain rich spatial and channel information for subsequent classification tasks.

[0092] After multiple convolution operations in the backbone network, the feature map has a large spatial dimension and rich channel information. In order to compress this information into a more compact global feature, an adaptive global pooling layer is introduced in the model, that is, the final output of the backbone network is used as the input of the adaptive global pooling layer (AdaptiveAvgPool). The adaptive global pooling layer is an important module in the convolutional neural network. Its main function is to compress the spatial dimension of the feature map into a fixed output size while keeping the channel information unchanged, thereby generating a global feature vector. In this model, the adaptive global pooling layer fixes the spatial dimension of the output to (1, 1), that is, all spatial dimensions of each channel are compressed into a single scalar value, which is the average value of the pixel values ​​at all spatial positions of the channel.

[0093] Specifically, the output formula of the adaptive global pooling layer can be expressed as:

[0094]

[0095] in: represents the global average pooling output on a specific channel C, is the first i Row, No. j The pixel value of the column; and Represent the height and width of the input feature map respectively.

[0096] Through the above formula, all spatial information in each channel (i.e., each pixel) is averaged and a channel-level scalar is output. The adaptive global pooling layer ensures that no matter what the spatial size of the input feature map is (i.e., different heights H and widths W), the output is always a global feature of each channel, whose size is (B, C, 1, 1), that is, the number of channels C remains unchanged, and each channel contains a global average value B, which represents the global average information of the channel. These values ​​will be passed to the subsequent fully connected layer or classifier for processing;

[0097] The feature map output by the adaptive global pooling layer after pooling is input into the Flatten layer. The Flatten layer is used to convert the multidimensional feature map into a one-dimensional vector (flattened into a one-dimensional vector). The input feature map is converted from (B, C, 1, 1) dimensions to (B, C), that is, all channel features of each sample are flattened into a one-dimensional vector; the size of the expanded feature vector is C, where C represents the number of channels; assuming that the input feature map dimension is (B=4, C=128, 1, 1), after the flattening operation, the feature map will become a matrix of size (B=4, 128);

[0098] The expanded feature vector is gradually compressed into the vector required for classification through the first fully connected layer (also called hidden layer); specifically, the flattened feature vector is mapped to a hidden layer to enhance the expressiveness of the feature; the parameters are: input dimension: number of channels C (such as 128); output dimension: usually set to the number of neurons in the hidden layer (such as 256), the first fully connected layer performs a linear transformation; after the linear transformation, the activation function will introduce nonlinear mapping. The activation function used in this embodiment is SiLU, and the smoothing characteristics of SiLU are more advantageous than ReLU. After passing the activation function, the first fully connected layer is connected to the dropout layer (Dropout, parameter 0.2, that is, the dropout rate is set to 0.2) to reduce overfitting and improve the generalization ability of the model.

[0099] The result processed by the discard layer is input to the second fully connected layer (also called classification layer), which is used to map the extracted high-dimensional global features to the probability space of the output category, thereby completing the classification task of vehicle intrusion detection; its parameters are: input dimension: the number of hidden layer neurons output by the previous layer (such as 256); output dimension: the number of categories num_classes, for example, in the vehicle intrusion detection task, there are 5 categories (num_classes=5);

[0100] Let the eigenvector be , the weight matrix of the classification layer is W and the bias term b , then the output of the classification layer can be expressed as:

[0101]

[0102] in: z is the output of the classification layer, that is, the score corresponding to each category; W is a weight matrix of dimension N×C, where N is the number of categories and C is the dimension of the feature vector (i.e., the number of output channels of the adaptive global pooling layer); is the global eigenvector of the input; b is a bias term of dimension N;

[0103] After obtaining the output of the classification layer, the output is converted into a probability distribution through the softmax function. The sum of the probabilities of all categories is 1. The formula of the softmax function is:

[0104]

[0105] in: is the input sample Belong to Probability of class; is the output of the classification layer The score of the class, is the output of the classification layer The score of the class; through the softmax function, the model generates a probability distribution for each category, and the output dimension is N, which indicates the probability that the input data belongs to each category.

[0106]

[0107] This means that the model will select the category y with the highest probability as the prediction result based on the probability value output by softmax.

[0108] The specific training steps are as follows:

[0109] Step S1. Select the vehicle data set Car-Hacking as the vehicle internal data set, and use a series of methods to convert it into a data form that can be processed by the Hybrid EfficientNet model;

[0110] The Car-Hacking dataset is an open dataset specifically used to study vehicle network security. It mainly collects various network attacks that may be suffered in the internal system of the vehicle. This dataset is designed for the internal control network (CAN bus) of the vehicle and can accurately reflect the real traffic in the vehicle network environment. Compared with traditional network intrusion detection datasets (such as KDD, NSL-KDD, etc.), the Car-Hacking dataset is more suitable for the communication scenarios inside the vehicle, especially the data structure and communication behavior under the automotive CAN bus protocol.

[0111] The Car-Hacking dataset covers a variety of typical car network attack types, such as Denial of Service (DoS), Fuzzy, RAM-Spoofing, and Gear-Spoofing. The specific information of each attack is shown in Table 1:

[0112] Table 1: The number of various labels in the Car-Hacking dataset

[0113] Category Label quantity Normal data (R) 701,832 RAM 32,539 Gear 29,944 DoS 29,501 Fuzzy 24,624

[0114] For the original Car-Hacking dataset obtained, this embodiment performs the following processing:

[0115] Step S101. Sampling the original Car-Hacking dataset;

[0116] Compared with the traditional random sampling method without replacement, the preprocessing of this embodiment introduces a multi-level sampling strategy to further improve the representativeness and sampling quality of the data set. For the labels 'R', 'Fuzzy', 'RAM', 'Gear', 'DoS' and other categories in the vehicle data, different sampling ratios (30%, 60%, 65%, 65%, 70% respectively) are used to balance the sample data of each category in a more refined manner. Through this sampling strategy, the differences between categories are effectively retained, while the risk of information loss is reduced, and the sampled data is finally indexed and sorted.

[0117] Step S102: Perform outlier detection on the sampled data set after dimensionality reduction;

[0118] First, the code reads the data and normalizes the numerical features to ensure that all values ​​are on the same scale (between 0 and 1). The normalized data fills any missing values, removes the Label column in the data, and retains other features for subsequent improved Autoencoder model training. The dimensionality of the input data depends on the number of features, prepares the input layer, and starts building the improved Autoencoder model;

[0119] Autoencoder is an unsupervised neural network, commonly used for dimensionality reduction and feature learning; its basic structure includes an Encoder and a Decoder. The Encoder maps the original data to a low-dimensional space (gradually reducing the dimension of the input data to a smaller bottleneck layer (32 dimensions), and compressing the features through a fully connected layer), and the Decoder attempts to reconstruct the original data from the low-dimensional space (gradually restoring the compressed features to the original input data, and using the sigmoid function to output the reconstruction results).

[0120] The optimization goal of Autoencoder is to minimize the input data and rebuild data The mean squared error (MSE) between them is used to train the Autoencoder by minimizing the reconstruction error (MSE) to ensure that the model can effectively compress and reconstruct normal data:

[0121]

[0122] In the formula, the data input to the input layer is the original feature , with a dimension of n; the Encoder gradually reduces the data dimension to the bottleneck layer through a multi-layer neural network, and the output of the bottleneck layer is a low-dimensional potential feature Z; the Decoder attempts to reconstruct the input data from Z ;

[0123] In this embodiment, in order to prevent overfitting, BatchNormalization and Dropout layers are added to the network during the dimensionality reduction preprocessing of Autoencoder. At the same time, the Early Stopping strategy is used to monitor the loss of the validation set to avoid overtraining of the model. The hyperparameters of network training are set as follows: the batch size is 256 and the maximum number of iterations is 100 rounds.

[0124] Specifically, Figure 2 As shown, in this embodiment, the improved Autoencoder model includes an input layer (Input Layer) arranged in sequence, a first fully connected layer (Dense, with 256 neurons for extracting features from the input data of the previous layer, relu activation function), a first normalization layer (Batch Normalization), a first Dropout layer (ratio 0.3, representing that 30% of the neuron outputs will be randomly discarded during each training), a second fully connected layer (Dense, 128 neurons, relu activation function), a second batch normalization layer (BatchNormalization), a second Dropout layer (ratio 0.3), a third fully connected layer (Dense, 64 neurons, relu activation function), a third batch normalization layer (BatchNormalization), a third Dropout layer (ratio 0.3), a fourth fully connected layer (Dense, 32 neurons, relu activation function, also known as the bottleneck layer Bottleneck, is the last layer of the encoder, located at the end of the data from high dimensionality to low dimensionality, through the bottleneck layer, the input data is compressed into 32 dimension, retaining the most important feature information while discarding redundancy and noise), the fifth fully connected layer (Dense, 64 neurons, relu activation function), the fourth batch normalization layer (BatchNormalization), the sixth fully connected layer (Dense, 128 neurons, relu activation function), the fifth batch normalization layer (BatchNormalization), the seventh fully connected layer (Dense 256 neurons, relu activation function), the sixth batch normalization layer (BatchNormalization), the eighth fully connected layer (Dense, input dimension input_dim, sigmoid activation function, is the last layer of the decoder, and outputs a reconstructed data with the same dimension as the input data.

[0125] This embodiment compresses high-dimensional data into a low-dimensional latent space through the Autoencoder dimensionality reduction model, generates low-dimensional features, enhances the ability of feature extraction, and reduces the interference of redundant information and noise. In addition, for the sampled data, there are some outliers, which will have a certain negative impact on the training results of the Hybrid EfficientNet model. Therefore, the isolation forest algorithm is introduced in the feature space after the Autoencoder dimensionality reduction to detect and delete outliers in the data set.

[0126] Isolation forest anomaly detection framework Figure 2 As shown in the figure, the data Z after dimensionality reduction by Autoencoder is used as input, and the isolation forest algorithm is applied for outlier detection. Isolation forest is an unsupervised learning method based on random trees, which is suitable for efficient detection of outliers. Its core idea is to isolate abnormal points from normal points by randomly splitting the feature space. Isolation forest divides the data space by constructing multiple random trees, and uses the depth of the tree to quantify the degree of abnormality of the data point. A shorter path length means that the data point is easy to be isolated and is therefore more likely to be an outlier. Conversely, a longer path length means that the data point is more common in the data set and is less likely to be an abnormality.

[0127] Each tree in an isolation forest is constructed in the following way:

[0128] Randomly select a feature q; randomly select a split point p on feature q to divide the data set into two subsets; repeat this process until each data point is separated individually.

[0129] For data points The calculation of the anomaly score depends on its average path length , that is, the path length from the root to the leaf node, the anomaly score of the data point can be expressed by the following formula:

[0130]

[0131] in: It is a data point Average path lengths across multiple trees; is a normalizing constant for path length, given a dataset of size :

[0132]

[0133] in, is a harmonic number, defined as:

[0134]

[0135] In this preprocessing, the hyperparameters of the isolation forest algorithm are set as follows: the number of trees (n_estimators) is 100, and the proportion of outliers (contamination) is set to 18%.

[0136] Determination and deletion of outlier thresholds:

[0137] The anomaly scores detected by Isolation Forest are normalized and scaled to the range of [0, 1].

[0138] According to the statistical information of the anomaly score, a threshold is set to filter out the outliers. The threshold used this time is the 95% quantile of the anomaly score. The data points with scores exceeding the threshold are marked as outliers. After removing these data points, the cleaned data set is obtained.

[0139] In this embodiment, the high-dimensional features are compressed into a low-dimensional space through the dimensionality reduction of the Autoencoder, so that the isolation forest algorithm can perform anomaly detection more efficiently, reducing the redundant features and noise that may exist in the high-dimensional feature space. The features after dimensionality reduction are more representative, so that the isolation forest algorithm can more accurately distinguish between normal points and abnormal points, especially for complex data distribution. The anomaly detection effect is significantly improved. Combined with the quantile setting threshold method, the outlier screening criteria can be dynamically adjusted according to the data distribution, avoiding the inadaptability problem that may be caused by the fixed threshold.

[0140] In this embodiment, the number of data set samples after outlier detection is shown in Table 2.

[0141] Table 2: The amount of various label data after outlier detection

[0142] Category Label quantity Normal data (R) 205,544 RAM 21,150 Gear 20,651 DoS 19,464 Fuzzy 5,465

[0143] Step S103. Oversampling

[0144] After deleting the outliers, the dataset has a class imbalance problem. To solve this problem, the oversampling technology combining SMOTE and ADASYN is used. Not only is the label 'Fuzzy' oversampled, but the number of samples between categories is further balanced. Compared with the traditional SMOTE method, after adding ADASYN, the system can dynamically adjust the sampling strategy according to the sample distribution, enhancing the adaptability to complex data distribution. In this embodiment, the number of samples of the label 'Fuzzy' is precisely controlled and oversampled to the average number of samples of the labels 'RPM', 'Gear' and 'DoS'. This makes the classifier's learning of minority categories more balanced, effectively reducing the deviation in the training process.

[0145] SMOTE (Synthetic Minority Over-sampling Technique) is a classic oversampling method that increases the number of minority class samples by generating new samples. Its main idea is to generate new synthetic samples through interpolation based on the neighborhood relationship of minority class samples.

[0146] The specific process is as follows:

[0147] First, for each sample in the minority class , select one of its k nearest neighbor samples (where k is a user-specified parameter);

[0148] Afterwards, the selected nearest neighbor samples ,exist and Randomly select a point on the line segment between and generate a new synthetic sample .

[0149] The formula for SMOTE to generate new samples is as follows:

[0150]

[0151] Among them, λ is a uniformly distributed random number, λ∈[0,1], which ensures that the generated new samples are located in and Somewhere in between.

[0152] ADASYN (Adaptive Synthetic Sampling) is an improved oversampling method. Unlike SMOTE, ADASYN dynamically adjusts the generation ratio of synthetic samples according to the distribution of samples. Its core idea is to determine the number of new samples to be generated based on the distribution density of minority class samples in the feature space. The lower the distribution density, the more new samples will be generated to make up for the imbalance between the distribution of minority class samples and majority class samples.

[0153] The specific process is as follows:

[0154] First, for each minority class sample , calculate the number of samples belonging to the majority category among its k nearest neighbor samples , calculate the proportion distribution of all minority class samples ;

[0155] Then, according to The value determines the number of synthetic samples generated for each minority class sample :

[0156]

[0157] Among them, G is the total number of synthetic samples and N is the total number of minority class samples.

[0158] In this embodiment, the oversampling strategy combining SMOTE and ADASYN is as follows:

[0159] In this preprocessing, in order to address the case of class imbalance, SMOTE was first used to oversample the minority categories labeled "Fuzzy". However, in order to avoid inaccurate data samples introduced by oversampling, ADASYN was also introduced to dynamically adjust the sampling process to ensure the balance of the data and the representativeness of the synthetic samples.

[0160] In the specific application, the number of samples with labels "RAM", "Gear" and "DoS" is first counted, and their average value is calculated; then, a sampling strategy is set to oversample the samples with the "Fuzzy" label to the average number of samples through SMOTE.

[0161] The number of new samples generated by SMOTE :

[0162]

[0163] For each sample generated, ADASYN technology is further applied to dynamically adjust the distribution of new sample generation according to the neighborhood distribution of the majority category. Compared with the single SMOTE method, combined with ADASYN technology, oversampling can generate samples more intelligently, especially in the distribution area of ​​minority categories. It can dynamically adjust the number of generated samples according to data density, reduce the possibility of generating new samples that are too concentrated, enhance the diversity and rationality of synthetic samples, and make the oversampled data more balanced, so that the classifier's learning ability for each category is significantly improved, especially when dealing with unbalanced data sets. By increasing the number of samples of minority categories, the classifier can better capture its characteristics, thereby improving the generalization ability and accuracy of the model.

[0164] After the above steps, the amount of processed label data is shown in Table 3:

[0165] Table 3: Amount of data for each type of label after oversampling

[0166] Category Label quantity Normal data (R) 205,544 RAM 21,150 Gear 20,651 DoS 20,421 Fuzzy 19,464

[0167] Step S104: performing feature selection;

[0168] All features and label columns are read from the dataset, and LabelEncoder is used to convert the label column (Label) into a numerical form so that correlation calculations can be performed with the numerical features. Then, the mutual information (Mutual Information) between each feature and the label is calculated through the mutual_info_classif function. The mutual information measures the dependency between the feature and the label. The higher the score, the stronger the predictive ability of the feature for the label. Next, the calculated mutual information scores are stored in a DataFrame and sorted from high to low according to the score to identify important features. Subsequently, by setting a mutual information score threshold (for example, 0.2), features with scores higher than the threshold are filtered out, which have a strong correlation with the label. Finally, a new dataset is created using these filtered high-correlation features, retaining these features and label columns for subsequent modeling; this process can effectively reduce irrelevant or redundant features and improve the performance and prediction effect of the model.

[0169] In this embodiment, a feature selection method based on mutual information is introduced. Mutual information measures the information gain between each feature and the target label to ensure that the retained features are highly correlated with the model output. Finally, features with mutual information scores higher than 0.2 are screened out, and irrelevant or noise features are deleted, thereby further optimizing the model performance.

[0170] The basic principle of mutual information feature selection is:

[0171] Mutual information is an indicator used to measure the correlation between two variables. It can reflect how much information about the target variable is contained in a feature. Mutual information not only considers linear relationships, but also captures nonlinear relationships. For each feature X and target variable Y, their mutual information I(X;Y) Calculated by the following formula:

[0172]

[0173] in: Represents the joint probability distribution of feature X and target variable Y; and They represent the marginal probability distribution of feature X and target variable Y respectively.

[0174] The larger the mutual information value is, the stronger the correlation between feature X and target Y is, that is, the greater the contribution of the feature to the classification task; therefore, the most useful features for the classification task can be screened out by the mutual information value.

[0175] In this embodiment, the specific steps of feature selection are as follows:

[0176] Step S1041: First, perform feature selection on the processed data set and calculate the mutual information between each feature and the target label.

[0177] The mutual information calculation function is defined by mutual_info_classif Implemented and generates a list of mutual information scores.

[0178] The calculation result of the mutual information score can be expressed as:

[0179]

[0180] in, It is i features, Y is the target label, ;

[0181] Step S1042: Sort the mutual information scores and filter out features whose mutual information scores are greater than a threshold (the threshold set in this process is 0.2).

[0182] Step S1043: The features screened out by the above method are considered to have significant contributions to the classification task and are used for subsequent data processing and model training. These features will be recombined with the labels into a new data set for training.

[0183] Through this process, noise features or redundant features can be effectively removed, and only features that contribute significantly to the target variable are retained.

[0184] Step S105. After the feature selection is completed, the selected features will be standardized and scaled to adapt to the subsequent image conversion process. The specific steps are as follows:

[0185] First, the selected features are normalized and the feature values ​​are converted to the range [0, 1] using QuantileTransformer;

[0186] Secondly, in order to ensure that the image format after data conversion is adapted to the model input, this embodiment adopts a normalization method based on quantile transformation to ensure the stability of data distribution and avoid interference from extreme values.

[0187] Quantile transformation is a normalization method based on the cumulative distribution function (CDF) that can map data samples to a specified range (such as [0, 255]) and make the distribution of data close to the normal distribution. The advantage of quantile transformation is that it is insensitive to extreme values ​​and can maintain a stable transformation effect when there are outliers in the data.

[0188] The formula for the quantile transformation is as follows:

[0189]

[0190] in: is the eigenvalue after quantile transformation, It is a feature The cumulative distribution function (CDF) of The probability that the median is less than or equal to a certain value; is the inverse cumulative distribution function, which is used to map the data samples to the desired range.

[0191] In this data processing, the eigenvalue Converted to pixel values ​​between 0 and 255 to fit the image format:

[0192]

[0193] in, is the eigenvalue after quantile transformation and linear scaling, and its range is standardized to between 0 and 255. It is a feature The minimum value of It is a feature The maximum value of

[0194] Through this transformation, the numerical eigenvalues ​​can be adjusted to the pixel value range of the image data, maintaining the data distribution while making it more suitable for the characteristics of the deep learning model. Compared with traditional normalization, this quantile transformation has a stronger ability to resist extreme value interference and helps to maintain the balance of data distribution.

[0195] Step S2. The data set processed in step S1 is converted and saved into multiple sets of image data sets according to the labels, and the data samples are converted into blocks according to the timestamp and feature size of the data set.

[0196] In this embodiment, in order to better utilize the image classification model and convert the numerical features into a suitable image format, 9 important features (such as CAN ID and DATA[0]-DATA[7]) are selected, and every 27 consecutive data blocks are converted into a 9x9x3 three-dimensional array. Compared with the traditional representation of numerical features, image conversion not only enhances the visualization ability of data, but also enables the present invention to apply a more powerful convolutional neural network (CNN) model; the specific steps are as follows:

[0197] Feature number selection: The present invention selects 9 features, denoted as F1, F2, ..., F9, and each feature value represents a data dimension.

[0198] Continuous data block: The present invention groups 27 consecutive samples into a data block, so each data block contains 9×27=243 eigenvalues;

[0199] Reshape into a 3D array: Reshape the 243 eigenvalues ​​into a 9×9×3 3D array whose format corresponds to the height, width, and color channels in the image. This 3D array can be used directly as input for image data.

[0200] In order to enhance the applicability of the data, the present invention also converts the three-dimensional array into a NumPy array and specifies the data type as an unsigned 8-bit integer (ie, a pixel value range of 0-255).

[0201] After the data block is converted into an image, it needs to be adjusted to the input size that adapts to the deep learning model. In order to adapt the model, the image size is adjusted to 224x224 pixels. Finally, the processed image data set is stored separately according to the label category. In order to ensure the generalization ability of the model, in this data processing, the training set and the test set are divided according to the ratio of 80%:20%.

[0202] Step S3. The training data set and test data set processed in step S2 are passed into the built HybridEfficientNet model for training;

[0203] Step S301. Input the processed data into the Hybrid EfficientNet intrusion detection model. Before the final training and evaluation of the model, the divided data set is optimized using the Hybrid EfficientNet model for hyperparameters. The optimization method used is the Tree Parzen Estimator (TPE) hyperparameter optimization scheme, which is an algorithm for Bayesian optimization. The hyperparameter search space includes batch size, number of iterations, and learning rate. During the optimization process, training is performed on 80% of the training set and evaluation is performed on 20% of the validation set to select the best hyperparameter configuration, and 5 iterations of patience are used for early stopping to prevent overfitting.

[0204] The Tree Parzen Estimator (TPE) hyperparameter optimization scheme models the distribution of good (low loss) and bad (high loss) configurations by maintaining two conditional probability density functions (PDFs). The formula for TPE to calculate the conditional probability ratio is as follows:

[0205]

[0206] in, Indicates new configuration The relative likelihood between good and bad configurations, the PDF( ,in indicates lower loss and bad configuration), bad configuration PDF( ,in indicates higher losses).

[0207] After obtaining the optimal hyperparameter combination, the optimal hyperparameter combination is evaluated on the HybridEfficientNet model. Usually, indicators such as accuracy, precision, recall rate, and F1 score are used to measure the evaluation results to ensure that the performance of the model on different data sets is consistent. The calculation methods of accuracy, precision, recall rate, and F1 score are as follows:

[0208]

[0209]

[0210]

[0211]

[0212] Among them, TP is the number of positive classes predicted as positive, FN is the number of positive classes predicted as negative, FP is the number of negative classes predicted as positive, and TN is the number of negative classes predicted as negative.

[0213] Step S302: Use the optimal hyperparameters obtained on the test set to perform final model evaluation on the HybridEfficientNet model.

[0214] Furthermore, in this embodiment, when the model processes data, for the input data, the data set is first loaded through the torchvision.datasets.ImageFolder function; secondly, in the process of processing the training data, the model applies a series of data enhancement operations, which are mainly to increase the diversity of the data and improve the generalization ability of the model to avoid overfitting; the enhancement operations include:

[0215] (1) Use transforms.Resize to resize the input image to the target size (224, 224) to ensure that all input images have the same size for easy model processing;

[0216] (2) Randomly apply horizontal flipping operations on training data to enhance the model’s robustness to images in different orientations;

[0217] (3) Randomly rotate the image by 0 to 10 degrees to further enhance the diversity of the data and allow the model to learn to be robust to slight changes in perspective;

[0218] (4) Use the transforms.ToTensor operation to convert the image from the PIL (Python Imaging Library) format to a tensor format that PyTorch can process; at the same time, adjust the channel order of the image to (C, H, W), that is, the number of channels is at the front.

[0219] The model processes data as follows:

[0220] Step 1. Input the processed data into the model, and perform feature extraction in the initial convolutional layer;

[0221] Step 2. The FusedMBConv and MBConv modules in the backbone network perform deeper feature extraction. This step aims to gradually reduce the spatial dimension of the feature map and enhance the expression ability of channel and spatial information through the attention mechanism.

[0222] Step 3. The adaptive average pooling layer reduces the spatial dimension of the feature map to a fixed output size, that is, all spatial information in each channel is compressed into one value.

[0223] Step 4. Flatten the feature map after adaptive average pooling into a one-dimensional vector and process it through a fully connected layer for final classification.

[0224] Experimental Results

[0225] The present invention tests multiple models such as HybridEfficientNet, ResNet54ViT, and ResNet54ViT on the Car-Hacking dataset. The test results are displayed in terms of accuracy, precision, recall, F1 score, and model space occupied. The results are shown in Tables 4 and 5.

[0226] Table 4: Experimental and evaluation indicators:

[0227]

[0228] Table 5: Model comparison results

[0229] Model Accuracy Recall Accuracy Average batch processing time ResNet54ViT 99.20% 99.21% 99.15% 98 ms EfficientNet-B0 97.46% 97.46% 97.47% 15 ms ShuffleNetV2 96.04% 96.02% 96.10% 8 ms MoblieNetV3 98.25% 98.19% 98.21% 11 ms HybridEfficientNet 100% 100% 100% 7.68 ms

[0230] In Table 4, the most effective hyperparameter combination of the present invention is: batch size = 4, number of iterations = 5, learning rate = 0.035088821401703926. Under this set of hyperparameters, the final accuracy, precision, recall, and F1 score are all 100%, and each category is also 100% in terms of precision, recall, F1 score and other indicators, with good model performance. In terms of the space occupied by the model, it occupies 15.60MB, which meets the vehicle's need for lightweight and is more suitable for vehicle mobile equipment. Therefore, Hybrid EfficientNet has a good performance effect in vehicle intrusion detection.

[0231] In Table 5, Hybrid EfficientNet performs best, with accuracy, recall, and precision all reaching 100%, and an average batch processing time of 7.68 milliseconds, showing its excellent performance in classification tasks. It is followed by ResNet54 ViT, with an accuracy of 99.20%, a recall of 99.21%, a precision of 99.15%, and a processing time of 98 milliseconds, showing strong competitiveness. MobileNet V3 also performed well, with an accuracy of 98.25% and an average processing time of 11 milliseconds, but it is slightly inferior to the previous two. EfficientNet-B0 and ShuffleNet V2 performed relatively poorly, especially ShuffleNet V2, with an accuracy of only 96.04%, despite its faster batch processing speed. Overall, HybridEfficientNet has obvious advantages in both accuracy and processing efficiency.

[0232] In summary, the vehicle intrusion detection system based on the Hybrid EfficientNet model proposed in the present invention can effectively solve the problem of malicious traffic intrusion in the Internet of Vehicles, and can effectively ensure the safety of vehicle driving during vehicle driving.

[0233] This embodiment provides a vehicle intrusion detection method based on the Hybrid EfficientNet model, and the method includes the following steps:

[0234] Step 1. Receive CAN traffic data in real time;

[0235] Step 2. Preprocess the CAN traffic data, normalize it and convert it into image data;

[0236] Step 3. Input the converted image data into the Hybrid EfficientNet model (vehicle intrusion detection system based on the Hybrid EfficientNet model) trained in Example 1;

[0237] Step 4. The trained Hybrid EfficientNet model (vehicle intrusion detection system based on the Hybrid EfficientNet model) identifies and classifies the CAN traffic data received in real time and outputs the classification results;

[0238] Step 5. Based on the classification results, determine the intrusion detection results.

[0239] The present invention also provides an electronic device, comprising: one or more processors and a memory; wherein the memory is used to store one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors implement the vehicle intrusion detection method based on the Hybrid EfficientNet model described in Example 2.

[0240] The present invention also provides a computer-readable medium having a computer program stored thereon, and when the computer program is executed by a processor, the vehicle intrusion detection method based on the Hybrid EfficientNet model described in Example 2 is implemented.

[0241] Those skilled in the art will appreciate that all or part of the functions of the various methods / modules in the above embodiments may be implemented by hardware or by computer programs. When all or part of the functions in the above embodiments are implemented by computer programs, the program may be stored in a computer-readable storage medium, which may include: a read-only memory, a random access memory, a disk, an optical disk, a hard disk, etc. The program is executed by a computer to implement the above functions. For example, the program is stored in the memory of the device, and when the program in the memory is executed by the processor, all or part of the above functions can be implemented.

[0242] In addition, when all or part of the functions in the above-mentioned embodiments are implemented by means of a computer program, the program can also be stored in a storage medium such as a server, another computer, a disk, an optical disk, a flash drive or a mobile hard disk, and saved to the memory of a local device by downloading or copying, or the system of the local device is updated. When the program in the memory is executed by the processor, all or part of the functions in the above-mentioned embodiments can be implemented.

[0243] The above specific examples are used to illustrate the present invention, which is only used to help understand the present invention and is not intended to limit the present invention. For those skilled in the art of the present invention, according to the idea of ​​the present invention, some simple deductions, deformations or substitutions can be made. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.

Claims

1. A vehicle network intrusion detection system based on the Hybrid EfficientNet model, characterized in that: The system is obtained by training the Hybrid EfficientNet model; wherein the Hybrid EfficientNet model includes an initial convolution layer, a backbone network, an adaptive global pooling layer, a Flatten layer, a discard layer, a hidden layer, and a classification layer; the data input to the input layer of the Hybrid EfficientNet model is an image with three channels, and the image is processed by the initial convolution layer, which is a two-dimensional convolution layer for extracting low-level features of the input image, performing batch normalization and SiLU activation function processing on the data after standard convolution operation, and then outputting the output data, and the output data is selected to enter the backbone network for further feature extraction according to the configuration parameters; The backbone network consists of 1 FusedMBConv module and 15 MBConv modules. The backbone network sets the parameter t. If t=1, the FusedMBConv module is used to process the data; if t≠1, the MBConv module is used to process the data. The specific parameter configuration is as follows: t,c,n,s,CBAM; 1, 16, 1, 1, 0; FusedMBConv; 4, 24, 2, 2, 0; MBConv; 4, 40, 2, 2, 0; MBConv; 4, 80, 3, 2, 1; MBConv; 6,112,3,1,1;MBConv; 6, 192, 4, 2, 1; MBConv; 6,320,1,1,1;MBConv; Where c: indicates the number of output channels of the module; n: indicates the number of times the module is repeated; s: indicates the stride of the module; CBAM: indicates whether the CBAM module is used, 1 indicates the use of the CBAM attention mechanism, and 0 indicates that the CBAM attention mechanism is not used; The FusedMBConv module is used to expand and fuse input features. It first performs a 3x3 standard convolution to extract spatial information and expand the number of channels. It then performs batch normalization and SiLU activation function processing. For the output after activation, it determines whether the expansion rate is equal to 1. If the expansion rate is 1, it is directly output; if the expansion rate is greater than 1, it continues to perform a 1x1 convolution, and then performs batch normalization before output; The MBConv module includes an expansion layer, a depth-separable convolution module, a channel and spatial attention mechanism, and a projection layer; the expansion layer is used to expand the number of channels of the input features, the number of output channels in the expansion layer is determined by the expansion factor t and the number of input channels, and the data after the expansion convolution is processed by batch normalization and SiLU activation function; The depthwise separable convolution module is divided into depthwise convolution and pointwise convolution. The number of input channels of depthwise convolution is the number of channels after expansion, and the number of output channels is consistent with the number of input channels. The stride s is 1 or 2, which is set in the parameter configuration. The number of input channels of pointwise convolution is the number of output channels of depthwise convolution, and the number of output channels c is set in the parameter configuration, which is the same as the original number of channels or the number of channels after expansion. The channel and space attention mechanism includes a channel attention mechanism and a space attention mechanism, wherein the channel attention mechanism is used to multiply the generated channel attention coefficient with the original feature to obtain an enhanced channel feature; the space attention mechanism is used to multiply the generated space attention coefficient with the input feature map to obtain a final enhanced space feature; The projection layer is used to adjust the number of channels of the feature map to ensure that the number of channels between different modules matches, and then output after batch normalization operation; The MBConv module uses residual connection inside. When the number of input channels of the MBConv module is the same as the number of output channels and the stride s is 1, the residual connection is used to directly add the input of the module to the output of the module. The adaptive global pooling layer is used to compress the spatial dimension of the feature map into a fixed output size while keeping the channel information unchanged, thereby generating a global feature vector; The Flatten layer is used to convert the multi-dimensional feature map into a one-dimensional vector; The hidden layer is the first fully connected layer, and the expanded feature vector is gradually compressed into a vector required for classification through the first fully connected layer; The classification layer is the second fully connected layer, which is used to map the extracted high-dimensional global features to the probability space of the output category to complete the classification task of vehicle intrusion detection; The specific steps for training the Hybrid EfficientNet model are: Step S1. Select the vehicle data set Car-Hacking as the vehicle internal data set, and convert it into a data form that can be processed by the Hybrid EfficientNet model by preprocessing the data; Step S2. converting the data set processed in step S1 into multiple sets of image data sets according to the labels; The data samples are converted into data blocks according to the timestamp and feature size of the dataset, and then the data blocks are converted into images, and the training dataset and test dataset are divided proportionally; Step S3. The training data set and test data set processed in step S2 are passed into the built HybridEfficientNet model for training; Wherein, step S1 specifically includes the following steps: Step S101. Sampling the original Car-Hacking dataset; For the labels ‘R’, ‘Fuzzy’, ‘RAM’, ‘Gear’, and ‘DoS’ in the vehicle data, sampling is performed at the ratio of 30%, 60%, 65%, 65%, and 70%, respectively; Step S102: Perform outlier detection on the sampled data set after dimensionality reduction; An improved Autoencoder model is used to perform dimensionality reduction processing, compressing high-dimensional data into a low-dimensional latent space to generate low-dimensional features, and then an isolation forest algorithm is applied to perform outlier detection; batch normalization and Dropout layers are added to the improved Autoencoder model; Step S103. Oversampling; Use SMOTE to oversample the samples labeled 'Fuzzy' to the average number of samples of the labels 'RPM', 'Gear', and 'DoS'; then, for each generated sample, use ADASYN to dynamically adjust the generation ratio of synthetic samples; Step S104: performing feature selection; The feature selection method based on mutual information screens out features with mutual information scores higher than 0.2; Step S105. After completing feature selection, the selected features are standardized and scaled; Firstly, the selected features are normalized and the feature values ​​are converted to the interval [0, 1]. Secondly, a normalization method based on quantile transformation is adopted to map the data samples to the range [0, 255] to adapt to the image format.

2. According to claim 1, a vehicle network intrusion detection system based on the Hybrid EfficientNet model is characterized in that: The convolution kernel size of the initial convolution layer is 3x3, with a stride of 2; the number of output channels of the expansion layer is 6 times the number of input channels, which is expanded by 1x1 convolution with a stride of 1 and padding of 0; the depthwise convolution is 3x3 convolution, and the point-by-point convolution is 1x1 convolution; the projection layer effectively adjusts the number of channels of the feature map through a 1×1 convolution operation with a stride of 1 and no padding; the spatial dimension of the output of the adaptive global pooling layer is fixed to (1, 1); the first fully connected layer performs a linear transformation, and after the linear transformation, the SiLU activation function is used; the drop rate of the drop layer is set to 0.

2.

3. The vehicle network intrusion detection system based on the Hybrid EfficientNet model according to claim 2, characterized in that: The channel attention mechanism applies global average pooling and global maximum pooling to the feature map to obtain two different global information representations; the two features obtained are then processed through two 1x1 convolutional layers, and nonlinear transformations are introduced through the ReLU activation function; Then, the two processed feature maps are added and the channel attention coefficient is generated through the Sigmoid activation function; finally, the generated channel attention coefficient is multiplied with the original feature to obtain the enhanced channel feature; after completing the channel attention processing, the feature map is further processed through the spatial attention mechanism.

4. The vehicle network intrusion detection system based on the Hybrid EfficientNet model according to claim 3 is characterized in that: The spatial attention mechanism performs channel-wise average pooling and maximum pooling operations on the feature map to generate two spatial feature maps; then the two spatial feature maps are concatenated together and processed through a 3x3 convolutional layer, and a spatial attention coefficient is generated through a Sigmoid activation function; finally, the generated spatial attention coefficient is multiplied by the input feature map to obtain the final enhanced spatial feature.

5. The vehicle network intrusion detection system based on the Hybrid EfficientNet model according to claim 1, characterized in that: The specific steps of step S2 are as follows: 9 important features are selected, namely CAN ID and DATA[0]-DATA[7], and every 27 consecutive samples are grouped into a data block. Each data block contains 9×27=243 eigenvalues. The 243 eigenvalues ​​are reshaped into a 9x9x3 three-dimensional array. The format of the three-dimensional array corresponds to the height, width and color channels in the image and is used as the input of the image data.

6. The vehicle network intrusion detection system based on the Hybrid EfficientNet model according to claim 1, characterized in that: When the step S3 is trained, the processed data is input into the Hybrid EfficientNet model. Before the model is finally trained and evaluated, the data set and the Hybrid EfficientNet model are first called by the tree-shaped Parzen estimator hyperparameter optimization method to find the best hyperparameter combination suitable for the Hybrid EfficientNet model; after obtaining the optimal hyperparameter combination, the obtained optimal hyperparameter combination is evaluated.

7. The vehicle network intrusion detection system based on the Hybrid EfficientNet model according to claim 1, characterized in that: The improved Autoencoder model includes an input layer arranged in sequence; a first fully connected layer with 256 neurons and a relu activation function; a first normalization layer; a first Dropout layer with a ratio of 0.3; a second fully connected layer with 128 neurons and a relu activation function; a second normalization layer; a second Dropout layer with a ratio of 0.3; a third fully connected layer with 64 neurons and a relu activation function; a third normalization layer; a third Dropout layer with a ratio of 0.3; a fourth fully connected layer with 32 neurons and a relu activation function, the fourth fully connected layer is a bottleneck layer and is the last layer of the encoder; a fifth fully connected layer with 64 neurons and a relu activation function; a fourth normalization layer; a sixth fully connected layer, There are 128 neurons and relu activation function; the fifth batch normalization layer; the seventh fully connected layer has 256 neurons and relu activation function; the sixth batch normalization layer; the eighth fully connected layer is the last layer of the decoder, which outputs a reconstructed data with the same dimension as the input data; the hyperparameters of network training are set as follows: batch size is 256 and the maximum number of iterations is 100 rounds.

8. A vehicle intrusion detection method based on the Hybrid EfficientNet model, characterized in that: The method comprises the following steps: Step 1. Receive CAN traffic data in real time; Step 2. Preprocess the CAN traffic data, normalize it and convert it into image data; Step 3. Input the converted image data into the vehicle intrusion detection system based on the HybridEfficientNet model according to any one of claims 1 to 7; Step 4. The vehicle intrusion detection system based on the Hybrid EfficientNet model identifies and classifies the CAN traffic data received in real time and outputs the classification results; Step 5. Based on the classification results, determine the intrusion detection results.