## 2 Materials and Methods
### Spatial Self-Attention Mechanism  
The attention mechanism is crucial for managing information overload by prioritizing essential information with limited computational resources. It selectively emphasizes key data (V) by filtering out less pertinent details from a larger dataset (K), calculating weight coefficients to highlight more significant information. This feature enables the model to focus on areas critical for path extraction, thus optimizing the feature extraction process and enhancing model performance.  
This study introduces a spatial self-attention mechanism to improve model performance further. To keep the network lightweight and reduce the number of parameters, this paper eschews traditional spatial and channel attention designs. Instead, it implements a modified spatial self-attention mechanism derived from a non-local self-attention framework, specifically tailored for binary classification problems, as shown in Figure 2.  
Figure 1: Architecture of the proposed IndoorPathNet.  
The process begins with a local feature \(A\) in \(R^{C\times H\times W}\). This feature is input into a convolution layer, which produces two new feature maps, \(B\) and \(C\), both of which are in \(R^{C\times H\times W}\). These maps are then reshaped to \(R^{C\times N}\), where \(N=H\times W\) denotes the total number of pixels. Following this, matrix multiplication is executed between B and the transpose of \(C\). \(A\) sigmoid layer is subsequently applied to calculate the spatial attention map, resulting in \(S\) in \(R^{N\times N}\), as specified in Equation (1). This structured approach facilitates focused processing based on the significance of spatial relationships in the data.  
\[S_{ji}=\frac{1}{1+exp(B_{i}\cdot C_{j})} \tag{1}\]  
The element \(S_{ji}\) quantifies the influence of the \(i\)-th position on the \(j\)-th position, with their correlation increasing as their feature representations become more similar. In this process, feature \(A\) is fed into a convolution layer to generate a new feature map \(D\in R^{C\times H\times W}\), which is subsequently reshaped to \(R^{C\times N}\). Following this, a matrix multiplication is conducted between \(D\) and the transpose of \(S\), and the resulting matrix is reshaped back to \(R^{C\times H\times W}\). Finally, this reshaped matrix is scaled by a parameter \(\alpha\) and combined elementwise with the original feature \(A\) to yield the final output \(E\in R^{C\times H\times W}\), as described in Equation (2). This method efficiently integrates contextual information, leveraging the spatial attention map to prioritize crucial areas for enhanced model performance.  
\[E_{j}=\text{ReLU}(x)+A_{j}=\text{max}(0,\alpha\sum_{i=1}^{N}{(s_{ji}D_{i})})+A _{j} \tag{2}\]  
The scaling parameter is initially set to zero and gradually adjusted to assign increasing weight. From Equation (2), it is inferred that the feature at each position is a weighted sum of all positional features combined with the original feature. This configuration allows for a global contextual perspective, enabling the selective aggregation of contextual information guided by the spatial attention map.