본문 바로가기

인공지능/Python

SPP(Spatial Pyramid Pooling) 와 ASPP(Atrous Spatial Pyramid Pooling)의 차이점(Multi-scale representation)

목차

     

    SPP(Spatial Pyramid Pooling)

    SPP는 CNN에서 입력 이미지의 크기 (H, W)에 상관없이 항상 동일한 feature를 추출하기 위해 고안된 방법으로 FC layer에 들어가기 직전인 CNN의 마지막 레이어의 feature map에 적용된다. 임의의 크기로 입력된 feature map에서 3개의 다른 스케일로 max pooling을 진행한다. 논문에서는 4x4, 2x4, 1x1의 3개의 다른 스케일을 적용했는데 여기서 말하는 4x4, 2x2, 1x1는 픽셀의 크기가 아닌 패치(patch)의 개수를 의미한다. 즉 4x4는 feature맵을 4x4의 패치로 잘라서 maxpooling을 하겠다는 의미이다. 예시를 들면 feature map의 크기가 8,8일 경우 (H,W; 여기서 배치사이즈와 채널 갯수는 고려하지 않음) 4x4 크기의 패치로 자르면 하나의 패치당 2x2의 픽셀을 가지게 된다.

    SPP 네트워크 구조(He, Kaiming, et al. "Spatial pyramid pooling in deep convolutional networks for visual recognition."  IEEE transactions on pattern analysis and machine intelligence  37.9 (2015): 1904-1916.)

     

     

    위의 SPP를 실제 예시를 들어서 설명해 보겠다. 임의의 feature map이 있다고 가정했을때 4x4, 2x2, 1x1 patch를 각각 적용해서 pooling한 output이 존재한다. SPP output을 flatten하여 concat하면 classification을 위한 FC layer에 연결될 준비가 끝난 것이다. 

    위 예시처럼 SPP는 입력 feature map의 크기가 어찌되었던 patch만큼의 구역으로 나누어 pooling을 하고, output을 합쳐서 하나의 고정된 길이(Fixed-length representation)의 벡터로 바꿔주기 때문에 더 이상 CNN이 입력 이미지의 크기를 고정시킬 필요가 없어졌다. 또한 기존의 convolution과 다르게 multi-scale의 feature representation을 얻을 수 있다.

     

     

    ASPP(Atrous Spatial Pyramid Pooling)

    pooling을 multi-scale로 하는 SPP와 다르게 convolution 할 때 dilation을 적용한다. Dilation는 convolution filter사이의 간격을 의미하는 것으로 기본값은 1을 가진다. dilation이 1보다 클 경우 filter 사이의 간격이 벌어져 feature map에서 더 넓은 범위를 데이터를 얻을 수 있다. ASPP 에서는 dilation을 rate로 표현하고 output stride에 따라 달라진다. 

    ASPP(Atrous Spatial Pyramid Pooling)

    ASPP 는 SPP와 다르게 max pooling이 없기 때문에 입력과 출력의 크기가 같으며, 해상도가 낮아지지 않는다.

    ASPP(Atrous Spatial Pyramid Pooling)

    출력이 vector인 SPP와 다르게 ASPP는 출력이 2D feature map형태가 유지된다. 또한 일반적인 convolution을 쓰지 않고 Dilated convolution을 쓰기 때문에 계산량을 증가시키지 않고도 넒은 범위의 context를 얻을 수 있다. 

     

    Reference

    1) He, Kaiming, et al. "Spatial pyramid pooling in deep convolutional networks for visual recognition." IEEE transactions on pattern analysis and machine intelligence 37.9 (2015): 1904-1916.

    2) Chen, Liang Chieh, et al. "Deeplab: Semantic image segmentation with deep convolutional nets, atrous convolution, and fully connected crfs." IEEE transactions on pattern analysis and machine intelligence 40.4 (2017): 834-848.