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

Layer 추가하는 법

~8 min · sequential

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

두 패턴: (1) constructor 에 list 로 전부 — keras.Sequential([Dense(128, activation='relu'), Dense(10)]). (2) 비어있는 model 에 model.add(layer) 점진적. 둘은 결과 동일, 취향 차이.

첫 layer 가 input shape 알아야 weight 초기화 가능. 두 가지 표현: 첫 layer 의 input_shape 인자, 또는 별도의 keras.Input(shape=...) 을 list 의 첫 항목으로. 후자가 더 명시적이고 권장.

Code

model = keras.Sequential([
    keras.Input(shape=(28, 28, 1)),  # 28x28 grayscale images
    layers.Flatten(),                       # → (784,)
    layers.Dense(128, activation="relu"),   # → (128,)
    layers.Dropout(0.2),                   # Regularization
    layers.Dense(10, activation="softmax"), # → (10,) probabilities
])

External links

Exercise

같은 MNIST classifier 를 두 방식으로 짜 — constructor list / model.add(). 둘이 똑같은 model.summary() 내는지 확인.

Progress

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

댓글 0

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

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