Skip to main content
. 2023 Sep 30;23(19):8190. doi: 10.3390/s23198190
Algorithm 1: Algorithm for CBAM attention mechanism
Input: Network intermediate volume characteristics map
Output: Attention maps
  1: CAM performs a spatially informative aggregation operation on the feature map:
Mc(F)=σ(MLP(AvgPool(F))+(MLP(MaxPool(F)))=σW1W0Favgc+W1W0Fmaxc
  2: The channel attention map is multiplied at the pixel level with the original image:
F=Mc(F)F,
  3: SAM performs feature focus and dimensionality reduction operations on feature maps:
Ms(F)=σf7×7([AvgPool(F);MaxPool(F)])=σf7×7Favgs;Fmaxs
  4: Spatial Attention Maps are multiplied by the original map at the pixel level:
F=Ms(F)F
  5: Output CBAM processed feature maps.