# AWEU-Net: An Attention-Aware Weight Excitation U-Net for Lung Nodule Segmentation
## 3 Proposed Methodology
### Attention Mechanism
#### 3.4.1 Position Attention-Aware Weight Excitation (PAWE)  
For accurate nodule semantic segmentation, deep learning models have to capture discriminant features of the nodules and background in a CT image. These features can be captured by aggregating the spatial context information from local features [30]. To model contextual relationships over local features, PAWE is able to enhance the local feature representation through encoding long-range contextual information. The process of PAWE can be elaborated as follows.  
The PAWE block consists of two sub-blocks: the position attention block (PAB) and the weight excitation block (WEB). To demonstrate the proposed PAWE block, let the input feature be \(Y\in\mathbb{R}^{C\times H\times W}\), where \(C\), \(H\) and \(W\) are channel, height and width, respectively (see Figure 4). In the PAB block, \(Y\) is fed into 3 convolutions of \(3\times 3\) called \(A\), \(B\) and \(C\), respectively. The first 2 produced feature maps, \(A^{p}\), \(B^{p}\in\mathbb{R}^{C/8\times H\times W}\) are provided by the first 2 convolutions \(A\) and \(B\),where \(p\) superscript is referred to as \"postion\". \(A^{p}\) and \(B^{p}\) feature maps are then reshaped into \((H\times W)\times C/8\). A matrix multiplication is applied to the transposition of \(\mathbf{A^{p}}\) and \(\mathbf{B^{p}}\), producing a spatial attention map, \(D^{p}\in\mathbb{R}^{(H\times W)\times(H\times W)}\), by using a softmax function:  
\[d^{p}_{i,j}=\frac{\exp{(A^{ip}\cdot Bj^{p})}}{\sum_{i=1}^{H\times W}\exp{(A^{ ip}\cdot Bj^{p})}}, \tag{1}\]  
Figure 3: The architecture of the proposed AWEU-Net. The PAWE and CAWE block refers to the position attention-aware weight excitation and channel attention-aware weight excitation, respectively.  
where \(s_{i,j}\) indicates the \(i\)th position's associated position of \(j\)th. The softmax function \(D^{p}\) attempts to learn the relationship between two spatial positions in the input feature maps.  
In addition, the output of the third convolutional layer \(C^{p}\in\mathbb{R}^{C<(H\times W)}\) is also reshaped to the same shape of the input feature map \(Y\) and then multiplied by a permuted order of the spatial attention map \(D^{p}\) of (1). The final output is reshaped to \(\mathbb{R}^{C\times(H\times W)}\) to provide the final feature map of PAB block, \(F\), as  
\[F_{PAB,j}=\alpha_{p}\sum_{i=1}^{H\times W}s_{i}^{p}C^{j}+Y_{j}, \tag{2}\]  
where \(\alpha_{p}\) is defined as 0 as explained in [29]. The resulting feature \(\mathbf{F}\) at each feature position is a weighted sum of all the neighbours of the original features.  
In the WEB, a sub-block for location-based weight excitation (LWE) proposed in [31] is used. The LWE provides fine-grained weight-wise attention during back propagation. The WEB shown in (Figure 4) can be defined as:  
\[F_{WEB,j}=Re_{2}(FC_{2}(Re_{1}(FC_{1}(AP(W_{WEB,j}))))), \tag{3}\]  
where \(W_{WEB,j}\) is the weights across the \(j\)th output channel. The average pooling layer, \(AP\), averages the values of each \(H\times W\). \(Re_{1}\) and \(Re_{2}\) are two ReLU activation functions. \(FC_{1}\) and \(FC_{2}\) are two fully connected layers.  
The output feature from WEB is reshaped and multiplied to the input feature map. Finally, an element-wise sum operation is performed between the feature maps from the PAB and WEB to produce the final PAWE features, as follows:  
\[\hat{Y}_{PAWE,j}=F_{PAB,j}+F_{WEB,j}, \tag{4}\]  
This process generates a global contextual description and aggregates the context according to a spatial weighted attention map by creating spatial-relevant weighted features,  
Figure 4: Illustration of the proposed PAWE block.  
which provide common weight excitation and enhance the intra-class semantic coherence of the input features maps.