# Enhancing Air Quality Prediction with an Adaptive PSO-Optimized CNN-Bi-LSTM Model
## 3 Model Introduction
### Cnn  
CNN has powerful grid data processing capabilities and was widely used in image analysis [27]. The input layer, convolutional layer, pooling layer, fully connected layer, and output layer form the main structure of the CNN. The information from the input layer is passed through the convolutional and pooling layers for feature transformation and extraction. The fully connected layer further integrates the extracted local information from the convolutional and pooling layers and maps this information to the output signal through the output layer. Figure 3 depicts the structure of a CNN, illustrating the flow of information from the input layer through the convolutional and pooling layers to the fully connected and output layers. Figure 2: Flowchart of this study. Indeed, the convolutional layer is the cornerstone of a Convolutional Neural Network (CNN), distinguished by its unique capability to automatically detect and extract features from the input data, primarily images. This layer employs small, learnable filters, commonly called convolutional kernels, which slide across the entire input matrix to perform a convolution operation. Unlike traditional fully connected layers where each neuron is connected to every neuron in the previous layer, the convolutional layer maintains a local connectivity pattern, significantly reducing the number of parameters and enabling the network to learn spatial hierarchies of features. Each convolutional kernel, through a process termed 'convolution', performs element-wise multiplication between its weights and a portion of the input (referred to as the receptive field), followed by a summation operation to produce a single value in the feature map. This operation is iteratively applied across the entire input, generating a two-dimensional (or higher, depending on the dimensionality of the input and the number of filters) feature map that encodes various aspects of the input data. The mathematical formula representing the computation at each element (pixel) in a feature map can be generically described as follows:  
\[\mathrm{X}^{\mathrm{o}}_{\mathrm{x},\mathrm{y}}=\mathrm{f}_{\mathrm{c}}\left( \sum_{\mathrm{m}=0}^{\mathrm{k}}\sum_{\mathrm{n}=0}^{\mathrm{k}}w_{\mathrm{m}, \mathrm{n}}\mathrm{X}^{\mathrm{in}}_{\mathrm{x}+\mathrm{m},\mathrm{y}+\mathrm{ m}}+\mathrm{b}\right)\]  
where \(\mathrm{X}^{\mathrm{o}}_{\mathrm{x},\mathrm{y}}\) is the output value of the feature map at \((\mathrm{x},\mathrm{y})\), \(\mathrm{X}^{\mathrm{in}}_{\mathrm{x}+\mathrm{m},\mathrm{y}+\mathrm{m}}\) is the value of the input matrix at \((\mathrm{x},\mathrm{y})\). \(w_{\mathrm{m},\mathrm{n}}\) is the weight of the convolution kernel at \((\mathrm{m},\mathrm{n})\), and \(\mathrm{b}\) is the bias of the convolution kernel. \(\mathrm{f}_{\mathrm{c}}(\cdot)\) is the selected activation function, and \(\mathrm{k}\) is the number of channels. The input matrix is usually convolved using multiple kernels. Each convolutional kernel can capture and encode a specific spatial feature information by performing the relevant operations in the input data matrix, thus generating a high-dimensional feature map enriched with that information. After that, this high-dimensional feature representation is processed by a pooling layer, which selectively retains critical information by downsampling to reduce computational complexity and dimensional redundancy in subsequent processing, thus improving computational efficiency. Since CNNs have better feature extraction for grid data, in this study, each category of the m environmental variables covering n stations was expanded into a high-dimensional construct, specifically in a matrix with m rows and n columns. A total of c categories (including meteorological parameters, air quality indicators, and spatial and temporal attributes) of data were input as multi-channel.