CBAM: Convolutional block attention module

Inc Lomin's avatar
Jun 23, 2019
CBAM: Convolutional block attention module
Woo, Sanghyun, et al. "CBAM: Convolutional block attention module." Proceedings of the European Conference on Computer Vision (ECCV). 2018.
본 논문은 Image Detection 또는 Classification 태스크 등에서 attention 개념을 이용하여 backbone 네트워크의 성능을 개선하는 방법에 관한 것이다. 저자들이 모두 카이스트와 루닛, Adobe 소속의 한국인 연구자들로 구성되어 있다.
해당 논문은 ECCV 2018에서 발표 되었으며, 공식 소스코드(pytorch)와 저자가 작성한 논문 설명에 관한 블로그가 공개되어 있다.
저자가 작성한 루닛 테크블로그 글
 

Introduction

Motivation

CNN 구조에서 attention은 feature selection의 역할을 해왔다.(주로 VQA, Image Captioning 등에서 많이 활용). 이러한 개념을 일반적인 image classification 또는 detection 태스크에 활용하여 성능을 높이기 위해, 네트워크의 backbone에 self-attention을 수행하는 모듈을 추가해 보자.

Previous Work: BAM(Bottleneck Attention Module)

CBAM의 저자들은 attention을 CNN에 적용한 이전 연구로서 BAM을 소개한바 있다.
Jongchan Park*, Sanghyun Woo*, Joon-Young Lee, and In So Kweon: “BAM: Bottleneck Attention Module” , in BMVC 2018 (Oral)
notion image
BAM은 CNN 네트워크에서 spatial resolution이 줄어드는 구간(=spatial pooling)인 Bottleneck 구간에 위치하면서, 3D feature 맵의 채널 방향 attention과 spatial 방향 attention을 각각 구한 후, 이로부터 3D attention을 생성하여, 입력 3D feature map의 attention feature를 계산한다.
notion image

Contribution

본 논문에서는 channel 방향 attention과 spatial 방향 attention을 각각 계산한 후에 입력 피쳐맵에 attention 연산을 시퀀셜하게 적용함으로서, 3D feature map에서 'What'(=channel attention)과 'Where'(=spatial attention)을 효과적으로 선별하는 attention 모듈을 제안하였다. 제안된 CBAM은 resnet의 residual path에 추가적으로 덧붙여서 사용되고, 추가되는 연산량이 전체 연산량에 비해 매우 작음에도 불구하고, detection과 classification 태스크에서 의미 있는 성능 향상 효과를 가져다 주었다.

Proposed Method: Convolutional Block Attention Module

 
notion image
CBAM은 입력 3D feature에 대해 채널방향 attention feature를 구한 후, spatial 방향 attention feature을 연산하는 시퀀셜한 구조로 구성된다. 이를 수식으로 나타내면 다음과 같다.
notion image
 
notion image
CBAM은 ResNet의 ResBlock 내의 conv path의 뒤에 추가된다.
 

Channel Attention Module

 
notion image
기존의 CNN 기반 attention 연구에서 각 채널마다의 attention weight를 구하는 일반적인 방식은 average pooling을 각 채널의 spatial feature map에 적용하여 하나의 스칼라 값을 계산하는 것이었다. 하지만, 제안 방법에서는 max pooling을 병렬로 함께 수행하여 얻어진 각각의 채널 크기의 vector를 1개의 hidden layer를 가진 Shared MLP(=fully-connected layer)에 통과 시켜 최종 attention vector를 얻는다. 여기서 Shared의 의미는 max pooled feature와 average pooled feature가 동일한 MLP를 통과한다는 의미이다.(네트워크 전체의 MLP가 모두 share된 다는 의미는 아닌 것으로 추정됨.)
이 모듈의 연산을 수식으로 나타내면 다음과 같다.
notion image
참고로 위 수식에서 시그마는 sigmoid activation을 의미한다.
 

Spatial Attention Module

notion image
Spatial Attention Module에서는 채널방향 pooling 통해 spatial attention weight map을 만들어 낸다. Channel Attention Module과 마찬가지로, MaxPool과 AvgPool를 동시에 수행한 후, 두 weight map을 concat한 feature를 7x7 conv layer와 sigmoid activation을 통과 시켜 최종 Spatial Attention을 만들어 낸다.
이 모듈의 연산을 수식으로 나타내면 다음과 같다.
notion image

Arrangement of attention modules

위 두개의 모듈은 각각 feature map에서 'What'과 'Where'를 찾는 역할을 한다. 이 두개의 모듈은 시퀀셜 하게 배치되거나 또는 병렬로 배치 될 수가 있다. 논문에 따르면, 시퀀셜하게 배치하는 것이 실험에서 더 높은 성능을 보여줬다고 한다.
내 개인적인 해석으로는 시퀀셜하게 attention을 계산하는 경우 3D feature에서 관심이 있는 feature를 특정하는 것을 2D+2D의 연산으로 두 단계에 걸쳐 범위를 좁혀가는데 비해, 병렬화 하게 되면 각각의 모듈은 전체 3D feature 안에서 관심 영역을 찾아야 하는 문제를 풀게 된다. 따라서, 그 검색 범위가 늘어나게 되어 효과적인 attention 계산이 더 어렵게 되는 것으로 볼 수도 있다.

Experiment

Ablation Studies

Channel Attention Methods 비교
AvgPool과 MaxPool을 동시에 사용하는 것이 효과적
notion image
Spatial Attention Methods 비교
Spatial Attention을 계산하기 위해 사용될 수 있는 방법으로 output channel 수가 1인 1x1 conv를 사용할 수 있다. 아래 비교 실험에서는 1x1 conv vs. avg&max pooling 레이어의 조합과, 해당 조합 뒤의 conv layer에서 커널 사이즈에 따른 성능을 비교하였다. 이 때, avg&max pooling + k=7 conv 조합의 성능이 가장 높았다.
notion image
Combining Methods 비교
notion image

Image Classification

제안 방법은 이미지넷 classification에서 다양한 종류의 ResNet 모델에 대해 모든 경우 성능 향상 효과를 보여 주었다.
notion image
notion image

Network Visualization with Grad-CAM

notion image

MS COCO Object Detection

notion image

VOC 2007 Object Detection

notion image

Conclusions

제안 방법은 매우 가볍고, 구현이 간단한 attention 모듈을 통해 기존의 backbone 네트워크의 성능을 효과적으로 향상 시킬 수 있는 방법이다. 이러한 장점들로 인해 앞으로 매우 많은 연구에서 이 모듈을 사용할 것으로 예측된다.
 
Share article