WSN anomaly detection method fusing time-frequency characteristics and space-time correlation

By constructing a WSN anomaly detection network using dynamic graph data and using timing decomposition, trend encoder, and seasonal encoder, the discrete wavelet transformation and frequency domain attention mechanism are used to solve the problem of low accuracy of WSN anomaly detection method, and improve the Inspection accuracy and efficiency.

CN118890626APending Publication Date: 2024-11-01GUILIN UNIV OF ELECTRONIC TECH
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410928219.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-11
Publication Date
2024-11-01

AI Technical Summary

Technical Problem

The existing WSN anomaly detection methods have shortcomings in capturing long-term dependencies, extracting spatiotemporal structural features, and processing multi-node timing data correlation anomalies, and their accuracy is not high.

Method used

Using WSN anomaly detection method that integrates time-frequency characteristics and spatiotemporal correlation, a wireless sensor anomaly detection network composed of a time series decomposer, trend encoder, seasonal encoder and decoder are used to utilize discrete wavelet transformation and The frequency domain attention mechanism extracts features, adaptively adjusts spatial dependencies and handles frequency domain differences.

Benefits of technology

It effectively improves the accuracy and efficiency of abnormal detection, reduces the amount of data, solves the problem of long-term dependence of Transformer, and enhances the ability to identify WSN abnormal data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118890626A_ABST
    Figure CN118890626A_ABST
Patent Text Reader

Abstract

The invention discloses a WSN (Wireless Sensor Network) anomaly detection method fusing time-frequency characteristics and space-time correlation. Effective detection and positioning of abnormal nodes in a WSN are realized through time sequence diagram data construction, time sequence decomposition, encoding, decoding and anomaly analysis. Discrete wavelet transform is adopted to decompose a data time sequence into a trend component and a seasonal component. The trend encoder and the season encoder are respectively added with a multi-modal fusion dynamic graph convolution module, so that the trend encoder and the season encoder can adaptively adjust a spatial dependency relationship, information of different modals is fused, and the accuracy of anomaly detection is improved. The seasonal encoder uses a frequency domain attention mechanism to extract features, and can make full use of the difference between the amplitude distribution of normal data and the amplitude distribution of abnormal data in a frequency domain, thereby improving the recognition capability of WSN abnormal data. According to the method, the abnormal nodes in the WSN can be effectively detected and positioned, and the accuracy and efficiency of anomaly detection are effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of wireless sensor networks (WSNs), and in particular to a WSN anomaly detection method integrating time-frequency features and time-space correlation. Background Art

[0002] With the rapid development of the Internet of Things and intelligent monitoring systems, wireless sensor networks play an important role in environmental monitoring, industrial automation, health monitoring and other fields. WSNs are composed of a large number of spatially distributed sensor nodes that can collect and transmit monitoring data in real time. However, due to hardware failures, environmental interference or network attacks of WSNs, abnormal data may appear during the operation of WSNs, affecting the accuracy of monitoring results. Therefore, studying effective WSN anomaly detection methods is crucial to ensure the reliability and stability of WSNs.

[0003] Traditional WSN anomaly detection methods mainly rely on statistical principles, and identify abnormal data that does not conform to the model by building a statistical model of the data. Although these methods are effective in some cases, they usually require prior knowledge of the data distribution, and their performance is limited when the data distribution is unknown or changes dynamically. With the development of deep learning technology, WSN anomaly detection methods based on neural networks have begun to attract attention. These methods can automatically extract data features without making assumptions about the data distribution. Deep learning methods such as convolutional neural networks (CNNs), long short-term memory networks (LSTMs), and gated recurrent units (GRUs) perform well in processing time series data, but they may encounter the problem of gradient vanishing or gradient exploding when processing long sequence data, which limits the ability to capture long-term dependencies. Recently, the Transformer model based on the attention mechanism has been applied in the field of time series anomaly detection due to its parallel processing capabilities and ability to capture long-distance dependencies. However, existing Transformer-based methods still have shortcomings in processing WSN data, especially in capturing long-term dependencies, extracting spatiotemporal structural features, and processing multi-node time series data correlation anomalies. Summary of the invention

[0004] The present invention aims to solve the problem that the existing WSN anomaly detection method has low accuracy. It provides a WSN anomaly detection method that integrates time-frequency features and time-space correlation, which can effectively detect and locate abnormal nodes in WSN and effectively improve the accuracy and efficiency of anomaly detection.

[0005] To solve the above problems, the present invention is achieved through the following technical solutions:

[0006] The WSN anomaly detection method integrating time-frequency features and time-space correlation includes the following steps:

[0007] Step 1: construct dynamic graph data using multimodal sensor data collected by sensor nodes in a wireless sensor network; the graph data at each moment of the dynamic graph data is represented by an attribute matrix at that moment and an adjacency matrix at that moment, wherein the attribute matrix reflects the multimodal sensor data collected by all sensor nodes, and the adjacency matrix reflects the spatial topological structure of all sensor nodes;

[0008] Step 2, establish a wireless sensor anomaly detection network; the wireless sensor anomaly detection network consists of a time series decomposer, a trend encoder, a season encoder and a decoder; the input of the time series decomposer forms the attribute input of the wireless sensor anomaly detection network, and the adjacent input of the trend encoder and the adjacent input of the season encoder form the adjacent input of the wireless sensor anomaly detection network; the output of the time series decomposer is divided into two paths, one path is connected to the attribute input of the trend encoder, and the other path is connected to the attribute input of the season encoder; the outputs of the trend encoder and the season encoder are simultaneously connected to the input of the decoder, and the output of the decoder forms the output of the wireless sensor anomaly detection network;

[0009] Step 3: Use the dynamic graph data constructed in step 1 to train the wireless sensor anomaly detection network established in step 2 to obtain a wireless sensor anomaly detection model;

[0010] Step 4: Collect the graph data represented by the attribute matrix and the adjacency matrix of the wireless sensor network at the current moment, and send the graph data to the wireless sensor anomaly detection model obtained in step 3. The wireless sensor anomaly detection model outputs an anomaly score matrix containing the anomaly scores of each mode of each sensor node, thereby realizing the detection and positioning of abnormal sensor nodes in the wireless sensor network.

[0011] In the above steps 1 and 4, the attribute matrix X t The i-th row and j-th column of Represents the sensor data collected by the sensor of the jth mode of sensor node i at time t; adjacency matrix A t The i-th row and i′th column represents the correlation between sensor node i and sensor node i′ at time t; above i,i′=1,2,…,N, N represents the number of sensor nodes in the wireless sensor network; j=1,2,…,M, M represents the number of modes of each sensor node.

[0012] In the above step 2, the time series decomposer is a time series decomposer based on discrete wavelet transform.

[0013] In the above step 2, the trend encoder includes K1 stacked trend encoding units, where K1≥1;

[0014] Each trend encoding unit is composed of a multi-layer perceptron module, a multimodal fusion dynamic graph convolution module and a feedforward module; the input of the multi-layer perceptron module forms the attribute input of the trend encoding unit, and the adjacent input of the multimodal fusion dynamic graph convolution module forms the adjacent input of the trend encoding unit; the output of the multi-layer perceptron module is connected to the attribute input of the multimodal fusion dynamic graph convolution module, and the output of the multimodal fusion dynamic graph convolution module is connected to the input of the feedforward module; the output of the feedforward module forms the output of the trend encoding unit.

[0015] The above-mentioned seasonal encoder includes K2 seasonal encoding units, where K2≥1; each seasonal encoding unit is composed of a frequency domain attention mechanism module, a multimodal fusion dynamic graph convolution module, a feedforward module and three superposition normalization modules; the input of the frequency domain attention mechanism module forms the attribute input of the seasonal encoding unit, and the adjacent input of the multimodal fusion dynamic graph convolution module forms the adjacent input of the seasonal encoding unit; the input and output of the frequency domain attention mechanism module are simultaneously connected to the input of the first superposition normalization module, and the output of the first superposition normalization module is connected to the attribute input of the multimodal fusion dynamic graph convolution module; the attribute input and output of the multimodal fusion dynamic graph convolution module are simultaneously connected to the input of the second superposition normalization module, and the output of the second superposition normalization module is connected to the input of the feedforward module; the input and output of the feedforward module are connected to the input of the third superposition normalization module; the output of the third superposition normalization module forms the output of the seasonal encoding unit.

[0016] The above-mentioned multimodal fusion dynamic graph convolution module consists of a pattern splitting layer, (M-1)×M cross-attention layers, M addition layers, a concatenation layer, 2 multiplication layers, a transposition layer, an activation function layer and a Hadamard product layer; wherein the (M-1)×M cross-attention layers are divided into M groups, each group includes M-1 cross-attention layers; the input of the pattern splitting layer and the input of the transposition layer form the attribute input of the multimodal fusion dynamic graph convolution module, and one input of the Hadamard product layer forms the adjacent input of the multimodal fusion dynamic graph convolution module; the output of the pattern splitting layer is divided into M modes, and each group of cross-attention layers corresponds to one mode output of the pattern splitting layer, that is, one of the inputs of the M-1 cross-attention layers of the group of cross-attention layers. At the same time, it is connected to the output of the mode corresponding to the mode splitting layer, and the other input of the M-1 cross-attention layers in this group of cross-attention layers is respectively connected to the output of other modes of the mode splitting layer; the outputs of the M-1 cross-attention layers in the same group of cross-attention layers are simultaneously connected to the input of one addition layer; the outputs of the M addition layers are simultaneously connected to the input of the concatenation layer; the input and output of the transpose layer are simultaneously connected to the input of the first multiplication layer, the output of the first multiplication layer is connected to the input of the activation function layer, the output of the activation function layer is connected to another input of the Hadamard product layer, the output of the Hadamard product layer and the output of the concatenation layer are simultaneously connected to the input of the second multiplication layer; the output of the second multiplication layer forms the output of the dynamic graph convolution module of multimodal fusion.

[0017] The above-mentioned frequency domain attention mechanism module is composed of a Fourier transform layer, a self-attention mechanism layer and an inverse Fourier transform layer; the Fourier transform layer forms the input of the frequency domain attention mechanism module; the output of the frequency domain attention mechanism module is connected to the input of the self-attention mechanism layer, and the output of the self-attention mechanism layer is connected to the input of the inverse Fourier transform layer; the output of the inverse Fourier transform layer forms the output of the frequency domain attention mechanism module.

[0018] In the above step 2, the decoder is composed of an inverse discrete wavelet transform module and a linear module; the input of the inverse discrete wavelet transform module forms the input of the decoder, the output of the inverse discrete wavelet transform module is connected to the input of the linear module, and the output of the linear module forms the output of the decoder.

[0019] In the above step 3, the training of the wireless sensor anomaly detection network is achieved by minimizing the mean square error between the attribute matrix output by the wireless sensor anomaly detection network and the attribute matrix input by the wireless sensor anomaly detection network.

[0020] In the above step 4, the square of the difference between the attribute matrix output by the wireless sensor anomaly detection model and the attribute matrix input by the wireless sensor anomaly detection model is calculated to obtain the anomaly score matrix.

[0021] Compared with the prior art, the present invention has the following characteristics:

[0022] 1. The time series decomposition method uses discrete wavelet transform to decompose the data into trend components and seasonal components. Compared with the existing decomposition method based on sliding average, it has great advantages. At the same time, the discrete wavelet transform is used to decompose the time series, which can effectively reduce the amount of data and effectively solve the problem of long-term dependence of Transformer;

[0023] 2. Both the trend encoder and the season encoder have added a multimodal fusion dynamic graph convolution module. Compared with the existing spatial dependency extraction method using graph convolutional neural network (GCN), the multimodal fusion dynamic graph convolution module can adaptively adjust the spatial dependency relationship and integrate information from different modalities, thereby improving the accuracy of anomaly detection.

[0024] 3. The season encoder uses the frequency domain attention mechanism to extract features. Compared with the existing time domain attention mechanism, the frequency domain attention mechanism can make full use of the difference in amplitude distribution between normal data and abnormal data in the frequency domain, and improve the recognition ability of WSN abnormal data. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] Figure 1 Schematic diagram of the wireless sensor anomaly detection network.

[0026] Figure 2 This is the schematic diagram of the timing decomposer.

[0027] Figure 3 Schematic diagram of the dynamic graph convolution module for multimodal fusion.

[0028] Figure 4 Schematic diagram of the frequency domain attention mechanism module.

[0029] Figure 5 This is the spatial location distribution map of sensors in the IBRL dataset.

[0030] Figure 6 This is a correlation anomaly detection analysis diagram. DETAILED DESCRIPTION

[0031] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in combination with specific examples and with reference to the accompanying drawings.

[0032] A WSN anomaly detection method integrating time-frequency features and time-space correlation comprises the following steps:

[0033] Step 1: Build dynamic graph data.

[0034] Dynamic graph data is constructed using multimodal sensor data collected by sensor nodes in a wireless sensor network; the graph data of the dynamic graph data at each moment is represented by an attribute matrix at that moment and an adjacency matrix at that moment, wherein the attribute matrix reflects the multimodal sensor data collected by all sensor nodes, and the adjacency matrix reflects the spatial topological structure of all sensor nodes.

[0035] The wireless sensor network includes multiple sensor nodes, each sensor node includes multiple sensors, and each sensor can collect sensor data of a modality (measurement attribute), such as sensor data including temperature, humidity, voltage and other modalities. The multi-node multi-modal WSN time series data is represented as a dynamic graph data form, that is, a dynamic graph that changes over time. To indicate. t =(X t , A t ) represents the snapshot (graph data) of the dynamic graph G at time t, and Respectively represent graph G t The attribute matrix and adjacency matrix of . Adjacency matrix A t Reflects the spatial topological structure of sensor nodes in wireless sensor networks, adjacency matrix A t The i-th row and i′th column Represents the correlation between sensor node i and sensor node i′ at time t. The attribute matrix X t Reflects the sensor data collected by the sensor node, the attribute matrix X t The i-th row Represents the M-dimensional modal sensor data collected by sensor node i at time t.

[0036] Since the sensor data of different modes of the sensor often have different dimensions, the order of magnitude of the sensor data of different modes varies greatly. If the original data is directly used for analysis, the role of the mode with higher values ​​in the comprehensive analysis will be strengthened, and the role of the mode with lower values ​​in the comprehensive analysis will be relatively weakened. Therefore, in order to eliminate the influence of the dimensional difference and value range difference between the modes, it is necessary to standardize the original data so that each mode is in the same dimension. To this end, the present invention adopts the Z-score standardization method to normalize the attribute matrix X t After standardization and Z-score preprocessing, the attribute matrix X t It will conform to the normal distribution with a mean of 0 and a standard deviation of 1. The formula is as follows:

[0037]

[0038] in, represents the normalized sensor data of the jth sensor of the i-th sensor node, Xij represents the raw sensor data of the jth sensor of the ith sensor node, μ(*) represents the mean, and σ(*) represents the standard deviation.

[0039] When training the model, a sliding window is used to intercept the dynamic graph G at T moments. That is, the time window size is usually W when the model is input, that is, W continuous sensor network observations at moments are used as input. G t =(X t , A t ) represents the graph data of the dynamic graph data G at time t. Represents graph data G t The attribute matrix, attribute matrix X t The i-th row and j-th column of Represents the normalized sensor data of the jth mode collected by sensor node i at time t. Represents graph data G t The adjacency matrix, adjacency matrix A t The i-th row and i′th column Represents the correlation between sensor node i and sensor node i′ at time t. i,i′=1,2,…,N, N represents the number of sensor nodes in the wireless sensor network. j=1,2,…,M, M represents the number of modes measured by each sensor node. t=1,2,…,W, W represents the number of time moments, i.e., the length of the sequence.

[0040] Step 2: Establish a wireless sensor anomaly detection network.

[0041] The wireless sensor anomaly detection network constructed by the present invention is composed of a time series decomposer, a trend encoder, a season encoder and a decoder. Figure 1 As shown. The input of the time series decomposer forms the attribute input of the wireless sensor anomaly detection network, and the adjacent input of the trend encoder and the adjacent input of the season encoder form the adjacent input of the wireless sensor anomaly detection network. The output of the time series decomposer is divided into two paths, one connected to the attribute input of the trend encoder, and the other connected to the attribute input of the season encoder. The outputs of the trend encoder and the season encoder are simultaneously connected to the input of the decoder, and the output of the decoder forms the output of the wireless sensor anomaly detection network.

[0042] (1) Timing decomposition

[0043] The time series decomposer of the present invention is a time series decomposer based on discrete wavelet transform. The time series decomposer uses discrete wavelet transform (DWT) to transform the time series data X={X1, X2, ..., X W} Perform multi-scale decomposition to decompose the time series into trend component and seasonal component. The trend component of the time series represents the overall development trend of the time series, which is the general process of the time series change and belongs to the low-frequency component in the time series. The seasonal component of the time series represents the fluctuation in the details of the time series, which is a relatively small and rapid change and belongs to the high-frequency component in the time series. Figure 2 As shown, the timing decomposer can be expressed as:

[0044] X tre ,X sea =DWT(X)

[0045] in, represents the input time series, represents the trend component of the time series, represents the seasonal component of the time series, and DWT(*) represents discrete wavelet transform.

[0046] After the original time series is transformed by a first-order discrete wavelet transform, the present invention uses an approximate component to represent the trend component of the time series, which reflects the long-term change trend of the data, and uses a detail component to represent the seasonal component of the time series, which reflects the short-term fluctuation information of the data, thereby effectively capturing the inherent structural characteristics of the data. Subsequently, the trend component and the detail component are respectively input into the trend encoder and the seasonal encoder to extract features.

[0047] (2) Coding

[0048] Based on the time series decomposition, the present invention designs two encoders: a trend encoder and a season encoder. The trend encoder uses a multi-layer perceptron module (MLP) to extract the features of the trend component, while the season encoder uses a frequency domain attention mechanism module (FDAM) to extract the features of the season component. In addition, the present invention also adds a multimodal fusion dynamic graph convolution module (MFDGCN) to these two encoders to extract the dependencies between data modalities and the dependencies between sensor nodes. The two encoders conduct in-depth analysis of the trend and seasonal components, respectively, and extract key features for subsequent processing.

[0049] (2.1) Trend encoder

[0050] The trend encoder includes K1 stacked trend encoding units, where K1 ≥ 1. Each trend encoding unit consists of a multi-layer perceptron module (MLP), a multimodal fusion dynamic graph convolution module (MFDGCN) and a feedforward module (Feed Forward). The input of the multi-layer perceptron module forms the attribute input of the trend encoding unit, and the adjacent input of the multimodal fusion dynamic graph convolution module forms the adjacent input of the trend encoding unit; the output of the multi-layer perceptron module is connected to the attribute input of the multimodal fusion dynamic graph convolution module, and the output of the multimodal fusion dynamic graph convolution module is connected to the input of the feedforward module; the output of the feedforward module forms the output of the trend encoding unit.

[0051] When the number of trend encoding units constituting the trend encoder is 1, the attribute input of the trend encoding unit forms the attribute input of the potential encoder, the output of the trend encoding unit forms the output of the trend encoder, and the adjacent input of the trend encoding unit forms the adjacent input of the trend encoder.

[0052] When the number of trend coding units constituting the trend encoder is greater than one, the attribute input of the previous trend coding unit is connected to the attribute output of the next trend coding unit, the attribute input of the first trend coding unit forms the attribute input of the trend encoder, the attribute input of the last trend coding unit forms the output of the trend encoder, and the adjacent inputs of all trend coding units form the adjacent inputs of the trend encoder.

[0053] The dynamic graph convolution module of multimodal fusion of the trend encoder is the key design. The following mainly introduces the dynamic graph convolution module of multimodal fusion.

[0054] See also Figure 3 ,The dynamic graph convolution module for multimodal fusion consists of a mode splitting layer, (M-1)×M cross attention layers, M addition layers, a concatenation layer, 2 multiplication layers, a transposition layer, an activation function layer, and a Hadamard product layer.

[0055] The multimodal fusion dynamic graph convolution module consists of a mode splitting layer, (M-1)×M cross attention layers, M addition layers, a concatenation layer, 2 multiplication layers, a transposition layer, an activation function layer and a Hadamard product layer; the (M-1)×M cross attention layers are divided into M groups, each group includes M-1 cross attention layers. The input of the mode splitting layer and the input of the transposition layer form the attribute input of the multimodal fusion dynamic graph convolution module, and one input of the Hadamard product layer forms the adjacent input of the multimodal fusion dynamic graph convolution module; the output of the mode splitting layer is divided into M modes, and each group of cross attention layers corresponds to one mode output of the mode splitting layer, that is, one of the inputs of the M-1 cross attention layers of the group of cross attention layers is simultaneously connected to the output of the mode corresponding to the mode splitting layer, and the other inputs of the M-1 cross attention layers of the group of cross attention layers are respectively connected to the outputs of other modes of the mode splitting layer; the outputs of the M-1 cross attention layers of the same group of cross attention layers are simultaneously connected to the input of an addition layer; the outputs of the M addition layers are simultaneously connected to the input of the concatenation layer. The input and output of the transpose layer are connected to the input of the first multiplication layer at the same time, the output of the first multiplication layer is connected to the input of the activation function layer, the output of the activation function layer is connected to another input of the Hadamard product layer, the output of the Hadamard product layer and the output of the concatenation layer are connected to the input of the second multiplication layer at the same time; the output of the second multiplication layer forms the output of the multimodal fusion dynamic graph convolution module.

[0056] The transposition layer, multiplication layer and activation function layer are used to dynamically calculate the correlation strength between nodes to obtain the spatial correlation weight matrix S t , and the calculated spatial correlation weight matrix S t The adjacency matrix is ​​adjusted by performing a Hadamard product operation element by element with the adjacency matrix A, thereby adaptively adjusting the network topology.

[0057] At time t, the node represents Z t ∈R N×M , spatial correlation weight matrix S t for:

[0058]

[0059] Among them, d M Represents Z t Dimension.

[0060] Adjusted adjacency matrix for:

[0061]

[0062] Among them, ⊙ represents the Hadamard product operation, is the adjusted adjacency matrix.

[0063] The cross attention mechanism calculates attention on two different sequences to obtain the dependency between the two sequences. The present invention uses the cross attention mechanism to fuse sequences of different modalities. One modality sequence is mapped into a query Q (Query, Q), and another different modality sequence is mapped into a key K (Key, K) and a value V (Value, V). Other modal information is fused by calculating attention and adding them. Input attribute matrix According to the mode, the matrix can be expanded into Modality i fusion other modality information fusion i It can be expressed as:

[0064]

[0065] Then the modal fusion is expressed as:

[0066] ModalFusion(X)=Concat(fusion1,…,fusion M )

[0067] Among them, Concat(*) means concatenation.

[0068] The propagation mode between layers of the dynamic graph convolution module of multimodal fusion is expressed as:

[0069]

[0070] Among them, σ(*) represents the activation function, W (l) represents the learnable parameters of the lth layer, H (l+1) and H (l) They are the feature representations of the l+1th layer and the lth layer respectively.

[0071] In summary, the overall structure of the trend encoder can be expressed as:

[0072] X′ tre =MLP(X tre )

[0073]

[0074] Z tre =FFN(X″ tre )

[0075] Among them, X tre Represents the trend component (trend encoder input), Z tre represents the trend encoder output, MLP(*) represents multi-layer perception, and FFN(*) represents feedforward.

[0076] (2.2) Seasonal encoder

[0077] The seasonal encoder includes K2 seasonal encoding units, where K2 ≥ 1. Each seasonal encoding unit consists of a frequency domain attention mechanism module (FDAM), a multimodal fusion dynamic graph convolution module (MFDGCN), a feed forward module (Feed Forward) and three stacking normalization modules (Add&Norm). The input of the frequency domain attention mechanism module forms the attribute input of the seasonal encoding unit, and the adjacent input of the multimodal fusion dynamic graph convolution module forms the adjacent input of the seasonal encoding unit; the input and output of the frequency domain attention mechanism module are simultaneously connected to the input of the first stacking normalization module, and the output of the first stacking normalization module is connected to the attribute input of the multimodal fusion dynamic graph convolution module; the attribute input and output of the multimodal fusion dynamic graph convolution module are simultaneously connected to the input of the second stacking normalization module, and the output of the second stacking normalization module is connected to the input of the feed forward module; the input and output of the feed forward module are connected to the input of the third stacking normalization module, and the output of the third stacking normalization module forms the output of the seasonal encoding unit.

[0078] When the number of seasonal coding units constituting the seasonal encoder is 1, the attribute input of the seasonal coding unit forms the attribute input of the potential encoder, the output of the seasonal coding unit forms the output of the seasonal encoder, and the adjacent input of the seasonal coding unit forms the adjacent input of the seasonal encoder.

[0079] When the number of seasonal coding units constituting the seasonal encoder is greater than one, the attribute input of the previous seasonal coding unit is connected to the attribute output of the next seasonal coding unit, the attribute input of the first seasonal coding unit forms the attribute input of the seasonal encoder, the attribute input of the last seasonal coding unit forms the output of the seasonal encoder, and the adjacent inputs of all seasonal coding units form the adjacent inputs of the seasonal encoder.

[0080] The multimodal fusion dynamic graph convolution module of the season encoder is the same as the multimodal fusion dynamic graph convolution module of the trend encoder. The following mainly introduces the frequency domain attention mechanism module. Figure 4 The frequency domain attention mechanism module consists of a Fourier transform layer, a self-attention mechanism layer, and an inverse Fourier transform layer. The Fourier transform layer forms the input of the frequency domain attention mechanism module; the output of the frequency domain attention mechanism module is connected to the input of the self-attention mechanism layer, the output of the self-attention mechanism layer is connected to the input of the inverse Fourier transform layer, and the output of the inverse Fourier transform layer forms the output of the frequency domain attention mechanism module.

[0081] 1) Fourier transform is a common method for converting a time series from the time domain to the frequency domain. It decomposes the time series into a series of trigonometric functions to represent the amplitude and phase of the time series at different frequencies. The Fourier transform layer of the present invention uses a discrete Fourier transform layer to convert the time series from the time domain to the frequency domain. The discrete Fourier transform formula is as follows:

[0082]

[0083] Wherein, N represents the time series length, e represents the base of the natural logarithm, i represents the imaginary unit, and ω represents the angular frequency.

[0084] The simplified expression is:

[0085]

[0086] in, represents the discrete Fourier transform,

[0087] In the anomaly detection task, it is usually hoped that the model can learn normal data and reconstruct normal data, and for abnormal data, it is hoped that the model can suppress or ignore it. The present invention finds that the use of a self-attention mechanism in the frequency domain can achieve this effect. Since normal data has a larger and more concentrated amplitude in the spectrum, while the amplitude of abnormal data is smaller and divergent, the self-attention mechanism can easily notice the frequency component of normal data and give it a larger attention weight.

[0088] 2) The self-attention mechanism layer uses three learnable parameters W in the frequency domain FQ , W FK , W FV X is mapped into query Q, key K and value V in the frequency domain, so that it has the ability to extract features in the frequency domain.

[0089] Q=X F W FQ

[0090] K=X F W FK

[0091] V=X F W FV

[0092] The self-attention mechanism layer usually uses the Softmax function when normalizing the attention weights. The Softmax function with exponential terms has a "polarization" effect, which can increase the gap between large and small values, polarizing the data. Larger values ​​get larger weights and smaller values ​​get smaller weights. Therefore, using the attention mechanism in the frequency domain can better focus on the frequency of normal data, while suppressing the frequency components of abnormal data. Therefore, it can capture the characteristics of normal data well and reduce the impact of abnormal data.

[0093] 3) The inverse Fourier transform layer uses the inverse discrete Fourier transform to convert the sequence from the frequency domain back to the time domain. The formula is:

[0094]

[0095] in, Represents the inverse discrete Fourier transform.

[0096] So the frequency domain attention mechanism module can be expressed as:

[0097]

[0098] In summary, the overall structure of the season encoder can be expressed as:

[0099]

[0100] Q=X F W FQ

[0101] K=X F W FK

[0102] V=X F W FV

[0103] X′ se =LayerNorm(X sea +FDAM(Q,K,V)

[0104]

[0105] Z se =LayerNorm(X″) se +FFN(X″ sea ))

[0106] Among them, X se represents the seasonal component (seasonal encoder input), Z sea represents the seasonal encoder output, LayerNorm(*) represents layer normalization, and FFN(*) represents feedforward.

[0107] (3) Decoder

[0108] The decoder consists of an inverse discrete wavelet transform module and a linear module. The input of the inverse discrete wavelet transform module forms the input of the decoder, the output of the inverse discrete wavelet transform module is connected to the input of the linear module, and the output of the linear module forms the output of the decoder.

[0109] The encoded features are reconstructed back to the original time series form through the decoder. The decoder restores the encoded trend component and seasonal component to their original form through inverse discrete wavelet transform, and then obtains the reconstructed output through linear mapping. The decoder can be expressed as:

[0110]

[0111] Among them, Z tre represents the encoded trend component, Z sea represents the encoded seasonal component, IDWT(*) represents the inverse discrete wavelet transform, Linear(*) represents the linear layer, Represents the reconstructed time series.

[0112] Step 3: Training of wireless sensor anomaly detection network.

[0113] The wireless sensor anomaly detection network is trained using dynamic graph data to obtain a wireless sensor anomaly detection model. During the training process, the present invention uses mean square error (MSE) as a loss function to measure the difference between the reconstructed output and the actual observed data.

[0114] Since the invention is designed as an anomaly detection method based on a reconstruction framework, its goal is to minimize the reconstruction output The mean square error (MSE) between the input actual observation data X is used to learn the characteristics of normal data and train the line sensor anomaly detection network. The loss function is:

[0115]

[0116] Where W represents the number of time points, N represents the number of sensor nodes in the wireless sensor network, and M represents the number of modes of each sensor node; x t (i,j) represents the observed sensor data of the j-th mode sensor of sensor node i at time t, Represents the reconstructed sensing data of the sensor of the jth mode of sensor node i at time t.

[0117] Step 4: Anomaly prediction.

[0118] Collect the graph data represented by the attribute matrix and the adjacency matrix of the wireless sensor network at the current moment, and send the graph data to the wireless sensor anomaly detection model obtained in step 3. The wireless sensor anomaly detection model outputs an anomaly score matrix containing the anomaly scores of each mode of each sensor node, thereby realizing the detection and positioning of abnormal sensor nodes in the wireless sensor network.

[0119] When predicting anomalies, the observed data is input into the model, and the model reconstructs and outputs the data. Since the distribution of abnormal data is different from that of normal data, the reconstruction error of abnormal data is relatively large. Therefore, the present invention uses the reconstruction error, that is, the square of the difference between the input value and the reconstructed value, as the anomaly score. The anomaly score of the jth mode on the i-th node at time t is expressed as:

[0120]

[0121] The anomaly score t (i,j) is compared with the threshold τ, and the abnormal score score t (i,j) is greater than the threshold, the label y of the data t (i,j) is set to 1, otherwise the label y of the data t (i,j) is set to 0, that is:

[0122]

[0123] The present invention uses the reconstruction error as anomaly score and sets a threshold to determine whether the data is abnormal. Data points whose anomaly scores exceed the threshold are marked as abnormal, thereby achieving effective detection and positioning of abnormal nodes in WSN.

[0124] The performance of the present invention is experimentally verified using a real dataset collected by Intel Berkeley Research Lab (IBRL). The IBRL dataset is data collected by 54 sensors deployed by Intel Berkeley Research Lab. The distribution of sensor nodes is shown in Figure 2. Figure 5 This dataset records the humidity, temperature, light, and voltage readings collected by the wireless sensor network every 31 seconds over a period of more than a month in the laboratory.

[0125] (1) Comparative experiment

[0126] In order to verify the effectiveness of the present invention, the experimental results of comparing the present invention with the following four existing methods are shown in Table 1. Wherein, Pre represents precision, Rec represents recall, and F1 represents F1 score.

[0127] Table 1 Comparative experimental results

[0128]

[0129] As can be seen from Table 1, the CNN-LSTM method achieved the worst F1 score, because this method uses CNN to extract the relationship between modalities and adopts a processing method similar to that of images. It does not take into account the complex correlation between modalities and is difficult to process graph data with complex correlation between nodes. Therefore, the worst effect in the comparative experiment was taken. The MTAD-GAT method is anomaly detection for a single node. It does not take into account the spatial correlation characteristics of multiple nodes. It needs to establish multiple models to train and learn the feature information of each node, which reduces the training efficiency. At the same time, since the MTAD-GAT method does not take into account the correlation between nodes, it cannot achieve good results. GAT-GRU and GLSL use different methods to extract data features from the time dimension, modal dimension and spatial dimension, so they have achieved better results. GAT-GRU first extracts the time feature and modal feature from each node, and then splices all nodes together to learn the spatial feature. GLSL decomposes the data into multiple graphs according to the modality, first extracts the time and space features, and then splices them together to learn the features between modalities. GAT-GRU needs to design a feature extractor for each node, so GLSL has more advantages when the data scale is large. In the comparative experiments, the model proposed by the present invention achieved the best results in terms of precision, recall and F1 score. Based on the problems found by the above methods, the present invention also considers time series decomposition, frequency domain feature extraction and dynamic space modeling. The ablation experiment will show the improvement of these factors in performance and effect.

[0130] (2) Ablation experiment

[0131] In order to study the effect and performance of each component in the model designed by the present invention, the present invention designs an ablation experiment. By gradually eliminating each component and observing the changes in each indicator of the experimental results, the influence of each component is determined. The results of the ablation experiment are shown in Table 2. Among them, Pre represents precision, Rec represents recall, F1 represents F1 score, Par represents parameter quantity (Parameters), and FLOPs represents the amount of operation, that is, the number of floating point operations (floating point operations).

[0132] Table 2 Ablation experiment results

[0133]

[0134] Solution 1 is a complete model designed by the present invention. The model uses DWT to decompose the trend and season of the time series, and then inputs them into the trend encoder and season encoder respectively. The season encoder uses FDAM to extract features, and both encoders use MFDGCN to extract spatial features. In the ablation experiment, Solution 1 achieved the best results in terms of precision, recall and F1 score.

[0135] In the second scheme, the present invention uses the sliding average method commonly used in the existing model to replace the DWT time series decomposition, so as to study the performance improvement brought by the use of DWT time series decomposition. The present invention analyzes and finds that the amount of time series data decomposed by using DWT is half less than that by the sliding average method. With the reduction of data volume, the amount of calculation and parameter required by the model will also be reduced accordingly. In order to compare the two methods, the present invention designs the experiment of scheme 2. From the experimental results, both the DWT method and the sliding average method have achieved good results, and the DWT method is slightly better. However, from the perspective of the amount of calculation and the amount of parameters, the DWT method is better than the sliding average method. The present invention has counted the amount of calculation and the amount of parameters of the two respectively. The model calculation amount of the sliding average method is 324.9M, the parameter amount is 1.8M, and the model calculation amount of the DWT method is 148.6M, and the parameter amount is 0.9M. From the statistical results, the model calculation amount of the sliding average method is more than twice that of the DWT method, and the model parameter amount of the sliding average method is almost twice that of the DWT method. It can be seen that the method of using DWT time series decomposition proposed in the present invention has greatly improved the performance of the model compared to the existing sliding average method, and the time complexity and space complexity of the model are almost reduced by half.

[0136] Solution 3 changes the frequency domain attention mechanism to the time domain signal attention mechanism based on Solution 2 to study the effectiveness of the frequency domain attention mechanism. Comparing the experimental results of Solution 2 and Solution 3, it can be found that the frequency domain attention mechanism improves the precision by 5.4%, the recall by 7.4%, and the F1 score by 6.6% compared with the time domain signal attention. Overall, the frequency domain attention mechanism has greatly improved the anomaly detection capability of the model due to its unique advantages.

[0137] Scheme 4 replaces MFDGCN with ordinary GCN on the basis of Scheme 3 to study the impact of dynamic spatial modeling and multimodal fusion on anomaly detection results. In Scheme 4, the present invention retains GCN and enables it to perform graph learning in a static manner. From the experimental results, the dynamic graph learning method proposed in the present invention has a significant improvement in accuracy, which is increased by 10.1%. The recall rate is similar to the static method, and the F1 score is increased by 5.2%. It can be seen that the use of a dynamic method for spatial structure learning is very necessary for anomaly detection. In order to further study the correlation information extraction capability of MFDGCN and the effectiveness of correlation anomaly detection, the present invention analyzes the actual anomaly detection situation of the model.

[0138] Figure 6In the IBRL dataset, the temperature data and humidity data of node 1 show a negative correlation. The data label curve shows that there are many point anomalies and context anomalies in the temperature data, and the humidity data has a correlation anomaly in the middle (positively correlated with temperature). Both schemes 3 and 4 can correctly detect point anomalies and context anomalies, but scheme 4 can hardly detect correlation anomalies. Scheme 3 adds MFDGCN to extract correlation information, which can detect correlation anomalies well.

[0139] The above experimental results once again prove the effectiveness of the WSN anomaly detection model proposed in the present invention, confirming that each component proposed in the present invention is indispensable, and the model has achieved excellent results in the WSN anomaly detection field.

[0140] It should be noted that although the embodiments of the present invention described above are illustrative, they are not intended to limit the present invention, and therefore the present invention is not limited to the above specific embodiments. Without departing from the principles of the present invention, any other embodiments obtained by those skilled in the art under the guidance of the present invention are deemed to be within the protection of the present invention.

Claims

1. A WSN anomaly detection method integrating time-frequency features and spatiotemporal correlation is characterized by: The steps include: Step 1: construct dynamic graph data using multimodal sensor data collected by sensor nodes in a wireless sensor network; the graph data at each moment of the dynamic graph data is represented by an attribute matrix at that moment and an adjacency matrix at that moment, wherein the attribute matrix reflects the multimodal sensor data collected by all sensor nodes, and the adjacency matrix reflects the spatial topological structure of all sensor nodes; Step 2: Establish a wireless sensor anomaly detection network; The wireless sensor anomaly detection network is composed of a time series decomposer, a trend encoder, a season encoder and a decoder; the input of the time series decomposer forms the attribute input of the wireless sensor anomaly detection network, and the adjacent input of the trend encoder and the adjacent input of the season encoder form the adjacent input of the wireless sensor anomaly detection network; The output of the time series decomposer is divided into two paths, one path is connected to the attribute input of the trend encoder, and the other path is connected to the attribute input of the season encoder; the outputs of the trend encoder and the season encoder are simultaneously connected to the input of the decoder, and the output of the decoder forms the output of the wireless sensor anomaly detection network; Step 3: Use the dynamic graph data constructed in step 1 to train the wireless sensor anomaly detection network established in step 2 to obtain a wireless sensor anomaly detection model; Step 4: Collect the graph data represented by the attribute matrix and the adjacency matrix of the wireless sensor network at the current moment, and send the graph data to the wireless sensor anomaly detection model obtained in step 3. The wireless sensor anomaly detection model outputs an anomaly score matrix containing the anomaly scores of each mode of each sensor node, thereby realizing the detection and positioning of abnormal sensor nodes in the wireless sensor network.

2. The WSN anomaly detection method integrating time-frequency features and time-space correlation according to claim 1 is characterized in that: In steps 1 and 4, the attribute matrix X t The i-th row and j-th column of Represents the sensor data collected by the sensor of the jth mode of sensor node i at time t; adjacency matrix A t The i-th row and i′th column represents the correlation between sensor node i and sensor node i′ at time t; In the above, i, i′=1, 2, …, N, N represents the number of sensor nodes in the wireless sensor network; j=1, 2, …, M, M represents the number of modes of each sensor node.

3. The WSN anomaly detection method integrating time-frequency features and time-space correlation according to claim 1 is characterized in that: In step 2, the time series decomposer is a time series decomposer based on discrete wavelet transform.

4. The WSN anomaly detection method integrating time-frequency features and time-space correlation according to claim 1 is characterized in that: In step 2, the trend encoder includes K1 stacked trend encoding units, where K1≥1; Each trend encoding unit is composed of a multi-layer perceptron module, a multimodal fusion dynamic graph convolution module and a feedforward module; the input of the multi-layer perceptron module forms the attribute input of the trend encoding unit, and the adjacent input of the multimodal fusion dynamic graph convolution module forms the adjacent input of the trend encoding unit; the output of the multi-layer perceptron module is connected to the attribute input of the multimodal fusion dynamic graph convolution module, and the output of the multimodal fusion dynamic graph convolution module is connected to the input of the feedforward module; the output of the feedforward module forms the output of the trend encoding unit.

5. The WSN anomaly detection method integrating time-frequency features and time-space correlation according to claim 1 is characterized in that: In step 2, the seasonal encoder includes K2 seasonal encoding units, where K2 ≥ 1; Each seasonal coding unit consists of a frequency domain attention mechanism module, a multimodal fusion dynamic graph convolution module, a feedforward module, and three stacking normalization modules; the input of the frequency domain attention mechanism module forms the attribute input of the seasonal coding unit, and the adjacent input of the multimodal fusion dynamic graph convolution module forms the adjacent input of the seasonal coding unit; The input and output of the frequency domain attention mechanism module are simultaneously connected to the input of the first superposition normalization module, and the output of the first superposition normalization module is connected to the attribute input of the multimodal fusion dynamic graph convolution module; the attribute input and output of the multimodal fusion dynamic graph convolution module are simultaneously connected to the input of the second superposition normalization module, and the output of the second superposition normalization module is connected to the input of the feedforward module; the input and output of the feedforward module are connected to the input of the third superposition normalization module; the output of the third superposition normalization module forms the output of the seasonal encoding unit.

6. The WSN anomaly detection method integrating time-frequency features and time-space correlation according to claim 4 or 5, characterized in that: The dynamic graph convolution module of multimodal fusion consists of a mode splitting layer, (M-1)×M cross attention layers, M addition layers, a concatenation layer, 2 multiplication layers, a transposition layer, an activation function layer, and a Hadamard product layer; the (M-1)×M cross attention layers are divided into M groups, each group includes M-1 cross attention layers; The input of the mode splitting layer and the input of the transposition layer form the attribute input of the dynamic graph convolution module of multimodal fusion, and one input of the Hadamard product layer forms the adjacent input of the dynamic graph convolution module of multimodal fusion; the output of the mode splitting layer is divided into M modes, and each group of cross-attention layers corresponds to one mode output of the mode splitting layer, that is, one of the inputs of the M-1 cross-attention layers of the group of cross-attention layers is simultaneously connected to the output of the mode corresponding to the mode splitting layer, and the other input of the M-1 cross-attention layers of the group of cross-attention layers is respectively connected to the output of other modes of the mode splitting layer; the outputs of the M-1 cross-attention layers of the same group of cross-attention layers are simultaneously connected to the input of one addition layer; the outputs of the M addition layers are simultaneously connected to the input of the concatenation layer; the input and output of the transposition layer are simultaneously connected to the input of the first multiplication layer, the output of the first multiplication layer is connected to the input of the activation function layer, the output of the activation function layer is connected to another input of the Hadamard product layer, and the output of the Hadamard product layer and the output of the concatenation layer are simultaneously connected to the input of the second multiplication layer; the output of the second multiplication layer forms the output of the dynamic graph convolution module of multimodal fusion.

7. The WSN anomaly detection method integrating time-frequency features and time-space correlation according to claim 5 is characterized in that: The frequency domain attention mechanism module consists of a Fourier transform layer, a self-attention mechanism layer, and an inverse Fourier transform layer; The Fourier transform layer forms the input to the frequency domain attention mechanism module; The output of the frequency domain attention mechanism module is connected to the input of the self-attention mechanism layer, and the output of the self-attention mechanism layer is connected to the input of the inverse Fourier transform layer; the output of the inverse Fourier transform layer forms the output of the frequency domain attention mechanism module.

8. The WSN anomaly detection method integrating time-frequency features and time-space correlation according to claim 1 is characterized in that: In step 2, the decoder consists of an inverse discrete wavelet transform module and a linear module; The input of the inverse discrete wavelet transform module forms the input of the decoder, the output of the inverse discrete wavelet transform module is connected to the input of the linear module, and the output of the linear module forms the output of the decoder.

9. The WSN anomaly detection method integrating time-frequency features and time-space correlation according to claim 1 is characterized in that: In step 3, the training of the wireless sensor anomaly detection network is achieved by minimizing the mean square error between the attribute matrix output by the wireless sensor anomaly detection network and the attribute matrix input by the wireless sensor anomaly detection network.

10. The WSN anomaly detection method integrating time-frequency features and time-space correlation according to claim 1 is characterized in that: In step 4, the square of the difference between the attribute matrix output by the wireless sensor anomaly detection model and the attribute matrix input by the wireless sensor anomaly detection model is calculated to obtain an anomaly score matrix.

Citation Information

Cited By

  • Traffic flow prediction method and system based on multi-scale dynamic decomposition and space-time Transform

    CN121034085A