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

실전 — save → cross-backend load → export

~8 min · serialize

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

트랙 전체를 한 번에 돌리기

이 lesson 은 트랙이 따로따로 소개한 걸 다 꿰매. .keras 포맷 (lesson 1), cross-backend 로드 (lesson 4), export (lesson 5) 는 별개의 세 트릭이 아니야 — 모델을 재학습 한 번 안 하고 빠른 학습 engine 에서 안정적인 serving runtime 까지 옮기는 하나의 파이프라인, 그 세 단계야.

세 단계, 세 context

1 단계 — 제일 빠른 데서 학습. JAX backend 설정하고 모델 빌드·fit 한 다음 model.keras 하나 써. optimizer 상태도 같이 실려서 이 checkpoint 는 완전히 재개 가능. 2 단계 — 안정적인 데서 로드. TensorFlow backend 를 고른 별도 프로세스에서 load_model 이 같은 파일을 읽어. weight 가 backend-agnostic 이라 handoff 에서 잃는 게 없어. 3 단계 — production 용 export. 로드한 모델을 export 로 serving 포맷에 투영하고, TF Serving·TFLite·TF.js 로 ship.

backend 전환이 프로세스 사이에서 일어나는 이유

단계마다 자기 KERAS_BACKEND 를 가진 별도 스크립트인 거 봐. backend 는 import keras 하는 순간 고정돼서 프로그램 중간에 engine 을 못 바꿔 — 전환은 프로세스 경계에 살고, 그 경계를 모델을 온전히 건너게 하는 게 .keras 파일이야. 그 파일이 계약이고, 양쪽 backend 는 교체 가능한 거지.

Code

학습 (JAX) → 저장 → 로드 (TF) → production export·python
# Step 1: Train on JAX
os.environ["KERAS_BACKEND"] = "jax"
import keras
model = build_model()
model.compile(optimizer="adam", loss="sparse_categorical_crossentropy")
model.fit(x_train, y_train, epochs=10)
model.save("model.keras")

# Step 2: Load on TensorFlow
# (In a new script with KERAS_BACKEND="tensorflow")
model = keras.models.load_model("model.keras")

# Step 3: Export for production
model.export("production_model", format="tf_saved_model")
# Deploy with TF Serving, TFLite, or TF.js

External links

Exercise

CIFAR-10 모델로 전체 lifecycle 실행 — 학습 (TF) → .keras 저장 → 로드 (PyTorch) → eval → 로드 (JAX) → eval → export → TFLite. 각 단계의 동작 command 를 runbook 에 기록.

Progress

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

댓글 0

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

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