C.W.K.
Stream
Lesson 04 of 07 · published

model.summary() 읽기

~8 min · sequential

Level 0Keras 도제
0 XP0/97 lessons0/20 achievements
0/120 XP to next level120 XP to go0% complete

model 의 X-ray

model.summary() 는 architecture 를 테이블로 찍어 — layer 이름, output shape, layer 별 parameter 수, trainable / non-trainable 합계까지. build 직후, .compile() 부르기 *전에* 가장 먼저 돌리는 거야. 안 그러면 학습 한 판 통째로 날린 뒤에야 발견할 구조적 실수를 몇 초 만에 잡아주거든.

위에서 아래로 읽으면 세 가지가 눈에 띄어 (Code 섹션에 실제 예시). output shape 가 (None, 128) 이면 None 은 batch dim — fit 때 채워져. parameter 수가 0 이면 학습 weight 없는 layer (Flatten, Dropout), 버그 아니라 정상이야. non-trainable 이 0 이 아니면 frozen layer 거나 BatchNormalization 의 moving stats 를 가리켜.

parameter 숫자는 어디서 나오나

param column 은 마법이 아니야 — 손으로 유도 가능하고, 한 번 해보면 layer 가 실제로 어떻게 도는지 머리에 박혀. 입력 n → 출력 mDense 는 weight n × m 개에 bias m 개. 그래서 784-벡터 먹는 Dense(128) 은 784 × 128 + 128 = 100,480. 손계산과 summary() 가 어긋나면 shape 멘탈 모델이 틀린 거고, 그게 바로 학습 *전에* 잡고 싶은 버그야.

Code

model.summary() 출력, 주석 포함·python
model.summary()
# Output:
# ┏━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┓
# ┃ Layer (type)           ┃ Output Shape     ┃    Param # ┃
# ┡━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━┩
# │ dense (Dense)          │ (None, 128)      │    100,480 │
# │ dropout (Dropout)      │ (None, 128)      │          0 │
# │ dense_1 (Dense)        │ (None, 10)       │      1,290 │
# └───────────────────────┴──────────────────┴────────────┘

External links

Exercise

Conv2D 2 개 + Dense 2 개로 CNN 짜. model.summary() 읽고 직접 계산해봐 — 각 Conv 의 parameter 수 = (kernel_h × kernel_w × in_channels + 1) × out_channels.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.