# Single-Shot Global and Local Context Refinement Neural Network for Head Detection
## 3 Our Approach
### Global Context Refinement Module  
The standard Non-local (NL) [30] is responsible for reinforcing the features of the query location by assembling features from other locations. The SNL [12] block is the simplified version of NL, which aims to compute a global attention map and shares this attention map for all query positions. SNL has a lower computation cost than and similar performance to NL. In Figure 2a, the detailed structure of the SNL block is illustrated. We denote \(\mathbf{x}=\{\mathbf{x}_{i}\}_{i=1}^{H\cdot W}\) as a feature map whose height is \(H\) and width is \(W\). \(\mathbf{x}\) and \(\mathbf{y}\) represent the input and output of the SNL, respectively. The process of SNL block can be formulated as follows:  
\[\mathbf{y}_{i}=\mathbf{x}_{i}+W_{p}\sum_{j=1}^{H\cdot W}\frac{\exp(W_{k} \mathbf{x}_{j})}{\sum\limits_{k=1}^{H\cdot W}\exp(W_{k}\mathbf{x}_{m})} \mathbf{x}_{j} \tag{5}\]  
where \(i\) is the query position's index and \(j\) traverses all possible positions. Furthermore, \(W_{v}\) and \(W_{k}\) denote linear transformation matrices, which are both \(1\times 1\) conv.  
When a feature map enters the SNL, the SNL first reduces the number of channels to 1 before using softmax for the global system to obtain a response map. The matrix multiplication for the features of the original input, which is the process of modeling long-range dependencies between each pair of points, is then performed using the response graph. Additionally, the multiplication results are added to the original input element-wise, resembling a residual structure. The reason why SNL can generate the response map with only one channel is that [12] discovered that the response maps of different query positions in NL are similar, so we only need to learn one to replace the others, thus greatly reducing the computational complexity.  
[PERSON] et al. [33] point out that, in the deep ConvNet, high-resolution maps have low-level features that hurt their representational capacity, while low-resolution maps have stronger semantics but coarser spatial representation ability. We rely on a certain architecture, the global context refinement module (GRM), which refines the global context via a top-down pathway and lateral connections in order to obtain a global context with strong representational ability and precise spatial positioning. Figure 2b depicts the basic block architecture of the GRM.  
All the low-level features go through a \(1\times 1\) convolutional layer to shrink the channel's dimensions. On account of the limited capability of the bilinear upsampling, our model applies a \(3\times 3\) transposed convolution to upsample the resolution of high-level features by a factor of \(2\) (\(kernel=4,stride=2\)). Then, using element-wise addition, the low-level feature map with reduced dimensions is combined with the corresponding upsampled feature map. For fused features, although parameters of SNL are much less than those of NL, we further reduce the channel dimensions through a \(1\times 1\) convolution for less computational complexity. Finally, the output feature map of \(1\times 1\) is used as the input of the SNL to obtain the refined global context by building long-range dependencies between similar pixels. We denote \(M_{i}(i=2,3,4)\) as the output as the GRM block which merges feature maps of \(S_{i}\) and \(S_{i+1}(i=2,3,4)\). In particular, \(M_{5}\) is denoted as the first GRM block, which is only related to \(S_{5}\) and has no upsampling or element-wise addition operator.