Dear Keras users,
We are now very close to the general release of Keras 3, the new multi-backend Keras with support for JAX, TensorFlow, and PyTorch. The launch will be in November.
Here's the latest:
1. Keras 3 is now available via the keras-nightly dev package on pip. You can install it via `pip install keras-nightly --upgrade`. After installing keras-nightly, you can just use it via `import keras` as usual.
2. tf-nightly is now depending on the new keras-nightly (Keras 3), and tf.keras in tf-nightly now resolves to Keras 3. Note that if your package or your CI depended on tf-nightly, this may have caused some breakages for you. See "What might break when I switch from Keras 2 to Keras 3" and "What to do to keep using Keras 2 after the Keras 3 release" sections for more information.
3. Keras 2 (the legacy, TensorFlow-only Keras version) is now available as a standalone package, `tf-keras`. You can install it via `pip install tf-keras`. After installing it, you can use it via e.g. `import tf_keras as keras`.
4. In TensorFlow 2.15 (to be released in November), tf.keras will keep resolving to keras==2.15 by default (legacy Keras 2). There are no immediate changes for tf.keras users.
5. In TensorFlow 2.16 (to be released early 2024), tf.keras will resolve to keras==3.x. tf.keras users will have to make sure their code is Keras-3 ready by then (or alternatively, use the fallback described in section "What to do to keep using Keras 2 after the Keras 3 release".
7. The beta Keras 3 preview package, keras-core, is being slowly phased out. If you were using it, I recommend switching to keras-nightly instead (you can pin a specific keras-nightly version in order to maintain stability). Likewise the GitHub repo keras-team/keras-core is no longer in use.
Q: What might break when I switch from Keras 2 to Keras 3?
The exhaustive list of incompatibilities between Keras 2 and Keras 3 is described
here. They're all related to niche features, except two:
- XLA compilation is now on by default. If this breaks you, you can turn it off by passing `jit_compile=False` in `model.compile()`.
- `model.save()` and `load_model()` no longer support the TF SavedModel format. To keep using TF SavedModel, you can save your model via `tf.saved_model.save()` and reload it for use in Keras via `keras.layers.TFSMLayer`.
Q: What to do to keep using Keras 2 after the Keras 3 release?
You have the option to ignore the changes in Keras 3 and just keep using Keras 2 with TensorFlow (this can be a good option for projects that are not actively developed but need to keep running with updated dependencies).
If you were accessing `keras` as a standalone package, just switch to using `tf_keras` instead. The code and API is wholly unchanged -- it's Keras 2.15 with a different package name. We will keep fixing bugs in `tf_keras` and regularly releasing new versions. However, no new features or performance improvements will be added, since the package is now in maintenance mode.
If you were accessing `keras` via `tf.keras`, there are no immediate changes until TF 2.16. In TF 2.16+, to keep using Keras 2, you can first install `tf_keras`, and then export the environment variable TF_USE_LEGACY_KERAS=1. This will direct TF 2.16+ to resolve tf.keras to the locally-installed tf_keras package. Note that this may affect more than your own code, however: it will affect any package importing `tf.keras` in your Python process. To make sure your changes only affect your own code, you should use the `tf_keras` package.
Best,
Francois