011. The Modern .keras Format
EXECUTIVE_SUMMARY // AEO_OPTIMIZED
[Answer Engine Overview: What, Why & How]
Prior to Keras 3.0, the ecosystem was fractured. You could save as a single .h5 file (which sometimes failed on custom layers) or a SavedModel folder (which was heavy and annoying to move). The new .keras format solves everything. It is literally a standard ZIP file. If you rename model.keras to model.zip and extract it, you will see a beautifully organized folder containing the config JSON, the weights, and the optimizer state.
022. The Full Model
When you run model.save('my_model.keras'), you capture the holy trinity:
1. The Architecture (so you don't need the original Python code).
2. The Weights (the actual learned knowledge).
3. The Optimizer State (Adam keeps internal momentum trackers; saving these allows you to pause training on Friday and resume perfectly on Monday).
033. Weights Only
Sometimes you build a model in Python, but you want to run it in a web browser using TensorFlow.js, or on an iPhone using CoreML. The optimizer state is useless in production. By running model.save_weights(), you export pure math matrices. However, the importing system MUST know the exact architecture beforehand to know where to put those matrices.
?Frequently Asked Questions
Can I convert a Keras model to PyTorch?
With Keras 3.0's multi-backend capability, it is becoming much easier to write the model once and export it to different native backends. Alternatively, the ONNX (Open Neural Network Exchange) format is the industry standard for translating models between frameworks.
What is TensorFlow Lite?
It is a specialized framework for shrinking models. It takes your massive float32 `.keras` model and 'quantizes' it (turns the 32-bit decimals into 8-bit integers). This drops the file size by 75% and makes it run blazing fast on mobile phones, with a very tiny drop in accuracy.
