## 2 Materials and Methods
### Proposed Deep-Learning Models
#### 2.2.2 Variable Length-GRU Model  
In contrast to the stranded partitioned architecture of the NN edge device model, the GRU-based model leverages the temporal modeling capabilities of recurrent neural networks more effectively. This model is structured to handle sequential data with a fixed number of timesteps and feature attributes, and it is specifically tailored for AQI forecasting using both meteorological and particulate matter measurements. The inputs are formatted as one-dimensional vectors of length \(t\), where \(t\) denotes the number of timesteps. Before entering the GRU layers, each input vector is reshaped into a three-dimensional tensor of shape\((n,\frac{t}{k},k)\), where \(n\) is the number of samples, \(k\) is the number of feature attributes, and \(\frac{t}{k}\) represents the sequence length. The model's core consists of \(n\) stacked GRU layers containing \(m\) units. All but the final GRU layer returns full sequences to preserve temporal context across layers. The final GRU layer outputs a fixed-length vector representation of the input sequence, which is passed through a series of fully connected layers. Depending on the value of \(m\), the dense block behaves accordingly:  
* For smaller values of \(m\leq 64\), a single dense layer with \(m\) neurons is applied. * For larger values of \(m>64\), the dense block consists of a sequence of layers starting from \(m\). This halves in size each time until reaching 64, allowing for a gradual dimensionality reduction. The final output layer consists of \(\ell\) neurons corresponding to the number of AQI values predicted. The number of output neurons \(\ell\) is not chosen arbitrarily but is derived as a function of the input sequence length \(t\). Specifically, it follows the relation shown in Equation (2):  
\[\ell=2^{\log_{2}(t)-5}=\frac{t}{32}. \tag{2}\]  
Formally, let \(x\in\mathbb{R}^{t\times k}\) represent a single flattened input sequence. The transformation applied by the model is summarized in Equation (3). \[x\xrightarrow{\text{Reshape}(\frac{t}{k})\times k}x^{\prime}\xrightarrow{ \text{GRU}(m)\times n}h\xrightarrow{\text{Dense block}}z\xrightarrow{\text{Dense}(\ell)}\hat{y}, \tag{3}\]  
Figure 2: slideNN model configurations (strands): (**a**) Model 1, (**b**) Model 2, (**c**) Model 3, and (**d**) Model 4.  
where \(x^{\prime}\) is the reshaped input, \(h\) is the output of the final GRU layer, \(z\) is the output of the dense block, and \(\hat{y}\) is the final output vector of the predicted AQI values. The architecture allows for flexible hyperparameter tuning in terms of the number of GRU layers (\(n\)), the size of each layer (\(m\)), the timestep length (\(t\)), and the number of output values (\(\ell\)). Different architectural results and GRU layer configurations were implemented depending on whether the model was intended for edge or cloud computing environments. These architectural designs are illustrated in Figures 3 and 4, corresponding to the edge and cloud settings, respectively. In the edge-case GRU, each configuration consistently featured two GRU layers (dual-layered with the first layer with return sequences set to True), with the number of GRU cells varying between 16, 32, 64, and 128, depending on the input size. Additional layers can be added on demand with return sequences during stranded GRU model calls, provided the number of cells remains the same (we used a single layer). All GRU layers end in a final GRU layer with return sequences equal to False and the same number of cells as the previously set GRU layers. For configurations where the number of GRU cells reached above 64 (which only occurred in the last configuration of the edge case), the subsequent dense layers were reduced by a power of two at each step until reaching 64 cells, promoting efficient computation and compactness suitable for constrained environments.