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

Cross-backend 저장

~8 min · serialize

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

.keras 의 진짜 magic — TF 로 학습한 모델을 PyTorch 또는 JAX 에서 그대로 로드. weight 가 backend-agnostic 으로 저장되기 때문. KERAS_BACKEND=tensorflow python train.py → save → KERAS_BACKEND=torch python eval.py → load → predict.

cross-backend 가 *완벽하지 않은* 경우: backend-specific layer 사용 (TF 의 tf.signal.fft 등 native op 직접). 순수 Keras / keras.ops 만 쓰면 cross-backend 안전.

Code

# Train on JAX (fast JIT compilation)
os.environ["KERAS_BACKEND"] = "jax"
model.fit(x_train, y_train, epochs=10)
model.save("trained_on_jax.keras")

# Later: load on TensorFlow for deployment
os.environ["KERAS_BACKEND"] = "tensorflow"
model = keras.models.load_model("trained_on_jax.keras")
model.export("tf_serving_model", format="tf_saved_model")

External links

Exercise

MNIST 를 KERAS_BACKEND=tensorflow 로 학습 후 mnist.keras 저장. KERAS_BACKEND=torch 로 새 shell 에서 로드 + test set predict. 원래 학습의 accuracy 와 일치 확인.

Progress

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

댓글 0

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

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