# Methane Gas Density Monitoring and Predicting Based on RFID Sensor Tag and CNN Algorithm
## 3 Proposed Algorithm  
### Convolutional Neural Network  
The basic structure of the CNN is shown in Figure 6. Each sample data is input in two-dimensional form, and then the hidden layer is input by kernel function. The hidden layer is mainly composed of alternately repeated convolution layer and pool layer, and the output of this layer is sampled as the next layer. The structure has a higher fault tolerance to the input samples, and can realize the hierarchical expression of data more accurately. The convolution layer is used to extract the local features of input data and consists of multiple feature matrices. Each characteristic matrix can be regarded as a plane (the same convolution kernel on the same plane), so it has the characteristics of parallel computation and greatly reduces the number of free parameters. Different planes correspond to different convolution kernels so that the extracted features are more fully demonstrated.  
The calculation process of the convolution layer is shown in Figure 7a. The calculation method is as follows:  
\[Y^{l}=f\bigg{(}\sum X^{l-1}\times K^{l}+B^{l}\bigg{)} \tag{1}\]  
In the formula, \(l\) represents the number of layers, \(f\) is the activation function, \(K\) is the convolution kernel, \(B\) is the bias, \(X\) is the input value, and \(Y\) is the output value.  
Figure 5: The whole procedure of monitoring and predicting the methane gas density.  
Figure 6: Basic structure of the convolution neural network.  
The pool layer is used to compress data on the results of the stacked layer to reduce data dimensions. The feature extracted by the pool layer has no deformation at scale and prevents over fitting. The pooling process is shown in Figure 7b, and the calculation is as follows:  
\[Y^{l}=f\bigg{(}\frac{1}{k}\sum{X^{l}}+B^{l}\bigg{)} \tag{2}\]  
A fully-connected layer is connected after the combination of some convolutional and pooling layers. The fully-connected layer shows similar function to the traditional multilayer neural network and can be applied through different classification models. The softmax regression, which can achieve fast computation and an accurate result, is the most popular output layer. The output of the softmax regression can be obtained as follows:  
\[O=\frac{1}{\sum\limits_{j=1}^{n}{\exp\left({X\times K_{j}+B_{j}}\right)}} \left[{\begin{array}{*{20}{c}}{\exp(X\times K_{1}+B_{1})}\\ {\exp(X\times K_{2}+B_{2})}\\ \cdots\\ {\exp(X\times K_{n}+B_{n})}\\ \end{array}}\right] \tag{3}\]  
In the learning process, the back-propagation algorithm is adopted, that is, the weight matrix is adjusted by reducing the mean square error (MSE) of the ideal output and the actual output. The MSE is calculated as follows:  
\[\text{MSE}=\frac{1}{2}\sum\limits_{j}{\left({y_{j}-o_{j}}\right)}^{2} \tag{4}\]  
Here, \(y_{j}\) is the actual output and \(o_{j}\) is the ideal output.  
The essence of the convolution neural network is to learn a number of filters that can extract the characteristics of the input data, extract the topological features hidden in the data through layer-by-layer convolution and pooling, and finally obtain the input data with translation, rotation, and scaling, the characteristics of the nature of change. This method can learn the features implicitly from the data, avoid explicit feature extraction, and achieve higher accuracy and efficiency than traditional neural networks.  
Figure 7: Schematic diagram of the convolution and pooling process: (**a**) convolutional process schematic; (**b**) pooling process schematic.