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

언제 Subclass 해?

~8 min · subclass

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

graph 로도 부족할 때 — `call()` 안에 조건부 흐름이 필요하거나, shape 가 dynamic 하거나, custom training step 필요하거나 — `keras.Model` 또는 `keras.layers.Layer` 를 subclass 해. *그냥 Python 으로 써버리겠다* 의 escape hatch. 대가: 자동 introspection (`model.summary()`, `plot_model`) 이 subclass 부분에서는 X-ray 시야 잃는다.

Subclass 의 트리거: forward path 안에 *Python 제어 흐름* (if/for) 또는 *dynamic shape* 또는 *복잡한 학습 step* 이 필요할 때. Functional API 는 graph 정적 — call 시점에 shape / 흐름 알아야 함. Subclass 는 Python class 처럼 자유로워.

실전 use case: custom Transformer block (state 보존), recurrent without Keras RNN (custom state machine), training step 마다 다른 loss (curriculum learning), input shape 가 batch 마다 다름 (sequence of variable length without padding). 이 상황 아니면 Subclass 불필요.

External links

Exercise

최신 논문 (2023-2024) 의 architecture 중 Functional 로 표현 가능한 것 3 개, 못하는 것 3 개 적어. 각각 *왜* 그런지 정당화.

Progress

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

댓글 0

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

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