๊ธ์ ๊ฐ๋ ์ฑ์ ์ํด ์๋ ๋งํฌ์ ์ ๋ฆฌํด๋ .
https://blog.naver.com/younjung1996/223413266165
์๋ ํ์ธ์.
Google Coral์์ ํ์ต๋ ๋ชจ๋ธ์ ํตํด ์ถ๋ก ์ ํ ์ ์๋ Coral Board & USB Accelator ๊ฐ ์์ต๋๋ค.
์ ๋ Coral Board๋ฅผ ์ฌ์ฉํ์ง ์๊ณ , ๋ผ์ฆ๋ฒ ๋ฆฌํ์ด4์ USB Accelator๋ฅผ ์ฐ๊ฒฐํ์ฌ ์ฌ์ฉํ ์๊ฐ์ ๋๋ค.
๋ฅ๋ฌ๋์ ์ํด ๋์จ ์ ํ์ด๋ผ ํ ์ง๋ผ๋ ์์ง ๋ถ์กฑํ ๋ถ๋ถ์ด ๋ง์ต๋๋ค.
์ด๋ฐ ๊ณ ์ฑ๋ฅ ํ๊ฒฝ์ด ์๋ ๊ณณ์์๋ ํ์ตํ๊ณ , ์ถ๋ก ํ ์ ์๋ ๋ชจ๋ฐ์ผ ๋ท(Mobile Net)์ด ๊ฐ๋ฐ๋์์ต๋๋ค.
๊ทธ ์ค Mobile Net์ Architecture์์ Depthwise Separable Convolution์ ๋ํด ์ด์ผ๊ธฐํ๊ฒ ์ต๋๋ค.
Depthwise separable Convoltion์ Parameter๋ฅผ ์ค์์ผ๋ก, ์ฐ์ฐ๋์ ์ค์ด๊ณ , ์๋๋ฅผ ๋์ด๋ ๊ธฐ๋ฒ์ ๋๋ค.
https://hichoe95.tistory.com/48
Depthwise Separable Convolution = Depthwise Convolution + Pointwise Convolution
์๋ง Depthwise Separable Convolution์ ๊ณต๋ถํ์ค ๋ ์ ๊ทธ๋ฆผ์ ๊ฐ์ฅ ๋ง์ด ๋ณด์ จ์๊ฒ๋๋ค.
Depthwise Convolution์ผ๋ก ์ฑ๋๊ฐ Spartial Correlations์ ๊ณ ๋ คํ์ฌ ~ ๊ฐ๊ฐ ๋ ๋ฆฝ์ ์ผ๋ก ํจํด์ ํ์ ํ๊ณ ~
Pointwise Convolution์ผ๋ก Cross Channel Correlations๋ก ์ฑ๋์ ์กฐ์ ํ ์ ์๋ ~ ๋ธ๋ผ๋ธ๋ผ
์ ๋ธ๋ก๊ทธ ๋ถ๊ป์ ๊ต์ฅํ ์ ๋ฆฌ๋ฅผ ์ํด์ฃผ์ จ์ต๋๋ค.
๊ทธ๋ผ ์ ์ ๊ธ์ ๋ชฉ์ ์ ๋ฌด์์ด๋.
Standard Convolution๊ณผ Depthwise Separable Covolution๋ฅผ pytorch๋ก ๊ตฌํํ์ฌ ์ ๋ง๋ก ํ๋ผ๋ฏธํฐ ์์ ์ฐ์ฐ๋์ด ์ค์ด๋๋์ง ๊ฒฐ๊ณผ๊ฐ์ ๋์ผ๋ก ํ์ธํ๋ ๊ฒ์ ๋๋ค.
1. Standard Convolution
Convolution = K * K * C * M
k : Kernel ( 3์ผ๋ก ๊ฐ์ )
c : intput_dimension (channel ) (100์ผ๋ก ๊ฐ์ )
m : output_dimension (activation map) (1000์ผ๋ก ๊ฐ์ )
standard_convolution = nn.Conv2d(in_channels=100, out_channels=1000, kernel_size=3, bias=False)
----------------------------------------------------------------
Layer (type) Output Shape Param #
================================================================
Conv2d-1 [-1, 1000, 15, 15] 900,000
================================================================
Total params: 900,000
Trainable params: 900,000
Non-trainable params: 0
----------------------------------------------------------------
Input size (MB): 0.11
Forward/backward pass size (MB): 1.72
Params size (MB): 3.43
Estimated Total Size (MB): 5.26
----------------------------------------------------------------
2. Depth-wise Convolution
Depthwise Convolutuon = K * K * C
k : Kernel ( 3์ผ๋ก ๊ฐ์ )
c : intput_dimension (channel ) (100์ผ๋ก ๊ฐ์ )
m : output_dimension (activation map) (1000์ผ๋ก ๊ฐ์ )
depthwise_convolution = nn.Conv2d(in_channels=100, out_channels=1000, kernel_size=3, groups=100,bias=False)
----------------------------------------------------------------
Layer (type) Output Shape Param #
================================================================
Conv2d-1 [-1, 100, 15, 15] 900
================================================================
Total params: 900
Trainable params: 900
Non-trainable params: 0
----------------------------------------------------------------
Input size (MB): 0.11
Forward/backward pass size (MB): 0.17
Params size (MB): 0.00
Estimated Total Size (MB): 0.29
----------------------------------------------------------------
3. Point-wise Convolution ( 1 x 1 Convolution )
Pointwise Convolutuon = C * M
k : Kernel ( 3์ผ๋ก ๊ฐ์ )
c : intput_dimension (channel ) (100์ผ๋ก ๊ฐ์ )
m : output_dimension (activation map) (1000์ผ๋ก ๊ฐ์ )
pointwise_convolution = nn.Conv2d(in_channels=100, out_channels=1000, kernel_size=1, bias=False)
----------------------------------------------------------------
Layer (type) Output Shape Param #
================================================================
Conv2d-1 [-1, 1000, 17, 17] 100,000
================================================================
Total params: 100,000
Trainable params: 100,000
Non-trainable params: 0
----------------------------------------------------------------
Input size (MB): 0.11
Forward/backward pass size (MB): 2.20
Params size (MB): 0.38
Estimated Total Size (MB): 2.70
----------------------------------------------------------------
4. Depthwise Separable Convolution
Depthwise Separable Convolution = K * K * C + C * M = C( K * K + M )
k : Kernel ( 3์ผ๋ก ๊ฐ์ )
c : intput_dimension (channel ) (100์ผ๋ก ๊ฐ์ )
m : output_dimension (activation map) (1000์ผ๋ก ๊ฐ์ )
depthwise_separable_convolution = nn.Sequential(
nn.Conv2d(in_channels=100,
out_channels=100,
kernel_size=3,
groups=100,
bias=False),
nn.Conv2d(in_channels=100,
out_channels=1000,
kernel_size=1,
bias=False)
)
----------------------------------------------------------------
Layer (type) Output Shape Param #
================================================================
Conv2d-1 [-1, 100, 15, 15] 900
Conv2d-2 [-1, 1000, 15, 15] 100,000
================================================================
Total params: 100,900
Trainable params: 100,900
Non-trainable params: 0
----------------------------------------------------------------
Input size (MB): 0.11
Forward/backward pass size (MB): 1.89
Params size (MB): 0.38
Estimated Total Size (MB): 2.38
----------------------------------------------------------------
Depthwise Separable Convolution = Depthwise Convolution + Pointwise Convolution ( 100900 = 100000 + 900 )
Standard Convolution Parameters = 900,000
Depthwise Separable Convolution Parameters = 100,900
=> ์ฝ K(Kernel Size) ์ ๊ณฑ์ ์ฐจ์ด
5. Kernel Size๊ฐ ๊ฐ์ด ๊ต์ฅํ ํฌ๋ค๋ฉด... ( kerenl size == 7 )
Standard Convolution
----------------------------------------------------------------
Layer (type) Output Shape Param #
================================================================
Conv2d-1 [-1, 1000, 11, 11] 4,900,000
================================================================
Total params: 4,900,000
Trainable params: 4,900,000
Non-trainable params: 0
----------------------------------------------------------------
Input size (MB): 0.11
Forward/backward pass size (MB): 0.92
Params size (MB): 18.69
Estimated Total Size (MB): 19.73
----------------------------------------------------------------
Depthwise separable Convolution
----------------------------------------------------------------
Layer (type) Output Shape Param #
================================================================
Conv2d-1 [-1, 100, 11, 11] 4,900
Conv2d-2 [-1, 1000, 11, 11] 100,000
================================================================
Total params: 104,900
Trainable params: 104,900
Non-trainable params: 0
----------------------------------------------------------------
Input size (MB): 0.11
Forward/backward pass size (MB): 1.02
Params size (MB): 0.40
Estimated Total Size (MB): 1.53
----------------------------------------------------------------
Kernel์ ์ฌ์ด์ฆ๊ฐ ์ปค์ง์๋ก, ์์ฒญ๋ ํ๋ผ๋ฏธํฐ ์์ ๊ฐ์๋ฅผ ๋ณด์ฌ์ฃผ๋ฉฐ, ๊ณฑ์ ์ ๋ง์ ์ผ๋ก ๋์ฒดํ๊ธฐ ๋๋ฌธ์ ์ฐ์ฐ์ด ๊ต์ฅํ ๋นจ๋ผ์ง๋๋ค.
์ด๋ฌํ ํน์ง๋์ ์ํด, Depthwise separable Convolution๋ฅผ ํตํ Inception, Xception, mobile net ๋ฑ ์ฌ๋ฌ ๋ ผ๋ฌธ์์ ๋ง์ด ๋ฑ์ฅํฉ๋๋ค.