본문 바로가기
인공신경망(DL)/Computer Vision

CNN의 기본 과정 정리

by kiimy 2022. 1. 8.
728x90
삼각형, 사각형, 원을 손으로 그린 이미지가 있고 이미지 크기가 8 x 8이라고 가정
삼각형, 사각형, 원을 구분하는 3개의 클래스를 분류하는 문제이기 때문에 출력 벡터는 3개
# padding = 'same' default
from tensorflow.keras.models import Sequential, Model
from tensorflow.keras.layers import Dense, Conv2D, MaxPooling2D, Flatten

model = Sequential()

model.add(Conv2D(2, (3, 3), padding='same', activation='relu', input_shape=(8, 8, 1)))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D(3, (2, 2), padding='same', activation='relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Flatten())
model.add(Dense(8, activation='relu'))
model.add(Dense(3, activation='softmax'))

 

conv2d =

kernel(3,3) * channel(1) * filter(2) + bias(2)

 

conv2d_1 =

kernel(2,2) * channel(2) * filter(3) + bias(3)

 

dense =

shape(2*2*3) * node(8) + bias(8) 

 

dense_1=

node(8) * node(3) + bias(3)

 

 

 

 

 

1. 가정

 

구하고자 하는 것

2. 컨볼루션 레이어

Conv2D(2, (3,3), activation='relu', input_shape=(8,8,1))

입력 이미지 크기 8 x 8, 입력 이미지 채널 1개, 필터 크기 3 x 3, 필터 수 2개, 경계 타입 ‘same’, 활성화 함수 ‘relu’

3. 맥스풀링

MaxPooling2D((2,2))

풀 크기 2 x 2

4. 컨볼루션 레이어

Conv2D(3, (2,2), activation='relu')

MaxPooling2D로 입력 이미지 크기 4 x 4,
MaxPooling2D로 입력 이미지 채널 2개
필터 크기 2 x 2, 필터 수 3개, 경계 타입 ‘same’, 활성화 함수 ‘relu’

5. 맥스풀링

MaxPooling2D((2,2))

풀 크기 2 x 2

6. 전결합층

flatten() - 12개 뉴런

7. Dense layer

Dense(8, activation='relu')

입력 뉴런 수 12개, 출력 뉴런 수 8개, 활성화 함수 ‘relu’

8. Dense layer

Dense(3, activation='softmax')

입력 뉴런 수 8개, 출력 뉴런 수 3개, 활성화 함수 ‘softmax’

9. 결과

https://tykimos.github.io/2017/01/27/CNN_Layer_Talk/

 

컨볼루션 신경망 레이어 이야기

이번 강좌에서는 컨볼루션 신경망 모델에서 주로 사용되는 컨볼루션(Convolution) 레이어, 맥스풀링(Max Pooling) 레이어, 플래튼(Flatten) 레이어에 대해서 알아보겠습니다. 각 레이어별로 레이어 구성

tykimos.github.io

 

728x90

댓글