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

The .keras Format

~9 min · serialize

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

The .keras format is one zip-shaped file with weights, architecture, and metadata — the same file loads in any backend. We cover that, weight-only saving for deployment, custom-object registration so subclassed layers round-trip, and model.export() for TF SavedModel / TFLite handoff.

One file, the whole model

The .keras format is Keras 3's native and recommended save format. A single .keras file is a zip archive that bundles three things: the architecture (a human-readable config.json), the weights, and the optimizer state. That last piece is what lets you resume training exactly where you left off — the optimizer's momentum and learning-rate schedule survive the round-trip, not just the learned parameters.

Why the zip shape matters

Because the config is plain JSON, the format is inspectable and debuggable: unzip -l my_model.keras shows you the contents without loading a single tensor. When a load fails, you can open the config and see the exact layer graph that was saved — no opaque binary blob to reverse-engineer. The weights are stored as backend-agnostic arrays, which is the property the rest of this track builds on: the same file loads under TensorFlow, PyTorch, or JAX. Save and load are one method each, shown below.

Code

Save and load a complete .keras model·python
# Save the complete model
model.save("my_model.keras")

# Load it back
loaded_model = keras.models.load_model("my_model.keras")

External links

Exercise

Train a small model. Save with .keras. Inspect the file with unzip -l — note the structure. Load it back and verify weights match exactly via numpy.allclose.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.