## 5 Results and Discussion
### A Brief Description of the Models Used for Comparison  
- GRU-Autoencoder: This model is built around the Gated Recurrent Unit (GRU), a type of RNN that is suitable for capturing sequential patterns while avoiding some of the gradient vanishing issues associated with traditional RNNs. Algorithm 2 starts by defining the input shape, which provides flexibility in handling sequences of different lengths and dimensions. The 'inputs' variable is initialized as the input layer and holds the data in the specified shape. The core of the model consists of an encoder-decoder architecture. In the encoding phase, the input sequence is processed by a GRU layer with 64 units. This GRU layer effectively compresses the input data into a fixed-size latent representation that is stored in the 'encoded' variable. The'return_sequences' parameter is set to 'False', which means it will only record the final hidden state of the GRU and summarize the input sequence. The decoding phase starts with a 'RepeatVector' layer, which repeats the latent representation to match the length of the original input sequence. Another GRU layer is then used to decode the repeated representation, effectively reconstructing the \begin{table}
\begin{tabular}{c c c c} \hline \hline
**Layer (type)** & **Output Shape** & **Param \#** & **Connected to** \\ \hline Layer\_normalization\_5 (LayerNormalization) & (None, 100, 32) & 64 & [tcn\_7[0][0]] \\ concatenate\_1(Concatenerate) & (None, 100, 96) & 0 & [layer\_normalization\_3[0][0], layer\_normalization\_4[0][0], layer\_normalization\_5[0][0], layer\_2(Dense) & (None, 100, 16) & 1552 & [concatenate\_1[0][0]] \\ Multi\_head-attention\_1 (Multiheadattention) & (None, 100, 16) & 2160 & [dense\_2[0][0], dense\_2[0][0]] \\ tcn\_8(TCN) & (None, 100, 32) & 45,032 & [multi\_head-attention\_1[0][0]] \\ dense\_3 (Dense) & (None, 100, 4) & 132 & [ten\_8[0][0]] \\ \hline \hline \end{tabular}
\end{table} 
Table 2: _Cont._  
Figure 6: Loss curves for the anomaly detection model, showing a rapid decrease and subsequent stabilization in both training and validation loss over 100 epochs. input sequence. By setting'return_sequences' to 'True', this GRU layer generates an output sequence that closely resembles the original input sequence. The last step involves using the 'TimeDistributed' layer along with a 'Dense' operation. This combination allows each time step in the output sequence to be reconstructed independently, effectively mapping the latent representation to the original data space. The reconstructed sequence is stored in the 'decoded' variable. ```
1:functionBUILD_GRU_AUTOENCODER(input_shape)
2: inputs \(\leftarrow\) Input(shape=input_shape)
3: encoded \(\leftarrow\) GRU(64, return_sequences=False)(inputs)
4: decoded \(\leftarrow\) RepeatVector(input_shape[0])(encoded)
5: decoded \(\leftarrow\) GRU(64, return_sequences=True)(decoded)
6: denseLayer \(\leftarrow\) Dense(input_shape[\(-1\)])
7: decoded \(\leftarrow\) TimeDistributed(denseLayer)(decoded)
8: autoencoder \(\leftarrow\) Model(inputs, decoded)
9: autoencoder.compile(optimizer=Adam(learning_rate=0.001), loss='mean_squared_error')
10:return autoencoder
11:endfunction
```  
**Algorithm 2** Pseudocode for building a GRU-Autoencoder  
- LSTM-Autoencoder: This model is a neural network architecture commonly used for sequencing tasks. The model uses Long Short-Term Memory (LSTM) cells, a type of recurrent neural network (RNN) that efficiently captures temporal dependencies in sequential data while mitigating the vanishing gradient problem. Algorithm 3 starts by specifying the input shape and provides the flexibility to handle sequences of different lengths and dimensions. The 'inputs' variable is initialized as an input layer, which can hold data in the specified shape. The core architecture revolves around an encoder-decoder structure. In the encoding phase, the input sequence is processed through an LSTM layer consisting of 64 units.