# Noise-Tolerant Data Reconstruction Based on Convolutional Autoencoder for Wireless Sensor Network +
## 4 Methodology
### Convolutional Autoencoder for Data Reconstruction  
A reconstruction method called an autoencoder (AE) [30] attempts to learn an approximation to the identity function, that is, \(x=f(x)\), where \(x\) is the input and \(f(x)\) is the output. The bottleneck layer contains fewer nodes than the previous layers to obtain a representation of the input. The bottleneck layer encodes the underlying data structure (typically in compressed form). Subsequently, the encoder layers compress the data, and the decoder layers decompress it. Unlike artificial neural networks, the AE does not use information from the area around the input data. In contrast to other neural network designs that employ stacking, the convolution process takes advantage of the spatial and temporal data structures to find correlations more quickly. Two ideas, convolution and autoencoding, are combined [31] to find underlying features in the data while retaining the neighborhood relationships between the pixels. They begin with convolutional layers that extract features, followed by bottleneck layers that employ feature maps to compress the data. The decoder, which completes the reconstruction, follows. Owing to the preservation of the 2D input data structure and the fact that each feature does not need to be connected to the global scale, a CNN-based AE (CAE) is far more resilient than AE and can rebuild images using small patches rather than requiring complete image information [32]. A CAE model, which is a powerful tool for compressing and reconstructing data, is described in Figure 5. The model is made up of two main kernel networks, the encoder and decoder, which work together to encode and decode data, respectively. Convolution layers are used in both the encoder and decoder kernels to extract the necessary information from the input data and reconstruct it using the bottleneck layer. To further improve the performance of the AE model, dense layers are employed between the AE and decoder kernels. These layers serve to enhance the encoding and  
Figure 4: Formatting input data for the CAE architecture in a WSN. Figure 5: Architecture of the CAE. decoding processes, thereby improving the overall performance of the network for data reconstruction. In this study, careful consideration was given to the number of dense layers used in the model. After evaluating performance, it was determined that five dense layers provided optimal results. Notably, a symmetric dense layer network is used for encoding and decoding purposes, ensuring that the number of nodes in dense layers 1 and 5 is equal, and layers 2 and 4 are equal. By carefully considering the structure of the CAE model, including the use of convolution and dense layers, this study has successfully developed a powerful tool for data reconstruction. As seen in Figure 5, the affected data from 20 sensors \(S_{i}\) are composed of the missing data due to the extreme weather conditions and noise due to internal events. After the training process, the affected data are reconstructed to become the data \(\hat{S}_{i}\) as close to the data \(S_{i}\) as possible. In the training process, the loss function of the mean squared error (MSE) is used and minimized by the CAE network model to make the output data \(\hat{Y}\) approximate the ground truth \(Y\) as closely as possible. This can be expressed as follows:  
\[\mathcal{L} =\frac{1}{K_{\text{train}}}\sum_{i=1}^{K_{\text{train}}}||\hat{Y} _{i}-Y_{i}||^{2}\] \[=\frac{1}{K_{\text{train}}}\sum_{i=1}^{K_{\text{train}}}\sum_{m=1 }^{M}\big{(}\hat{S}_{i,m}-S_{i,m}\big{)}^{2}, \tag{24}\]  
where \(K_{\text{train}}\) denotes the number of training data points in each batch. Backpropagation is used to update the weights of the layers using the gradient descent method, as follows:  
\[