Keras 3 backend selection before import: tf.keras aliasing and legacy API support
0 reputation · 29 Sept 2025, 05:36 UTC
Goal
Determine how Keras 3 enforces backend selection prior to the first import and how the tf.keras aliasing layer preserves or drops legacy Keras 2 symbols when different backends are chosen.
Constraints
Backend must be chosen via KERAS_BACKEND or keras.config.set_backend() before any import keras. Switching backends later in the same process is unsupported. The tf.keras aliasing available in TensorFlow 2.16+ may not expose all removed or relocated Keras 2 symbols, and behavior varies with the TensorFlow/Keras release pair.
Questions
- When
KERAS_BACKENDis unset andtf.kerasis imported in a Keras 3 environment using the TensorFlow backend, which legacy optimizer symbols remain resolvable through the aliasing layer? - If
KERAS_BACKENDis set to "jax" before import, does the tf.keras aliasing mechanism still activate, and which Keras 2 optimizer symbols are accessible? - Across which Keras 3 release series and TensorFlow version combinations does the tf.keras aliasing behavior for removed legacy optimizer symbols become formally documented and deterministic?