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

Legacy Formats

~8 min · serialize

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

Why the old formats still exist

Keras predates Keras 3 by nearly a decade, and the ecosystem is full of models saved in the formats of that era. Rather than orphan them, Keras 3 keeps the loaders alive for backwards compatibility — you can still load_model an .h5 file from a 2018 project. What changed is the recommendation: these formats are for reading the past, not writing the future.

FormatExtensionNotes
.keras.kerasRecommended. Cross-backend, architecture + weights + optimizer
HDF5.h5Legacy. Weights only or full model. Still widely used
SavedModeldirectoryTF-specific. Good for TF Serving

The cost of each legacy format

The two legacy formats each carry a tax. HDF5 (.h5) can't reliably round-trip subclassed models or custom objects — it was built for the symbolic-graph world and struggles with arbitrary Python. SavedModel is a TensorFlow-specific directory, so it ties you to one backend and breaks the cross-backend portability the rest of this track depends on. Both predate the backend-agnostic weight storage that makes .keras portable, which is exactly why new work should target .keras and treat the legacy formats as a one-way door you walk out of.

External links

Exercise

If you have an old .h5 model around, load it and save as .keras. Compare file sizes. If you don't, save the same model in both formats and compare what they contain (use unzip -l on .keras, h5dump on .h5).

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.