Study on Temperature Sensor Data Anomaly Diagnosis Method Based on Deep Neural Network

In order to solve the problems of low accuracy and low eﬃciency of traditional sensor data anomaly diagnosis methods, a new temperature sensor data anomaly diagnosis method based on deep neural network is proposed in this paper. Firstly, the temperature sensor data in a running cycle is collected, and the characteristics of the temperature sensor data are extracted by the sliding window technology. Secondly, based on the feature extraction results, a deep neural network model for anomaly diagnosis of temperature sensor data is constructed. The feature data are input into the model, and the result obtained is the diagnosis result. Finally, the simulation comparison experiment is carried out. The experimental results show that the error rate of feature extraction of temperature sensor data in this method changes between − 2.1% and 5.9%, the diagnosis accuracy remains above 95%, the average diagnosis time is only 59ms, and the diagnosis eﬃciency is high.


Introduction
At present, the development speed of intelligent sensors is getting faster and faster. erefore, temperature sensors have been transformed from traditional analog to digital and intelligent [1]. Temperature sensors mainly ensure the accuracy of temperature data collection through the cooperation of hardware and software, saving a lot of design and manufacturing costs, so they have been widely used in various social fields [2]. And temperature sensor with the support of hardware and software will be linked with various microprocessor temperature sensors, and the wireless network is used to transmit data to upload, or to the specified device, but once the sensor fails, it may result in abnormal temperature sensor data [3], so you need to diagnose abnormal temperature sensor data. erefore, it is very important to design a temperature sensor data anomaly diagnosis method to judge the running state of intelligent sensors.
For the anomaly diagnosis of temperature sensor data, relatively good research results have emerged in related fields. For example, reference [4] proposed an anomaly diagnosis method of temperature sensor data based on a dual prediction model. is method mainly collected the operation data of multiple temperature sensors. e data were cleaned and deduplicated. Based on this, a support vector machine (SVM) and least squares support vector machine (LS-SVM) prediction model was built. e model is used to predict the operating state of the temperature sensor data, and the abnormality diagnosis of the temperature sensor data is realized by combining the prediction results. However, in practical application, it is found that this method takes a long time to diagnose abnormal temperature sensor data. Reference [5] proposed a temperature sensor data anomaly diagnosis method based on multiple lag regression model. is method mainly takes the building wood structure as the research object.
e temperature sensor data are arranged in the building to collect the building temperature change data. Combined with the collected data, a multiple lag regression model to analyze the autocorrelation is built, periodicity and heteroscedasticity of the data. According to these characteristics, the abnormal data of the temperature sensor are diagnosed. However, this method has the problem of low diagnostic accuracy, and the practical application effect is not good. Ding et al. [6] proposed a method for abnormal temperature sensor data diagnosis based on serial correlation analysis. e temperature sensor data are collected, and the multi-dimensional time series of the sensor data are segmented and normalized, so as to obtain the judgment matrix of data correlation and obtain the correlation judgment result of the data. According to the results, a time series correlation graph model is established, and the model is used to distinguish normal temperature sensor data and abnormal temperature sensor data. e abnormal data of the temperature sensor is diagnosed. e temperature sensor data are abnormal. However, this method has the problem of high error rate of temperature sensor data feature extraction, which is far from ideal application effect.
In the process of using traditional methods to diagnose the abnormal data of temperature sensor, the performance of the abnormal diagnosis model of building temperature sensor data is poor because the characteristics and extraction of temperature sensor are not analyzed. is paper aims to solve the problem of low diagnosis accuracy and efficiency of traditional sensor data abnormal diagnosis methods, and a temperature sensor data anomaly diagnosis method based on a deep neural network is proposed. erefore, this method has the characteristics of high temperature sensor data anomaly diagnosis accuracy and diagnosis efficiency. e overall design scheme of the method is as follows: (1) Collect the temperature sensor data within a running cycle, and use the sliding window technology to extract the temperature sensor data characteristics (2) Based on the result of feature extraction, a deep neural network model for anomaly diagnosis of temperature sensor data is constructed. e characteristic data are input into the model, and the result obtained is the diagnosis result.
(3) Compare the error rate of feature extraction of temperature sensor data, anomaly diagnosis accuracy, and efficiency of temperature sensor data of different methods through experiments.

Temperature Sensor Data Collection.
In order to achieve the comprehensive goal of data acquisition accuracy and efficiency of temperature sensor, this paper introduces a K-means algorithm to design the data acquisition process of temperature sensor. e operation cycle of temperature sensor is set to 6 months, and the sampling time interval is set to 1 s so as to collect more complete and reliable data to the greatest extent. Suppose there is a periodic temperature sensor dataset represented by x 1 , x 2 , . . . , x N , which mainly includes N observation series of random variable x [7,8]. e goal of k-means clustering is to divide dataset N into k categories, at which a vector-value u k is introduced, where k � 1, . . . , K and u k are the central values of the first cluster. e goal of clustering is to find each data point category and vector u k so that the sum of squares of the distance between each data point and u k can reach the minimum [9]. Suppose x n is used to represent the node vector, and a set of corresponding binary indicator variable r nk is introduced, where k � 1, . . . , K means that the node vector x n belongs to class K, and x n is assigned to class k; then, r nk � 1 exists, and the objective function is defined in the following form: In the above formula, J represents the sum of the square of the distance between each data point and the center vector of the cluster to which it is assigned. Now, the key is to find the value of r nk and u k to achieve the minimum value.
First, we determine the value of r nk . J given by equation (1) is a linear function of r nk , so it is easy to obtain an analytical solution for r nk . Each data is independent, so we can choose to optimize each n separately, as long as we ensure that the value of x n − u 2 k is small. Here, let r nk � 1. In language description, we simply set the clustering of data nodes as the nearest clustering center. e function expression is as follows: Here, if we take the derivative of the objective function and make it equal to 0, then the minimum value can be obtained, which can be expressed as rough solution, we obtain u k � n r nk x n n r nk .

(4)
For the data type in this paper, the dataset objects in the network are cooperative sensor node sets, and each temperature sensor set is a data vector [10]. Among them, n such dataset vectors form a set G, and the data of these n datasets are initialized into K categories, as shown in Figure 1: e temperature sensor data acquisition process based on the K-means algorithm is shown as follows: (1) K objects are randomly selected from set G of node group data set as the initial class center (2) According to the class center value, the dataset value in the G sets is compared with the class center value, and the remaining n objects are divided into each class by comparing the minimum distance value. and J represent the number of process samples and the number of process variables, respectively. is two-dimensional data matrix is segmented along the sampling direction by a sliding window H [11]; that is, matrix X is segmented along the horizontal axis after transposing. Assuming that the sliding step of the window is H and the data of each window is X T k ∈ R N×J , the principal component analysis method is applied to these two-dimensional matrices [12], from which the temperature sensor data features in each window can be extracted. e projection of the original set of sample points on the a-th principal axis constitutes the synthesis variable t a (H × 1), where a � 1, 2, . . . , A. Assuming that the variation information carried by the fifth principal component 6 is represented by Var(t a ), the following relationship exists: , and a comprehensive variable t 1 is a linear combination of x(1), . . . , x(J), namely: In order to make t 1 carry the most original variation information, the variance of t 1 is required to reach the maximum value, and the variance of t 1 is In the above formula, R � X T X is the covariance matrix of X. e above problems are translated into the solution of the following optimization problems: We write λ 1 as Lagrange operator, and let We take the partial derivatives of p 1 and λ 1 of L, respectively: We obtain We assume that p 1 is the first principal axis, and t 1 � Xp 1 is called the first principal component [13], so the second principal axis p 2 is obtained by analogy, where p 2 is orthonormal p 1 , p T 2 p 1 � 0, p 2 2 , and the second principal component t 2 � Xp 2 is the second largest component carrying variation information, and Var(t 2 ) is second only to Var(t 1 ). So, we have Var(t 1 ) ≥ Var(t 2 ) ≥ · · · ≥ Var(t A ) > 0. erefore, if the data variation is used to reflect the information in the data, the first principal component t 1 carries the most information, followed by t 2 times. A total of J principal components were extracted. Matrix X is decomposed into the sum of the cross product of A subspaces, namely, principal component decomposition, and the extraction results of temperature sensor data features are obtained. e specific calculation formula is as follows: In the above formula, T and P are principal component score matrix and load matrix, respectively, t a is H × 1-dimensional principal component vector, and p a is J × 1-dimensional load vector, which is also the projection direction of principal components [14].

Data Anomaly Diagnosis Based on Deep Neural Network
Model. Deep neural networks (DNNs) can be understood as a neural network with many hidden layers, also known as deep feedforward network (DFN) and multilayer perceptron (MLP). e deep neural network has many advantages such as high speed and low error, and has been widely used in various fields. erefore, this paper uses the deep neural network model to diagnose the data anomaly of temperature sensor. e topology of deep neural network is shown in Figure 2. e measures to improve the generalization performance of the deep neural network are as follows: (1) Use more data: on the premise of conditions, obtaining as much training data as possible is the most ideal method. More data can fully learn the model and easily improve the generalization ability. (2) Use larger batches: under the condition of the same number of iterations and learning rate, using more data in each batch will help the model better learn the correct mode, and the output result of the model will be more stable. (3) Adjust data distribution: the data distribution in most scenarios is uneven. If the model learns too much about a certain type of data, its output results will tend to this type of data. At this time, the generalization ability can be improved to a certain extent by adjusting the input data distribution.
In the deep neural network, the input information is tagged, so the deep neural network can be simplified into a simple modeling unit, as shown in Figure 3.
In order to ensure the integrity of data, a decoder was added [15]. erefore, the autoencoder modeling unit is shown in Figure 4.
In order to minimize the network reconstruction error [16], this paper constructed a new multilayer autoencoder, whose structure is shown in Figure 5.
In order to minimize errors, this paper mainly uses the attention mechanism to train the deep neural network model, and the process is as follows: e usual convolution operation in the deep neural network can be formulated as follows: In the above formula, W is the 4-dimensional tensor, and W (i,j,k,l) is the weight parameter of the position of the y-th channel input in the i-th convolution kernel. e attention mechanism can further constrain and adjust each factor by observing globally and learning the relationship between each parameter and its influence on the result. After this restriction is introduced in the training process of convolution, the parameters of the convolution layer supervised by the attention mechanism can be expressed in the following form: W a (i,j,k,l) � W (i,j,k,l) · att (i,j,k,l) .
In the above formula, att is the attention weight obtained after global observation, and W (i,j,k,l) ′ obtained will be used for the final convolutional feature extraction. It can be divided into two parts: channel attention and shape attention.
e information of different channels can be considered as the image description information extracted from different angles or using different features, and the filter will combine these feature information with different weights. Some features are focused on, while others tend to be ignored. Channel attention applies this idea. e average response of the convolution kernel i to the input channel y can be represented by the average value of the filter weights of the corresponding channel, namely: e average response of these channels is then input into the full connection layer used to analyze their relationships, and the Sigmoid activation function is used as the threshold.
In this representation, the attention weight of each channel can be related to the filter parameters of other channels, introducing the interaction between channels. Similarly, the shape of the convolution kernel is usually used to describe the importance of features extracted from different positions of the filter, and the response weight of each position can be obtained by averaging the weights of all channels at that position. avg s (i,k,l) � mean W (i,j,k,l) � A similar attention model can then be used to obtain shape weights.

Coding process
Decoding process Output layer

Input layer
Hidden layer   Scientific Programming att s � sigmoid fc s avg s .

(19)
At this point, for each parameter of the convolution layer, the parameter ultimately affected by the global parameter can be obtained through formula (15). After the training of the network is completed, the weights obtained by the attention mechanism can be directly solidified on the original parameters of the convolutional layer without recalculation during the network operation. e characteristic data are input into the trained deep neural network model, and the result is the anomaly diagnosis result of temperature sensor data.

Experimental Scheme.
To verify the validity of the temperature sensor data anomaly diagnosis method based on the deep neural network designed in this paper as the research objective, a simulation experiment scheme is designed. e specific experimental scheme is as follows: (1) Experimental environment: in order to ensure the authenticity of experimental results, experimental environmental parameters need to be designed in detail in this experiment. e specific parameter settings are shown in Table 1.
(2) Experimental data: multiple types of temperature sensors are taken as research objects to keep them running, and the operating data of temperature sensors are taken as experimental sample data, and the collected data are denoised to improve the authenticity of the simulation results. Because the setting of experimental parameters will affect the simulation results, in order to maximize the accuracy of the simulation experiment, the simulation experimental parameters are adjusted many times in this experiment, and the parameters in the optimal running state of the simulation software are taken as the initial simulation parameters. (3) Experimental methods and evaluation indicators.
In this paper, reference [4] method and reference [5] method are selected as experimental comparison methods, and the practical application effects of the two methods and the proposed method are verified by comparing the error rate of feature extraction, diagnostic accuracy, and diagnostic efficiency of temperature sensor data.
Among them, the lower the error rate of temperature sensor data feature extraction, the higher the accuracy of data feature extraction, and the more accurate the result of feature extraction. e diagnostic accuracy is an important index to verify the anomaly diagnosis method of temperature sensor data. e higher the anomaly diagnosis accuracy of temperature sensor data, the more accurate the diagnosis result is. e diagnostic efficiency of temperature sensor data refers to the time it takes to diagnose temperature sensor data anomalies. e shorter the diagnostic time, the higher the diagnostic efficiency.

Data Feature Extraction
Error. e error rate of feature extraction of temperature sensor data by reference [4] method, reference [5] method, and this method is compared, and the results are shown in Figure 6.
According to the data in Figure 6, the error rate of feature extraction of temperature sensor data in reference [4] is between −12.5% and 14.65%, and that of temperature sensor data in reference [5] is between −9.6% and 12.15%. Compared with these two comparison methods, the error rate of temperature sensor data feature extraction in this method varies from −2.1% to 5.9%, which is the lowest among the three methods. e reason is that this method uses the K-means algorithm to collect the temperature sensor data in an operation cycle and uses the sliding window technology to extract the temperature sensor data features, which improves the accuracy of temperature sensor data feature extraction, and can lay a solid data foundation for subsequent diagnosis and analysis.

Diagnostic Accuracy.
e diagnostic accuracy of abnormal temperature sensor data of reference [4] method, reference [5] method, and this method is compared, and the results are shown in Figure 7.
According to the data in Figure 7, the minimum and maximum diagnostic accuracy of abnormal temperature sensor data in reference [4] are 73% and 93%, respectively, and the minimum and maximum diagnostic accuracy of abnormal temperature sensor data in reference [5] are 76% and 91%, respectively. Compared with these two methods, the anomaly diagnosis accuracy of temperature sensor data obtained by the proposed method is always above 95%, which is much higher than the two experimental comparison methods, indicating that the anomaly diagnosis results of temperature sensor data obtained by the proposed method are more accurate. e reason is that this method constructs a deep neural network model for abnormal diagnosis of temperature sensor data, inputs the characteristic data into the model, and the obtained result is the diagnosis result.

Diagnostic Efficiency.
e anomaly diagnosis time of temperature sensor data of reference [4] method, reference [5] method, and this method is compared to test the diagnosis efficiency of different methods. e results are shown in Table 2.
According to the average value of anomaly diagnosis time of temperature sensor data of different methods after multiple experiments, the diagnosis efficiency of different methods can be obtained. e average value of anomaly diagnosis time of temperature sensor data of reference [4] method is 263 ms, and the average value of anomaly diagnosis time of temperature sensor data of reference [5] method is 140 ms. Compared with these two methods, the average value of anomaly diagnosis time of temperature sensor data in this method is the lowest, only 59 ms, which proves that this method has the highest efficiency and the best practical application effect. e reason is that this method uses the K-means algorithm to collect the temperature sensor data in a running cycle, constructs a deep neural network model for abnormal diagnosis of temperature sensor data, and inputs the characteristic data into the model to realize abnormal diagnosis.

Conclusion
As people production and living standards continue to improve, various sensors has been widely applied in all fields, especially the temperature sensor because of its high precision and convenient advantages, such as the application on a large scale in the areas of agricultural production, scientific research and life, but also easy to appear abnormal temperature sensor data. erefore, it is necessary to diagnose abnormal temperature sensor data. Aiming at the problems of high error rate of current temperature sensor data feature extraction, abnormal diagnosis accuracy, and low efficiency of temperature sensor data, this paper proposes a temperature sensor data anomaly diagnosis method based on the deep neural network. Finally, a comparative simulation experiment is conducted to verify the performance of the proposed method in data anomaly diagnosis. e experimental results show that the error rate of feature extraction of temperature sensor data in this method varies from −2.1% ∼ 5.9%, the diagnosis accuracy remains above 95%, and the average diagnosis time is only 59 ms, indicating that this method has low error rate of feature extraction of temperature sensor data, high accuracy, and efficiency of abnormal diagnosis of temperature sensor data. It can fully solve the problems of traditional methods and can be widely used in the field of temperature sensor data anomaly diagnosis.
Data Availability e temperature sensor data used to support the findings of this study are available from the corresponding author upon request.