## 3 Methodology
### Self-Attention Mechanism
Excluding the dropout layer caused the accuracy to decline to 98.23%, while the detection time improved to 17.22 s, suggesting that while regularization adds slight computational overhead, it helps maintain generalization. In the most minimal setup, using only the Conv1D layer, the model achieved significantly lower accuracy at 90.88%, with a detection time of 20.53 s. This result confirms that relying solely on convolutional feature extraction is insufficient for capturing the temporal dependencies inherent in WSN traffic data. Overall, the ablation results affirm that each component particularly the recurrent and attention mechanisms plays an essential function in achieving the high accuracy and robustness of the final model. The integration of these layers contributes meaningfully to both predictive performance and temporal learning, validating the design of the proposed architecture. The impact of removing each component of the model is shown in Table 5.

## 6 Results

The proposed Conv1D-GRU-Self-Attention model was evaluated on a preprocessed and balanced version of the WSN-DS dataset using several standard performance metrics to assess classification accuracy, detection robustness, and real-time efficiency. The evaluation focused on both predictive performance and operational responsiveness, which are crucial in WSN intrusion detection systems. Figure 2 illustrates the training and validation performance graphs, showcasing the efficacy and stability of the proposed Conv1D-GRU-Self-Attention model throughout 10 epochs. The accuracy plot illustrates a consistent growth in both training and validation accuracy, with training accuracy reaching about 98.4% and validation accuracy slightly exceeding this at around 98.8%, indicating robust generalization to novel data and little overfitting. The loss curves demonstrate a consistent drop, with training loss reducing from 0.18 to below 0.05, while validation loss mirrors this pattern, ultimately stabilizing around 0.04. The strong correspondence between training and validation curves in both accuracy and loss indicates that the model is well-regularized and well trained, making it highly dependable for multi-class intrusion detection in WSNs. The precision was recorded at 98.63% in Figure 3, confirming that the majority of positive predictions were indeed true intrusions. Likewise, the recall value of 98.60% \begin{table}
\begin{tabular}{c c c c} \hline \hline
**Configuration** & **Accuracy (\%)** & **Detection Time (s)** & **Observation** \\ \hline Full Model (Conv1D–GRU–Self Attention) & 98.60 & 53 & \begin{tabular}{c} Baseline performance with all \\ components included \\ \end{tabular} \\ \hline Without Self-Attention Layer & 98.48 & 25.14 & \begin{tabular}{c} Slight accuracy drop; slower inference \\ due to loss of contextual focus \\ \end{tabular} \\ \hline Without Dense Layer & 98.33 & 22.94 & \begin{tabular}{c} Dense layer aids in refining features \\ before classification \\ \end{tabular} \\ \hline Without Second GRU Layer & 98.31 & 20.53 & \begin{tabular}{c} Less depth reduces detection time, but \\ minor accuracy drop observed \\ \end{tabular} \\ \hline Without Dropout Layer & 98.23 & 17.22 & \
\begin{tabular}{c} Overfitting risk increases; faster but \\ less generalizable \\ \end{tabular} \\ \hline Only Conv1D Layer & 90.88 & 20.53 &
\begin{tabular}{c} Major accuracy drop; insufficient \\ temporal learning capacity \\ \end{tabular} \\ \hline \hline \end{tabular}
\end{table} 
Table 5: Ablation experiment. Figure 2: Accuracy and Loss over epochs. demonstrates the model's strong capacity to detect nearly all relevant attack events without omission. In terms of class discrimination in Figure 4, the ROC-AUC score reached 0.9994, which suggests the model is nearly perfect in distinguishing between attack and normal traffic patterns. This is particularly valuable for multi-class classification in cybersecurity applications, where subtle differences in traffic behavior must be captured accurately.