bam
**BAM** (Bottleneck Attention Module) is a **parallel dual attention mechanism that computes channel and spatial attention maps simultaneously** — then combines them with an element-wise addition, applied at bottleneck points between stages of a CNN.
**How Does BAM Work?**
- **Channel Branch**: Global average pooling -> MLP -> channel attention vector.
- **Spatial Branch**: 1×1 conv (reduce channels) -> dilated convolutions -> 1×1 conv -> spatial attention map.
- **Combination**: $M(F) = sigma(M_c(F) + M_s(F))$ (element-wise addition, then sigmoid).
- **Placement**: Between CNN stages (e.g., between ResNet stages), not within each block.
- **Paper**: Park et al. (2018).
**Why It Matters**
- **Stage-Level Attention**: Applied between stages rather than within every block -> lower total overhead.
- **Parallel Processing**: Channel and spatial branches computed in parallel (unlike CBAM's sequential approach).
- **Complementary to CBAM**: BAM for between-stage attention, CBAM for within-block attention.
**BAM** is **the bottleneck attention gate** — a dual-branch attention module placed at the transition points between CNN stages.