더북(TheBook)

2. CNN 구성하기(14x14 → 7x7)

>>> model = models.Sequential()
>>> model.add(layers.Conv2D(32, (3, 3), activation='relu', input_shape=(28, 28, 1)))
>>> model.add(layers.MaxPooling2D((2, 2)))
>>> model.add(layers.Conv2D(64, (3, 3), activation='relu'))
>>> model.add(layers.MaxPooling2D((2, 2)))
>>> model.add(layers.Conv2D(64, (3, 3), activation='relu'))

3. 결과층까지 모형 구성하기(최종 출력값에서 출력 64개를 입력 값으로 받아서 0~9 레이블인 10개의 출력하기)

>>> model.add(layers.Flatten())
>>> model.add(layers.Dense(64, activation='relu'))
>>> model.add(layers.Dense(10, activation='softmax'))
>>> model.summary( )
Model: "sequential_2"
_________________________________________________________________
Layer (type)                 Output Shape           Param #
=======================================
conv2d (Conv2D)              (None, 26, 26, 32)      320
_________________________________________________________________
max_pooling2d (MaxPooling2D) (None, 13, 13, 32)      0
_________________________________________________________________
conv2d_1 (Conv2D)            (None, 11, 11, 64)      18496
_________________________________________________________________
max_pooling2d_1 (MaxPooling2 (None, 5, 5, 64)        0
_________________________________________________________________
conv2d_2 (Conv2D)            (None, 3, 3, 64)        36928
_________________________________________________________________
flatten_1 (Flatten)          (None, 576)             0
_________________________________________________________________
dense_4 (Dense)              (None, 64)              36928
_________________________________________________________________
dense_5 (Dense)              (None, 10)              650
===================================
Total params: 93,322
Trainable params: 93,322
Non-trainable params: 0
신간 소식 구독하기
뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.