{"id":811,"library":"tf-keras-nightly","title":"TF-Keras Nightly","description":"TF-Keras is a deep learning API written in Python, running on top of the machine learning platform TensorFlow. It was developed with a focus on enabling fast experimentation and providing a delightful developer experience. As a nightly build, it offers the very latest features and bug fixes, with daily releases. The current version is 2.21.0.dev2026032809.","status":"active","version":"2.21.0.dev2026032809","language":"python","source_language":"en","source_url":"https://github.com/keras-team/tf-keras","tags":["deep learning","machine learning","tensorflow","keras","nightly"],"install":[{"cmd":"pip install tf-keras-nightly","lang":"bash","label":"Install latest nightly build"}],"dependencies":[{"reason":"tf-keras-nightly is the Keras API integrated within TensorFlow, typically used with the corresponding TensorFlow nightly build for the latest features and compatibility.","package":"tensorflow-nightly","optional":true}],"imports":[{"symbol":"keras","correct":"from tensorflow import keras"},{"note":"While 'keras' (the multi-backend Keras 3 package) and 'tf.keras' often expose the same API, 'tf-keras-nightly' specifically refers to the Keras implementation bundled with TensorFlow. Directly importing 'keras' might point to a different Keras installation or an older Keras 2 if not explicitly managed.","wrong":"import keras","symbol":"keras","correct":"import tensorflow.keras as keras"}],"quickstart":{"code":"import tensorflow as tf\nimport os\n\n# Ensure Keras backend is set to TensorFlow if running multi-backend Keras 3\n# (though tf-keras-nightly implies TensorFlow backend by nature)\n# os.environ[\"KERAS_BACKEND\"] = \"tensorflow\"\n\n# Import Keras from TensorFlow's namespace\nfrom tensorflow import keras\nfrom keras import layers\n\n# Define a simple sequential model\nmodel = keras.Sequential([\n    layers.Dense(64, activation='relu', input_shape=(784,)),\n    layers.Dense(64, activation='relu'),\n    layers.Dense(10, activation='softmax')\n])\n\n# Compile the model\nmodel.compile(\n    optimizer=keras.optimizers.Adam(learning_rate=0.001),\n    loss=keras.losses.SparseCategoricalCrossentropy(),\n    metrics=[keras.metrics.SparseCategoricalAccuracy()]\n)\n\n# Generate dummy data\nimport numpy as np\nx_train = np.random.rand(100, 784).astype('float32')\ny_train = np.random.randint(0, 10, 100).astype('int32')\n\n# Train the model\nprint(\"Starting model training...\")\nmodel.fit(x_train, y_train, epochs=1, batch_size=32)\nprint(\"Model training finished.\")\n\n# Save the model (using the recommended .keras format)\nmodel.save('my_model.keras')\nprint(\"Model saved as my_model.keras\")\n\n# Load the model\nloaded_model = keras.models.load_model('my_model.keras')\nprint(\"Model loaded successfully.\")","lang":"python","description":"This quickstart demonstrates how to define, compile, train, and save a basic Keras Sequential model using the `tensorflow.keras` API. It uses dummy data for a simple classification task."},"warnings":[{"fix":"If encountering checkpoint loading issues or needing to use the old optimizer behavior, explicitly use the legacy optimizers: `tf.keras.optimizers.legacy.Adam()`.","message":"Keras optimizers were moved to `tf.keras.optimizers.legacy` starting with TensorFlow 2.12. Directly instantiating `keras.optimizers.Adam()` (or other optimizers) will use the new Keras 3 optimizers, which handle state differently and may break checkpoint loading from models trained with older optimizers.","severity":"breaking","affected_versions":"TensorFlow 2.12+ (and corresponding tf-keras-nightly versions)"},{"fix":"To save in the legacy H5 format, explicitly specify `save_format=\"h5\"`: `model.save('my_model.h5', save_format=\"h5\")`.","message":"The default Keras model saving format for `model.save()` is now the `.keras` format (Keras V3 format), not the legacy H5 format, when using `model.save('my_model.keras')`. This change was introduced with TensorFlow 2.13 and Keras 2.13.","severity":"breaking","affected_versions":"TensorFlow 2.13+ (and corresponding tf-keras-nightly versions)"},{"fix":"Use `tf-keras-nightly` for access to the newest features and bug fixes, but be prepared for potential instability or API changes without notice. For production environments, prefer stable releases of `tensorflow`.","message":"`tf-keras-nightly` is a nightly build, meaning it's built from the latest development branch and is not guaranteed to be stable or backward compatible between daily releases.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure your Python environment is version 3.10 or newer before installing `tf-keras-nightly`.","message":"Requires Python >=3.10. Installing with older Python versions will result in an installation error.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure `tensorflow` is installed by running `pip install tensorflow` in your environment.","message":"`tensorflow` module not found. This typically means the the `tensorflow` package has not been installed in the current Python environment.","severity":"breaking","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-05-12T19:49:29.771Z","next_check":"2026-06-27T00:00:00.000Z","problems":[],"ecosystem":"pypi","meta_description":null,"install_score":0,"install_tag":"stale","quickstart_score":null,"quickstart_tag":null,"pypi_latest":"2.21.0.dev2026051209","cli_name":null,"install_checks":{"last_tested":"2026-05-12","tag":"stale","tag_description":"widespread failures or data too old to trust","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":"timeout","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":"timeout","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"37.6M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":"timeout","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"29.0M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":"timeout","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"28.6M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":"timeout","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":9.81,"mem_mb":126.2,"disk_size":"2.2G"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":"timeout","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":"timeout","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":7.55,"mem_mb":118.5,"disk_size":"2.1G"}]},"quickstart_checks":{"last_tested":"2026-04-24","tag":null,"tag_description":null,"results":[{"runtime":"python:3.10-alpine","exit_code":-1},{"runtime":"python:3.10-slim","exit_code":-1},{"runtime":"python:3.11-alpine","exit_code":-1},{"runtime":"python:3.11-slim","exit_code":-1},{"runtime":"python:3.12-alpine","exit_code":-1},{"runtime":"python:3.12-slim","exit_code":-1},{"runtime":"python:3.13-alpine","exit_code":-1},{"runtime":"python:3.13-slim","exit_code":-1},{"runtime":"python:3.9-alpine","exit_code":-1},{"runtime":"python:3.9-slim","exit_code":-1}]}}