Pytorch實作系列 — SENet and its variants (2)

mz bai
7 min readJul 14, 2024

--

CBAM是由 Woo et al. 在 CBAM: Convolutional Block Attention Module(2018, 韓國科學技術院 KAIST)提出,相較SENet只使用特徵資訊計算注意力權重,也同時使用空間資訊獲得更多的資訊。

對SENet不熟悉,可參考

網路概念

與Squeeze and excitation相比,CBAM更使用了空間資訊做注意力權重的計算,達到跨通道的資訊混合。

CBAM uses channel attention and spatial attention sequentially

網路結構

CBAM同時使用Max pooling和Average pooling,以期增加空間不變性,在通道注意力混合不同空間資訊,而在空間注意力混合不同通道資訊,再順序性地組合兩區塊。

CBAM uses max pooling and average pooling

Bottleneck attention module(BAM)強調在殘差區塊的外部使用注意力機制,結構上偏向平行組合空間注意力區塊和通道注意力區塊。

BAM follows every bottleneck
BAM uses channel attention and spatial attention parallelly

Coordinate attention 在CBAM的基礎上,提出藉由組合X方向或Y方向的注意力結果,即可同時達到空間注意力區塊和通道注意力區塊的效果。整體而言也會有較低的計算量。

Coordinate attention aggregates each dimension’s pooling as attention weight

Residual attention network 採用類似UNet的子網路建立mask branch,計算出注意力權重來篩選特徵圖上的重要資訊,相較於其他注意力網路的變形,該網路著重在訊息傳遞而非特徵融合。

Residual attention network uses two convolution branch instead of pooling
Residual attention network has a new structure

資料集

Animals-10,一個包含十種動物,兩萬八千多張照片的資料集。

評估

CBAM 訓練準確度84.6%

CBAM confusion matrix(training)

BAM 訓練準確度84.1%

BAM confusion matrix(training)

Coordinate attention 訓練準確度87.9%,模型稍微小一些。

Coordinate attention confusion matrix(training)

Residual attention network 訓練準確度71.3%,模型實作參考caffe原始碼,參數是ResNet50的兩倍以上、運算量大、訓練時間長。

Residual attention networkconfusion matrix(training)

實作

參考

--

--

mz bai
mz bai

Written by mz bai

Math is math, math is universal Code is code, code is horrifying unique.

No responses yet