https://www.boostcourse.org/ai111


Convolution

  • Continuous convolution
    $(f*g)(t) = \int f(\tau)g(t-\tau)d\tau = \int f(t-\tau)g(t)d\tau$


  • Discrete convolution
    $(f*g)(t) = \sum_{i=-\infty}^{\infty} f(i)g(t-i) = \sum_{i=-\infty}^{\infty} f(t-i)g(i)$


  • 2D image convolution
    $(I*K)(i, j) = \sum_{m}\sum_{n} I(m,n)K(i-m,j-n) = \sum_{m}\sum_{n} I(i-m,i-n)K(m,n)$


스크린샷 2023-05-28 오후 11 07 20

스크린샷 2023-05-28 오후 11 07 35

  • 3x3 convolution filter를 7x7 image에 찍으면 해당 위치에 있는 convolution filter값과 이미지의 픽셀값을 곱해서 더하면 output의 $O_{11}$ 값이 됨

  • Blur, Emboss, Outline 등에 활용


RGB image convolution

스크린샷 2023-05-28 오후 11 30 57

스크린샷 2023-05-28 오후 11 31 33

  • 여러 개의 채널을 갖는 convolution feature map 생성됨
    • 여러 개의 convolution filters
    • input channel과 output channel의 크기를 알면, 적용된 convolution filter의 개수 알 수 있음


stack of convolutions

스크린샷 2023-05-28 오후 11 33 00

  • 한 번 convolution을 거치고 나면 nonlinear activition이 들어가게 됨
  • 이 연산에 필요한 파라미터의 숫자를 항상 생각해야 함!


Convolution Neural Networks

  • CNN consists of convoluiton layer, pooling layer, and fully connected layer
    • convolution & pooling layers: feature extraction
    • fully connected layer: decision making (e.g., classification)

스크린샷 2023-05-28 오후 11 38 17


  • 최근에는 fully connected layer를 없애는/최소화하는 추세
    • ML에서 일반적으로 학습하고자 하는 모델의 파라미터의 숫자가 늘어날수록 학습이 어렵고 generalization performance가 떨어진다고 알려져 있음
    • CNN - 같은 모델을 만들고 convolution layer를 많이 추가하여 deep하게 만들지만, 동시에 파라미터 수를 줄이는 데 집중


Convolution Arithmetic of GoogleNet

스크린샷 2023-05-28 오후 11 41 17


Stride

스크린샷 2023-05-28 오후 11 42 23

  • 갖고 있는 convolution filter(kernel)을 몇 칸씩 옮기느냐


Padding

스크린샷 2023-05-29 오전 1 25 20

스크린샷 2023-05-29 오전 1 27 45


Convoluiton Arithmetic

스크린샷 2023-05-29 오전 1 28 18

  • 필요한 파라미터 수: 3 x 3 x 128 x 64 = 73,728


exercise

  • AlexNet

스크린샷 2023-05-29 오전 1 33 25

  • Convolution 레이어(1): 11 x 11 x 3 x 48 * 2 ≈ 35K
  • Convolution 레이어(2): 5 x 5 x 28 x 128 * 2 ≈ 307K
  • Convolution 레이어(3): 3 x 3 x 128 * 2 x 192 * 2 ≈ 884K
  • Convolution 레이어(4): 3 x 3 x 192 x 192 * 2 ≈ 663K
  • Convolution 레이어(5): 3 x 3 x 192 x 128 * 2 ≈ 442K

  • Dense 레이어(1): 13 * 13 * 128 * 2 x 2048 * 2 ≈ 177M
    • fully connected -> input 뉴런 개수 x output 뉴런 개수
  • Dense 레이어(2): 2048 * 2 x 2048 * 2 ≈ 16M
  • Dense 레이어(3): 2048 * 2 x 1000 ≈ 4M


스크린샷 2023-05-29 오전 1 41 04


  • Dense 레이어가 Convolution 레이어보다 훨씬 많은 파라미터 가짐
    • Convoluiton operator와 각각의 커널이 모든 위치에 대해 동일하게 적용됨
      • shared parameter
    • 파라미터 수를 줄이기 위해 convolution 레이어를 늘리고, fully connected 레이어를 줄이는 추세


1 X 1 Convolution

스크린샷 2023-05-29 오전 1 44 23

  • 이유
    • Dimension reduction (Dimension: channel)
    • convolution layer를 깊게 쌓으면서 파라미터를 줄일 수 있음
    • e.g., bottleneck architecture


AlexNet

스크린샷 2023-05-29 오전 1 51 15


  • key ideas
    • ReLU (Rectified Linear Unit) activation
    • GPU implementation (2 GPUs)
    • Local response normalization (지금 많이 사용되지 않음), Overlapping pooling
    • Data augmentation
    • Dropout


  • ReLU activation
    스크린샷 2023-05-29 오전 1 54 55
    • linear model의 장점을 갖는 nonlinear
    • gradient descent로 학습 용이
    • good generalization
    • vanishing gradient 문제 해결


VGGNet

스크린샷 2023-05-29 오전 1 55 35

  • 3 X 3 convolution filter만 사용
  • fully connected layer에 1 x 1 covolution 사용


  • 3 X 3 convolution 스크린샷 2023-05-29 오전 1 56 49
    • convolution layer의 크기가 커지면 한 번 찍을 때 고려되는 input의 크기가 커짐 : Receptive filed


GoogLeNet

  • 1 X 1 convolution을 적절히 활용함
    • parameter 수 감소
  • Inception Block

스크린샷 2023-05-29 오전 2 01 46


ResNet

스크린샷 2023-05-29 오전 2 11 06