You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
tensorflow-model-optimization fails to import in official tensorflow:2.15.0 Docker image due to TF_USE_LEGACY_KERAS=1 and missing tf_keras #1272
When using the official TensorFlow Docker image tensorflow/tensorflow:2.15.0, the environment variable TF_USE_LEGACY_KERAS is preset to 1 (True). This causes tensorflow-model-optimization (tfmot) to fail with an ImportError because it expects tf_keras to be installed.
Attempting to install tf_keras leads to an automatic upgrade of TensorFlow to 2.21+, which breaks compatibility with tfmot (which is designed for TensorFlow 2.15).
Pull the official image:
docker pull tensorflow/tensorflow:2.15.0
docker run -it tensorflow/tensorflow:2.15.0 bash
pip install tensorflow-model-optimization==0.8.0
python -c "import tensorflow_model_optimization as tfmot"
The import fails with:
ImportError: Keras cannot be imported. Check that it is installed.
Activity