2023. 10. 4. 14:26ใArtificialIntelligence/2023GoogleMLBootcamp
Computer Vision


CV ์ด๋ฏธ์ง ์ฒ๋ฆฌ์ ๋ฌธ์
input (image)์ ์ฐจ์์ด ๋งค์ฐ ํฌ๋ค (3 channel๊น์ง ๊ณ ๋ ค)
๋ ๋์ ํด์๋์ ์ด๋ฏธ์ง์ผ์๋ก, ์๋์ ์ผ๋ก ๋ฐ์ดํฐ ์๊ฐ ๋ถ์กฑํ์ฌ ์ค๋ฒํผํ ๋ ํ๋ฅ ๋์์ง
Edge Detection Example

edge์ ๊ฐ๋

Convolution ์ฐ์ฐ์ ์์ (๊ณผ์ )



ํ๋ ์์ํฌ ๋ณ conv ์ฐ์ฐ์ ์ํํ๋ ๊ฐ๊ฐ์ ์ฐ์ฐ์ด ์กด์ฌํ๋ค (method ์ด๋ฆ์ ๋ค๋ฆ)

์ ์ธ๋ก ๋ฐฉํฅ edge๋ฅผ detect ํ๋๊ฐ?
๋ฐ์ ๋ฐ๊ณ (๊ฐ์ด ํฌ๊ณ ), ๋ฐ์ ์ด๋์ด ์ด๋ฏธ์ง๋ฅผ ์๊ฐํด๋ณด์
์ด๋ vertical filter๋ฅผ ํ์ฉํ๋ฉด (์ด๋ฏธ์ง ๋ณํ๋ฅผ ๊ฒ์ถํ๋ ๊ฒ)
์ข์ฐ ๋ณํ๋ฅผ detect ํ ๋ถ๋ถ์ +30์ผ๋ก ๋ฐ๊ฒ ํํ๋๋ค
๋ฐ๋ผ์ ๊ฒฝ๊ณ์ (์ธ๋ก ์ค ๋ถ๋ถ)์ด ๋ค์ ๋จ๊ณ์์๋ ๋ฐ์ ๊ฐ์ผ๋ก ํํ๋๋ ๊ฒ
์ค..!
More Edge Detection

input image ๋ฐ๋๋ก ๋ค์งํ ์ํฉ์์๋
๊ฐ์ด๋ฐ๊ฐ -30์ผ๋ก, ์ด๋์ด ๊ฐ(dark region)์ ๊ฐ๊ฒ ๋จ

Horizontal edge (filter)
๊ฐ๋ก ๋ฐฉํฅ์ ๊ธฐ์ค์ผ๋ก ๊ฐ์ ๋ณํ๋ฅผ ๊ฒ์ถ
ํฅ๋ฏธ๋ก์ด ๋ถ๋ถ -> ์ฒดํฌ ํ์์ ์ค์ ๊ฒฝ๊ณ์์ ์ฌ๋ฏธ์๋ ๊ฐ์ด ๋์จ๋ค (์์๋์ ์ข, ์ฐ ๊ณ์ฐ +10)

vertical + ๊ฐ์ด๋ฐ์ ๊ฐ์ค์น๋ฅผ ์ค sobel filter
๋์๊ฐ์ scharr filter
์ด๋ฌํ ํํฐ๋ฅผ ํ์ตํ๋ ๊ฒ์ด CNN
์ ์ฒด image ๋์ , ์ด์ ์ฐ์ฐ ๋ 9๊ฐ์ params๋ฅผ ํ์ตํ๋ ๊ฒ
Padding

์ด๋ฏธ์ง ์์ถ๋๋ ๊ณต์
( n - f + 1 ) ^ 2
n : input / original
f : filter size
ex) 6 - 3 + 1 = 4 (๋ฐ๋ผ์ 16)

ํ ๊ฒน์ padding์ผ๋ก input๊ณผ ๋์ผํ pixel์ ouput์ ์ป์ ์ ์๋ค

ํจ๋ฉ๊น์ง ์ ์ฉ๋ Ouput ๊ณต์
( n + 2p - f + 1 ) ^ 2

valid = ํจ๋ฉ ์๋ ๋ฒ์
same = ํจ๋ฉ์ผ๋ก ์ธํ ์์ํ ์ฌ์ด์ฆ ๋์ผํ๊ฒ
๋ฐ๋ผ์ padding = ( filter - 1 ) / 2

* ํํฐ๋ ํ์๋ก (convention)
1. central pixel
2. padding
Strided Convolutions

๋ ์นธ ์ฉ, step์ ๋ฐ๊ธฐ
stride์ ๊ฐ๋


floor ํจ์
output ๊ณ์ฐํ๋ ๊ณต์ ๋ณํ
{ ( n + 2p - f ) / s + 1 } ^ 2


์ ํธ์ฒ๋ฆฌ์์๋ convolution ์ฐ์ฐ์ด (์ํ์ ์ผ๋ก)
๋๊ฐ ์ถ์ผ๋ก (๊ฐ๋ก, ์ธ๋ก) ๋ฐ์ ๋ (๋ณํ๋) filter์ ๋ํ ์ฐ์ฐ์ด ์ด๋ฃจ์ด์ ธ์ผํ์ง๋ง
Deep learning ์ฐ์ฐ์์๋ ๋์นญ ์ ์ฉํ์ง ์๊ณ , ์๋ ๊ทธ๋๋ก ํฉ์ฑ ๊ณฑ ์ฐ์ฐ์ด ์ด๋ฃจ์ด์ง๋ค
Convolutions Over Volume


ํ๋ธ ๋จ์์ 27๋ฒ์ ๊ณฑ์ ํฉ์ด ํ ์นธ์ ์ ํ๊ฒ ๋๋ค

Red channel์ vertical edge๋ฅผ detectํ๊ณ ์ถ์ ๋

channel๊ณผ ๋ฌด๊ดํ๊ฒ ์ธ๋ก ์ฃ์ง๋ฅผ ๊ฒ์ถํ๊ณ ์ถ๋ค๋ฉด
2๋ฒ์งธ ์ค์ ๊ฒฝ์ฐ์ ๊ฐ์ด ๋ชจ๋ ๋ค vertical filter

output์ ๋ง์ง๋ง ์ฐจ์์
ํํฐ์ pixel์ด ์๋๋ผ, (f ์๋ ๋ฌด๊ด)
ํํฐ์ ๊ฐ์์ ๋์ํ๋ ์ฐจ์์ ๊ฐ๊ฒ ๋๋ค
number of channel
One Layer of a Convolutional Network

1. 3*3 Conv ํต๊ณผ
2. bias๋ฅผ ๋ํ๊ณ , ReLU๋ฅผ ํต๊ณผ
3. 2 ๊ฐ์ 4 * 4 ๋ํ๋ค
-> next a (4 * 4 * 2)


input image์ size์๋ ๋ฌด๊ดํ๋ค!
ํํฐ๋ฅผ ํ์ตํ๋ ๊ฒ, ๋ฐ๋ผ์ ํํฐ์ params๋ง ๊ณ ๋ ค
CV ๋ถ์ผ์์ ์ปจ๋ณผ๋ฃจ์ ์ ํ์ฉํ ์ด์ ๊ฐ ๋๊ธฐ๋ ํจ

* input dimension
previous layer์ ๋ํ ํ๊ธฐ๋ก l - 1 ์ผ๋ก ์ฌ์ฉํ๋ค.
์ด์ ์ height, width, channel (ํํฐ์ ์)์ ์๋ฏธํจ

Simple Convolutional Network Example

์์๋ฅผ ํตํด params ์์๋ณด๊ธฐ
๋ฅ๋ฌ๋ ๋คํธ์ํฌ๊ฐ ๊น์ด์ง์๋ก, H,W๋ ์ค์ด๋ค๊ณ , ๊น์ด๋ ๋์ด๋๋ค. (channel ๋ฐฉํฅ)

Pooling Layers

max pooling์ ๊ณผ์
filter 2*2 , stride2๋ฅผ ์ค ๊ฒ๊ณผ ๋์ผํ๋ค

max pooling
ํํฐ์ 3๊ฐ, ์คํธ๋ผ์ด๋ 1

average pooling
max pooling์ด NN์์ ๋ ๋ง์ด ์ฐ์ธ๋ค.
(ํ๊ท ์ด ๋ ์ฐ์ด๋ ๊ฒฝ์ฐ๋ ์์)

ํ๋ง์ ์ฅ์ !
- parameter X
- padding X
CNN Example

parameter์ ํจ๊ป ์ด๋ป๊ฒ Conv ๊ณผ์ ์ด ์งํ๋๋ ๊ฒ์ธ์ง ์์ธํ๊ฒ ์ ์ ์์๋ค.


ํ๋ฐ๋ถ์ Fully connected layer๋ฅผ ์ถ๊ฐํ์ฌ
softmax ํต๊ณผ ํ classification

Nh, Nw๋ ์ค์ฌ๊ฐ๋ฉด์,
Nc๋ฅผ ๋์ด๋๊ฒ ์ผ๋ฐ์ ์ธ ๊ฒฝ์ฐ
conv pooling conv pooling -> FC FC FC -> softmax (์ผ๋ฐ์ ์ธ ๊ณผ์ )

Why Convolutions?

์ปจ๋ณผ๋ฃจ์ ๋ ์ด์ด๋ฅผ ํ์ฉํ๋ ๊ฒ์ด parameter ํจ์ฌ ์ ๋ค

1. parameter sharing
์ ์ฒด ์ด๋ฏธ์ง์ ๋ํด filter์ params๋ฅผ ๋ชจ๋ ๊ณต์ ํ๋ค

2. ์ฐ๊ฒฐ์ sparsity
sparseํ๊ฒ ์ด๋ฏธ์ง ์ ๋ณด๋ฅผ ์ฒ๋ฆฌ
ํน์ ๋ถ๋ถ์๋ง ์ํฅ์ ๋ฐ๊ฒ ๋๋ค.
denseํ ๊ธฐ์กด์ MLP ๊ธฐ๋ฐ๊ณผ๋ ๋ค๋ฆ

'ArtificialIntelligence > 2023GoogleMLBootcamp' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[GoogleML] Object Detection (1) | 2023.10.09 |
---|---|
[GoogleML] Convolutional Neural Networks Case Studies (1) | 2023.10.06 |
[GoogleML] Structuring Machine Learning Projects ์๋ฃ (0) | 2023.10.01 |
[GoogleML] Transfer Learning & End-to-end Deep Learning (0) | 2023.09.30 |
[GoogleML] Error Analysis & Mismatched Train and Test Set (0) | 2023.09.30 |