Computer Science/Data Science

[CNN] CNN feature map๊ณผ filter ์‹œ๊ฐํ™”

_cactus 2022. 4. 18. 20:54
๋ฐ˜์‘ํ˜•

๋ชฉ์  : CNN layer๋“ค ์ค‘๊ฐ„์ค‘๊ฐ„ ์ถ”์ถœ๋˜๋Š” feature๋“ค์„ ์‹œ๊ฐํ™”ํ•ด๋ณด๋ฉด์„œ layer๋ฅผ ๊ฑฐ์น˜๋ฉด์„œ ์–ด๋– ํ•œ ๋ณ€ํ™”๊ฐ€ ์ผ์–ด๋‚˜๋Š”์ง€ ์•Œ์•„๋ณธ๋‹ค.

 

 

CNN architecture

๋“ค์–ด๊ฐ€๊ธฐ์ „์—, CNN์„ ์ดํ•ดํ•˜๊ธฐ ์œ„ํ•ด ๊ผญ ํ•„์š”ํ•œ ์ •๋ณด๋“ค์— ๋Œ€ํ•ด์„œ ์ •๋ฆฌํ•ด๋ณธ๋‹ค.

 

1. input image์— ์šฐ๋ฆฌ๋Š” filter(=mask=kernel)๋ฅผ ์ ์šฉํ•˜์—ฌ feature map์„ ์ƒ์„ฑํ•œ๋‹ค. ์ด๋•Œ filter๋Š” ์ด๋ฏธ์ง€๊ฐ€ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” edge, vertical line, horizontal line, bends์™€ ๊ฐ™์€ ์—ฌ๋Ÿฌ feature๋“ค์„ ๋‚˜ํƒ€๋‚ด์ฃผ๋„๋ก ๋„์™€์ค€๋‹ค.

 

2. ์ƒ์„ฑ๋œ feature map์— pooling์„ ์ ์šฉํ•œ๋‹ค. min, avg, max pooling๋“ฑ์„ ์“ธ ์ˆ˜ ์žˆ๊ณ , ๊ทธ ์ค‘์—์„œ max pooling์„ ์‚ฌ์šฉํ–ˆ์„ ๋•Œ ์„ฑ๋Šฅํ–ฅ์ƒ์„ ๊ธฐ๋Œ€ํ•ด๋ณผ ์ˆ˜ ์žˆ๋‹ค.

 

์ฐธ๊ณ ๋กœ, pooling์€ subsampling์ด๋ผ๊ณ ๋„ ๋ถˆ๋ฆฌ๋Š”๋ฐ image data์˜ size๋ฅผ ์ค„์ด๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค. size๋ฅผ ์–ด๋–ป๊ฒŒ ์ค„์ผ ์ง€์— ๋”ฐ๋ผ min/max/avg sampling ๋“ฑ์œผ๋กœ ๋‚˜๋‰œ๋‹ค.

    - pooling์˜ ๋ชฉ์  : ์ด๋ฏธ์ง€ ํฌ๊ธฐ๋ฅผ ์ค„์ž„ = parameter์ˆ˜ ์ค„์ž„ = ๊ณผ์ ํ•ฉ ๋ฐฉ์ง€

    - pooling์˜ ์žฅ์  : channel์ˆ˜์— ์˜ํ–ฅ์„ ์ฃผ์ง€ ์•Š๋Š”๋‹ค. channel ์ˆ˜ ์œ ์ง€ (independent)
                            input feature map์— ๋ฒผํ™”๊ฐ€ ์žˆ์–ด๋„ pooling์˜ ๊ฒฐ๊ณผ์—๋Š” ๋ณ€ํ™”๊ฐ€ ์ ๋‹ค (robustness)

                            ํ•™์Šตํ•  parameter๊ฐ€ ์—†๋‹ค

 

 

3. flatten์‹œํ‚จ ํ›„ deep neural net์˜ input์œผ๋กœ ๋„ฃ์–ด์ค€๋‹ค. ์ด neural net์€ output์œผ๋กœ ๋ถ„๋ฅ˜๋  class๋ฅผ ๋‚ด๋ฑ‰์–ด์ค€๋‹ค. (classify)

 


 

CNN์˜ ๊ณผ์ •์„ ์Š์–ด๋ณด์•˜๋‹ค.
๊ทธ๋Ÿฐ๋ฐ ๊ฐ€๋”,, CNN์„ ์‚ฌ์šฉํ•˜๋‹ค๋ณด๋ฉด ๊ฒฐ๊ณผ๊ฐ€ ์™œ ์ด๋ ‡๊ฒŒ ๋‚˜์˜ค์ง€? ํ˜น์€ ๋ฐ์ดํ„ฐ๊ฐ€ CNN์„ ํ†ต๊ณผํ•˜๋Š” ๊ณผ์ •์ค‘์˜ ๊ฒฐ๊ณผ๊ฐ€ ๊ถ๊ธˆํ•  ๋•Œ๊ฐ€ ์žˆ๋‹ค.
๋ชจ๋ธ์ด ์–ด๋–ค์‹์œผ๋กœ ํ•™์Šตํ•˜๊ณ  ์žˆ๋Š”์ง€ intermediate representation์„ ์‹œ๊ฐํ™”ํ•ด๋ณด๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™๋‹ค.
์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ๋ชจ๋ธ์˜ ๊ฒฐ๊ณผ์— ๋Œ€ํ•œ ํ•ด์„, model fine tuning ๋“ฑ ๋” ์šฉ์ดํ•ด์งˆ ๊ฒƒ์ด๋‹ค. 

 

filter์™€ feature map์„ ์‹œ๊ฐํ™”ํ•˜๋Š” ๋ฒ•์„ ๋ฐฐ์šฐ๊ธฐ ์ „์—, convolutional layer์™€ filter์— ๋Œ€ํ•ด ์งš๊ณ  ๋„˜์–ด๊ฐ€์•ผํ•  ์ค‘์š”ํ•œ point๋“ค์„ remind ํ•ด๋ณธ๋‹ค. 

 

Convolution layer์™€ Filter (์ค‘์š” point)

1. CNN์˜ filter์˜ depth๋Š” input image์˜ depth์™€ ๊ฐ™์•„์•ผํ•œ๋‹ค. ์—ฌ๊ธฐ์„œ depth๊ฐ€ ์˜๋ฏธํ•˜๋Š” ๊ฒƒ์€ color channel ์ˆ˜์ด๋‹ค.

 

2. color image์˜ 3๊ฐœ channel๋งˆ๋‹ค ๊ฐ๊ฐ ๋‹ค๋ฅธ Conv2D filter๊ฐ€ ์ƒ์„ฑ๋œ๋‹ค.

 

3. ๊ฐ layer์˜ filter๋Š” randomํ•˜๊ฒŒ initialize๋œ๋‹ค. ํ•™์Šต์„ ํ†ตํ•ด์„œ feature๊ฐ€ ๋‘๋“œ๋Ÿฌ์ง€๋Š” filter๋กœ ๋งŒ๋“ค์–ด์ง„๋‹ค.

ํ•™์Šต ์ „ : ๋ฌด์ž‘์œ„๋กœ ๋ถ„ํฌ๋œ filter / ํ•™์Šต ํ›„ : edge filter

 

4. ์•ž์— ์žˆ๋Š” layer์ผ์ˆ˜๋ก high-level feature๋ฅผ ์ถ”์ถœํ•œ๋‹ค. layer๊ฐ€ ๊นŠ์–ด์งˆ์ˆ˜๋ก filter ๊ฐœ์ˆ˜๋ฅผ ์ฆ๊ฐ€์‹œํ‚จ๋‹ค.

 

5. ๋” ๊นŠ์€ layer์— ์žˆ๋Š” filter์ผ์ˆ˜๋ก ๋” ๋งŽ์€ feature๋ฅผ ํ•™์Šตํ•˜์ง€๋งŒ ๊ณ„์‚ฐ๋Ÿ‰์ด ํฌ๋‹ค. 

 

 

 

 

filter์˜ ๊ฐœ์ˆ˜ = feature map๊ฐœ์ˆ˜

์ฆ‰, ๋‚ด๊ฐ€ 6๊ฐœ์˜ filter๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค -> 6๊ฐœ์˜ ์„œ๋กœ ๋‹ค๋ฅธ feature๋ฅผ ๋ฝ‘๊ฒ ๋‹ค -> filter 6๊ฐœ๋ฅผ convolveํ•œ ๊ฒฐ๊ณผ convolution layer์—๋Š” ์„œ๋กœ๋‹ค๋ฅธ 6๊ฐœ์˜ feature map ์ด ์ƒ์„ฑ๋œ๋‹ค

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

728x90
๋ฐ˜์‘ํ˜•