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

Functional API 가 왜 필요한가

~8 min · functional

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

graph 모양 Keras. skip connection, 다중 입력, 다중 출력, 공유 layer 가 들어오는 순간 Sequential 은 무너져 — Functional 은 버틴다. ResNet, U-Net, multi-modal model 다 여기 산다. 전체 API 가 output = layer(input) 이걸 체인으로 잇다가 마지막에 keras.Model(inputs, outputs) 로 감싸는 게 끝.

Sequential 이 못 버티는 순간

실전 model 은 일자 파이프라인이 아니야. 갈라지고, 합쳐지고, 건너뛰어. Sequential 은 layer 한 줄 — 입력이 한쪽으로 들어가서 반대쪽으로 나오고, 중간에 뭘 건너뛰거나 다시 합치는 문법 자체가 없어. 두 번째 입력이 필요하거나, residual add 가 필요하거나, 갈라진 branch 를 나중에 다시 concat 하는 순간 Sequential 로는 표현이 안 돼.

Functional API 는 layer 의 DAG (방향성 비순환 그래프) 를 짜. 그래서 이게 가능해:

  • 다중 입력 — text + image + metadata 합치기
  • 다중 출력 — class label + confidence 동시 예측
  • skip connection — ResNet residual block (layer 건너뛰기)
  • 공유 layer — 같은 weight 를 다른 입력에 (siamese)
  • 중첩 model — model 을 다른 model 안에서 layer 처럼

왜 production default 인가

실전에서 어디 쓰이나? ResNet (skip), U-Net (encoder-decoder + skip), Inception (parallel branch + concat), siamese (shared encoder), multi-modal (image + text 합치기). 사실상 SOTA architecture 거의 다 Functional 또는 Subclass 야. Functional 이 production default 인 결정적 이유는 *serializable* 이라는 거 — 임의 Python 을 돌리는 게 아니라 graph 를 *기술* 하니까 Keras 가 architecture 를 JSON 으로 저장하고, plot 하고, 소스 없이도 복원해. 이게 다음 track 의 full Model subclass 와 갈리는 지점이야: subclass 는 imperative 제어 흐름을 주는 대신 정적·serializable graph 를 포기해. architecture 가 고정된 DAG 면 Functional, step 마다 진짜 Python 로직이 필요할 때만 subclass.

External links

Exercise

2015 년 이전 architecture (예: AlexNet) 와 이후 (예: ResNet) 짝지어. 둘 다 data-flow 다이어그램으로 그려. 어느 게 list 고 어느 게 DAG 인지 식별.

Progress

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

댓글 0

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

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