## 3 Materials and Methods
### Combining Adaptive Ensemble Attention with GAN
It is typically computed as:  
\[SA=Softmax\ \left(\frac{QKt}{sqrt(dk)}\right)*V \tag{8}\]  
where  
* \(Q\), \(K\), and \(V\) are the query, key, and value matrices, respectively, derived from the input \(X\). * dk is the dimensionality of the query and key vectors. * The Softmax operation ensures that the attention weights are normalized. Spatial attention focuses on the important regions in the image. It can be computed by applying a convolutional layer followed by a sigmoid activation to highlight the most relevant spatial regions:  
\[SPA(X)=\sigma(Conv\theta(X)) \tag{9}\]  
where:  
\(Conv\theta\) is a convolutional layer with parameters \(\theta\), designed to output a spatial attention map, \(\sigma\) is the sigmoid function, ensuring the attention map is between 0 and 1. Channel attention recalibrates the feature maps to emphasize important channels and suppress irrelevant ones. This is typically computed using global average pooling followed by a learned fully connected layer:  
\[CA(X)=\sigma(W2\cdot ReLU(W1\cdot GlobalAvgPool(X))) \tag{10}\]  
where:  
* GlobalAvgPool (X) is a global average pooling operation over the spatial dimensions \(\text{WH}\times\text{W}\). * \(W1\) and \(W2\) are learned weight matrices, \(\sigma\) is the sigmoid activation function. The adaptive ensemble of these attention mechanisms is a weighted combination of the three attention maps. Let \(\alpha SA\), \(\alpha SPA\), and \(\alpha CA\) be the adaptive weights assigned to self-attention, spatial attention, and channel attention, respectively. The combined attention can be written as:  
\[AEA(X)=\alpha SA\cdot SA(X)+\alpha SPA\cdot SPA(X)+\alpha CA\cdot CA(X) \tag{11}\]  
where:  
\(\alpha SA+\alpha SPA+\alpha CA=1\) to ensure a normalized combination. The AEA combines three attention mechanisms--self-attention (\(SA\)), spatial attention (\(SPA\)), and channel attention (\(CA\))--through a weighted sum, where the weights (\(\alpha SA\), \(\alpha SPA\), \(\alpha CA\)) adaptively adjust based on the input image and driving scenario. The sum of the weights equals 1, ensuring a normalized combination. To realize the AEA mechanism described in Equation (11), a weighted summation module was implemented that combines the outputs of the three attention branches: the \(SA\), \(SPA\), and \(CA\). Each branch processes the  
where \(\beta_{i}\) are unconstrained learnable parameters and \(\alpha_{i}\) are the normalized attention weights. This fusion layer is implemented as a lightweight module and placed after the feature extraction block. The resulting attention-enhanced feature map \(AEA(X)\) is then passed to the segmentation head for prediction. This adaptive fusion enables the model to emphasize the most informative attention mechanism dynamically, based on the input context. In the proposed model, the input driving scene image from the BDD100K dataset is first fed into a Generator network that integrates an AEA mechanism. This module combines self-attention, spatial attention, and channel attention adaptively to focus on the most relevant features of the scene, such as vehicles, roads, and pedestrians. The Generator processes these features and produces a pixel-wise segmentation mask that classifies each region of the image. To ensure the segmentation output is both accurate and realistic, the model employs a GAN framework, where the Discriminator receives both the real image-ground truth mask pair and the real image-generated mask pair. It evaluates how closely the generated mask resembles the true segmentation. This adversarial setup enables the Generator to continuously refine its output based on feedback from the Discriminator. Figure 1 shows the proposed architecture. The independent application of self-attention, spatial attention, and channel attention enhances segmentation; however, their integration within an Adaptive Ensemble Attention mechanism significantly elevates segmentation performance [31].