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 불필요.