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

Sequential 이 뭐야?

~8 min · sequential

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

Keras hello-world. keras.Sequential([layer, layer, layer]) 가 교과서 1페이지짜리고, 작거나 중간 사이즈 model 의 80% 는 진짜로 이 모양이야. 처음부터 만들어보고, MNIST classifier 돌려보고, 이 API 가 *부족해지는 시점* 도 정직하게 짚는다.

list 가 곧 model

keras.Sequential 은 layer 들의 *linear stack* 이야. 입력 하나 → 첫 layer → 다음 → 다음 → ... → 출력, 옆길 없음. 멘탈 모델이 진짜 그냥 Python list 야 — 순서대로 layer 를 list 에 담아 넘기면 Keras 가 앞뒤로 알아서 연결해 줘.

이게 전부고, 강력한 이유는 *가장 흔한 경우* 를 거의 ceremony 없이 해결한다는 점. 평범한 MLP, 단순 CNN, RNN stack — 다 "이거 하고, 그다음 이거, 그다음 이거" 잖아. Sequential 이 그 모양을 가장 정직하게 표현해.

쓰는 법 두 가지

동등한 표현 두 개 (Code 섹션 봐): 전체 list 를 keras.Sequential([...]) 에 넘기거나, 빈 model 에 model.add(layer) 한 줄씩. architecture 를 처음부터 다 알 땐 list 가 깔끔하고, loop 안에서 동적으로 쌓을 땐 add() 가 빛나.

모든 걸 가르는 단 하나의 규칙

이게 통하는 조건: 입력 tensor 하나, 출력 tensor 하나, branch 없음, skip 없음, layer 공유 없음. data flow 가 갈라지는 순간 — 입력 두 개, residual connection, 같은 layer 를 두 곳에서 재사용 — Sequential 은 *물리적으로* 표현을 못 해. list 엔 "이걸 저기로도 보내" 라고 말할 방법이 없거든. 이 딱딱한 경계가 오히려 쓸모 있어 — 언제 Functional API 로 졸업할지 정확히 알려주니까. 그게 이 track 마지막 lesson 이야.

Code

Sequential model 만드는 동등한 두 방법·python
import keras
from keras import layers

# Method 1: Pass a list of layers
model = keras.Sequential([
    keras.Input(shape=(784,)),
    layers.Dense(128, activation="relu"),
    layers.Dense(64, activation="relu"),
    layers.Dense(10, activation="softmax"),
])

# Method 2: Incremental add()
model = keras.Sequential()
model.add(keras.Input(shape=(784,)))
model.add(layers.Dense(128, activation="relu"))
model.add(layers.Dense(10, activation="softmax"))

External links

Exercise

regression 용 3-layer Sequential MLP 짜. model.summary() 출력하고 각 layer 의 input/output shape 확인.

Progress

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

댓글 0

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

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