One Library, Several Engines
Keras 3 can run on top of TensorFlow, JAX or PyTorch. You write your model once and choose the engine that suits your needs: TensorFlow for deployment tools, JAX for speed, PyTorch for its ecosystem.
Choosing the Backend
The backend must be set before importing Keras, and it cannot be changed after the import in the same Python session.
You can also set it outside Python, either with an environment variable or in the Keras config file.
pip install jax or pip install torch. For GPU support, follow the installation guide of that framework, and use a separate clean environment for each backend.
Write Portable Code with keras.ops
keras.ops mirrors the NumPy API and works on every backend. Use it in custom layers and losses instead of tf. functions to stay portable.
Model Code Stays the Same
Backend Comparison
| Backend | Strengths | Watch out |
|---|---|---|
| TensorFlow | Mature deployment (TFLite, TF Serving), tf.data | None for beginners, a good default |
| JAX | Very fast compiled training, TPUs | Fewer beginner tutorials |
| PyTorch | Large research ecosystem, easy debugging | Use torch ops in custom training code |
Data Pipelines
Keras 3 fit() accepts NumPy arrays, tf.data.Dataset objects, PyTorch DataLoader objects and Python generators, no matter which backend is selected. So you can reuse your data code.
What Is Not Portable?
- Code that calls
tf.*functions directly, such astf.GradientTapein custom loops - Saving with
model.export()for the SavedModel format, which requires TensorFlow - Backend-specific custom layers
Models saved in the .keras format can be loaded on any backend.
keras.ops so that you can switch later if you want.
Conclusion
Keras 3 gives you freedom from lock-in. Set the backend first, then write portable code with keras.ops.

