Choose the format before you need to deploy
Training a model is expensive. Saving lets you reuse it without retraining — for inference, continued training, deployment, sharing, publishing. TF provides multiple formats; the wrong choice creates deployment headaches.
The format is determined by the file extension you save with:
| Format | Architecture | Weights | Optimizer | Best for |
|---|---|---|---|---|
.keras | ✅ | ✅ | ✅ | Development checkpoints, framework-agnostic Keras 3 |
| SavedModel directory | ✅ | ✅ | ✅ | Production: TF Serving, TFLite, TF.js |
.h5 (legacy) | ✅ | ✅ | ✅ | Avoid for new projects |
weights only (.weights.h5) | ❌ | ✅ | ❌ | When you have the architecture code already |
Save to .keras during development for maximum fidelity. Export to SavedModel for production serving / TFLite conversion / TF.js. Knowing the format differences before you need to deploy saves hours of debugging later.