Skip to content
CAI
Software that uses CAICheck a score

keras-team/keras

58.2

Weak · 11 October 2026

157.2k

lines of production code

Python

primary language

3

measurements over time

CAI band scale
CAI trend line
CAI lens gauges

What this system is

This system is Keras 3, a high-level deep learning API that provides a unified interface for building and training neural networks across multiple execution backends, including JAX, TensorFlow, and PyTorch. It enables users to define models using a consistent set of layers, optimizers, and metrics while allowing runtime switching between engines via configuration. The system supports advanced workflows such as distributed training, model export to various formats, and fine-tuning through techniques like LoRA and quantization.

How it got here

2015–2024 — Keras 3 multi-backend architecture

64 changes.

This period covers the development and release of Keras 3, introducing a pluggable multi-backend architecture that supports JAX, TensorFlow, PyTorch, and NumPy. The work involved restructuring the core library to enable backend-agnostic operations, implementing comprehensive integration tests, and adding extensive features such as distributed training, model export, and new layer implementations.

2025–2026 — Backend modularization and quantization features

7 changes.

This period focused on restructuring backend operations for JAX, NumPy, TensorFlow, and PyTorch into modular sub-packages to improve code organization and maintainability. It also introduced new capabilities for model optimization, including a dedicated Distillation API and a unified registry for various quantization strategies such as Int4, Int8, and Float8.

Features

Add adaptive pooling layers (1D, 2D, 3D) for average and max operations

New \AdaptiveAveragePooling1D/2D/3D\ and \AdaptiveMaxPooling1D/2D/3D\ layers are now available in \keras.layers\. These layers allow you to specify a target \output\_size\ (as an integer or tuple) regardless of the input dimensions, automatically computing the necessary kernel size and stride to achieve that output shape. They support both \channels\_last\ and \channels\_first\ data formats and are exported as \keras.layers.AdaptiveAveragePooling1D\, \keras.layers.AdaptiveAveragePooling2D\, \keras.layers.AdaptiveAveragePooling3D\, \keras.layers.AdaptiveMaxPooling1D\, \keras.layers.AdaptiveMaxPooling2D\, and \keras.layers.AdaptiveMaxPooling3D\.

keras/src/layers/pooling · high confidence

Add benchmark to compare Keras and Torch performance using a custom training loop

A new benchmark suite has been added to evaluate the performance difference between Keras and PyTorch models when executed under an identical PyTorch custom training loop. The suite includes a convolutional model benchmark (conv\_model\_benchmark.py) and a dense model benchmark (dense\_model\_benchmark.py), which construct equivalent architectures in both frameworks and measure execution time per batch. Users can run these comparisons by executing the benchmark modules directly, helping to understand the overhead or efficiency gains of the modeling API choice.

_benchmarks/torch\_ctl\benchmark · high confidence

Add layer performance benchmarks

The \benchmarks/layer\_benchmark\ directory now includes a comprehensive suite of scripts to measure and compare the performance of Keras layers against TensorFlow/Keras equivalents. This suite covers activation, attention, convolution, core, merge, normalization, pooling, regularization, reshaping, and RNN layers, allowing users to evaluate forward pass and training step throughput with configurable sample counts, batch sizes, and JIT compilation options.

_benchmarks/layer\benchmark · high confidence

Add legacy Keras 1/2 compatibility layer

Introduces the \keras.\_legacy\ namespace to support code written for Keras 1 and 2. This includes a \backend\ module that wraps TensorFlow operations with deprecated wrappers, a \layers\ module containing legacy implementations like \AlphaDropout\, \RandomHeight\, and \RandomWidth\, and a \losses\ module providing the \Reduction\ enum for backward compatibility.

keras/src/legacy · high confidence

Add legacy preprocessing modules for image, sequence, and text data

The \keras/src/legacy/preprocessing\ package now includes \image.py\, \sequence.py\, and \text.py\, exposing deprecated Keras 1 APIs such as \Iterator\, \TimeseriesGenerator\, \Tokenizer\, and various text utilities. These classes and functions are marked as deprecated and are exported under the \keras.\_legacy.preprocessing\ namespace to support migration from older Keras versions.

keras/src/legacy/preprocessing · high confidence

Enable direct 'import keras' from repository root

A new \keras/\_\init\\_.py\ file has been added to the repository root to allow importing Keras directly via \import keras\ when running from the source tree. This file extends the module search path to include the \api\ directory and re-exports all public symbols from \keras.api\, ensuring that the top-level namespace matches the structured API layout while keeping the namespace clean by removing temporary imports.

keras · high confidence

Initial NumPy backend implementation

The NumPy backend is now available as a pluggable execution engine, providing core capabilities for inference and evaluation. This includes a full set of random number generation functions (normal, uniform, categorical, dropout, etc.), a native RNN loop implementation that supports masking and unrolling, and a \NumpyTrainer\ class that enables \predict\ and \evaluate\ operations. The backend exposes configuration flags indicating it is thread-safe but does not support complex dtypes, gradients, ragged tensors, or sparse tensors, and it currently lacks \fit\ support and model export functionality.

keras/src/backend/numpy · high confidence

Initial devcontainer configuration for local development

Developers can now use GitHub Codespaces, Visual Studio Code, or JetBrains IDEs to run the project in a standardized container environment. The setup installs Python 3.10, configures the Ruff extension for linting and formatting, enables pre-commit hooks, and installs project dependencies via requirements.txt.

.devcontainer · high confidence

Introduce DTypePolicyMap for per-layer dtype configuration

Users can now assign different dtype policies to specific layers within a model using the new \DTypePolicyMap\ class. This dict-like object maps layer paths (supporting exact matches and regex patterns) to \DTypePolicy\ instances, enabling complex mixed-precision and quantization setups where sub-layers require different data types. The \dtype\_policies\ module also exports the full suite of policy classes, including \GPTQDTypePolicy\, \AWQDTypePolicy\, \Int4DTypePolicy\, and \QuantizedFloat8DTypePolicy\, along with serialization and deserialization utilities to ensure these configurations are preserved when saving and loading models.

_keras/src/dtype\policies · high confidence

Introduce Keras Distillation API for knowledge distillation

Adds a new \keras.distillation\ module providing a \Distiller\ model class and loss functions (\LogitsDistillation\, \FeatureDistillation\) to facilitate knowledge distillation. Users can now wrap a teacher and student model in a \Distiller\ instance to train the student using both ground truth labels and the teacher's outputs, with support for multiple distillation losses and configurable loss weights.

keras/src/distillation · high confidence

Introduce Keras constraints module with serialization and retrieval APIs

The \keras.constraints\ module is now available, providing a standardized way to apply weight constraints such as MaxNorm, NonNeg, UnitNorm, and MinMaxNorm to layers. This change introduces the \Constraint\ base class and specific implementations, along with \serialize\, \deserialize\, and \get\ functions to support configuration-based instantiation and saving/loading of models. Users can now easily apply these constraints via layer arguments like \kernel\_constraint\ and ensure they are correctly persisted in model configs.

keras/src/constraints · high confidence

Introduce PyTorch backend with distributed training and export support

The PyTorch backend is now available, providing core tensor operations, random number generation, and RNN implementations. It includes robust support for distributed training via PyTorch DTensor and DistributedDataParallel (DDP), allowing data and model parallelism across multiple processes and devices. Additionally, the backend supports exporting Keras models to the SavedModel format using torch-xla, enabling interoperability with TensorFlow-based serving infrastructure.

keras/src/backend/torch · high confidence

Introduce \`keras.random\` module with \`SeedGenerator\` for reproducible randomness

Keras now provides a dedicated \keras.random\ API for random number generation, including functions for normal, uniform, categorical, randint, truncated normal, dropout, and shuffle distributions. A key addition is the \SeedGenerator\ class, which allows users to maintain stateful, reproducible random sequences across multiple calls (e.g., within layers) without relying on global state, addressing issues with determinism in JIT-compiled backends like JAX. The module also includes a global seed generator for simple use cases and handles backend-specific seed dtype and overflow constraints automatically.

keras/src/random · high confidence

Introduce backend-agnostic device placement and pluggable backend support

Users can now control device placement across all supported backends (TensorFlow, JAX, PyTorch, NumPy) using the new \keras.device()\ context manager, which allows operations and tensors to be explicitly allocated on specific CPUs or GPUs. Additionally, the backend system has been refactored to support pluggable backends (such as MLX, OpenVINO, and PaddlePaddle) alongside the built-in ones, with configuration options like \PLUGGABLE\_BACKENDS\ and \BUILT\_IN\_BACKENDS\ now exposed in \keras.config\. The \keras.Variable\ class is also re-exported for consistency, and backend-specific imports are handled dynamically based on the active backend.

keras/src/backend · high confidence

Introduce common backend utilities and symbolic tensor infrastructure

This change establishes a shared \keras.backend.common\ layer by adding core utilities and the \KerasTensor\ symbolic tensor class. It introduces \backend\_utils\ to handle cross-backend padding conversions for \ConvTranspose\ operations (JAX and Torch), a \dtypes\ module implementing a JAX-style type promotion lattice, and a \name\_scope\ context manager for managing variable paths. The \KerasTensor\ class provides the foundation for static shape inference in Functional models, while \global\_state\ and \masking\ modules support session clearing and tensor masking. Comprehensive tests are included for these new components.

keras/src/backend/common · high confidence

Introduce legacy HDF5 saving and loading implementation

Adds the \keras/src/legacy/saving\ module, providing the core infrastructure for saving and loading Keras models in the legacy HDF5 format. This includes \legacy\_h5\_format.py\ for model and weight I/O, \json\_utils.py\ for serializing TensorFlow-specific types (such as TensorShapes, TypeSpecs, and tuples) to JSON, and \serialization.py\ for handling shared object references and deserialization. The implementation ensures that model compile configurations are preserved during save operations and that the \safe\_mode\ flag is correctly propagated to prevent arbitrary code execution when loading untrusted files.

keras/src/legacy/saving · high confidence

Introduce native .keras model format and KerasFileEditor

Keras now uses a new native \.keras\ file format (a ZIP archive containing \config.json\, \model.weights.h5\, and \metadata.json\) for saving and loading models, replacing the legacy HDF5 format. The \load\_model\ and \save\_model\ APIs now support this format, file-like objects (\io.IOBase\), and remote paths (including Hugging Face Hub). A new \KerasFileEditor\ utility allows users to inspect, compare, and edit weight files (\.keras\ and \.weights.h5\) to adapt models after architecture changes. The change also includes Orbax checkpoint integration for JAX, improved security measures against decompression bombs and malicious HDF5 links, and a new \keras\_saveable\ interface for pickle support.

keras/src/saving · high confidence

Introduce scikit-learn wrappers for Keras models

Users can now wrap Keras models as scikit-learn estimators using the new \SKLearnClassifier\, \SKLearnRegressor\, and \SKLearnTransformer\ classes. These wrappers allow Keras models to be used directly in scikit-learn pipelines and utilities, supporting features like \warm\_start\ to reuse model weights across fits and dynamic metadata routing for scikit-learn versions 1.3 and above. The scikit-learn dependency is optional, ensuring the rest of Keras remains unaffected if scikit-learn is not installed.

keras/src/wrappers · high confidence

Introduce shell scripts for API generation and code formatting

Added two new executable shell scripts to streamline development workflows: \shell/api\_gen.sh\ generates the public API directory and subsequently formats the output using pre-commit hooks, while \shell/format.sh\ runs the full codebase formatting via pre-commit (requiring the pre-commit package to be installed). These scripts provide convenient entry points for maintaining code style and API consistency.

shell · high confidence

Introduce unified high-level distribution APIs for distributed training

Keras now exposes a new \keras.distribution\ module providing a unified interface for distributed training across backends. Users can initialize multi-host/process environments via \keras.distribution.initialize\ (supporting both explicit parameters and environment variables), discover available hardware with \list\_devices\ and \get\_device\_count\, and define device topologies using \DeviceMesh\. The module also introduces \TensorLayout\ and \Distribution\ classes to manage how tensors and variables are sharded across devices, enabling data and model parallelism strategies in a backend-agnostic way.

keras/src/distribution · high confidence

Introduce unified tree API with backend-specific implementations

Keras now provides a unified \keras.tree\ API for traversing and manipulating nested Python structures (lists, dicts, namedtuples, etc.), ensuring consistent behavior across TensorFlow, PyTorch, and JAX backends. The implementation automatically selects the optimal backend-specific engine: \torchtree\_impl\ for the PyTorch backend (optimized for \torch.compile\ compatibility), \optree\_impl\ for TensorFlow and JAX when available, and a pure-Python \dmtree\_impl\ fallback. This change introduces new capabilities such as \flatten\_with\_path\ and \assert\_same\_paths\, fixes deterministic ordering for dictionaries in the PyTorch backend, and ensures Keras tracking wrappers (like \TrackedDict\) are correctly handled as nested structures.

keras/src/tree · high confidence

Introduces PyTorch backend implementations for Keras optimizers

This change adds the initial PyTorch backend implementations for Keras optimizers, including Adadelta, Adagrad, Adam, Adamax, AdamW, Lion, Nadam, RMSprop, and SGD. These new classes inherit from Keras optimizer base classes and implement the \TorchParallelOptimizer\ interface to handle gradient updates using PyTorch's foreach operations, enabling Keras models to run on the PyTorch backend.

keras/src/backend/torch/optimizers · high confidence

Introduces a unified quantization strategy registry and built-in mode implementations

The \keras/src/quantizers/modes\ package now provides a centralized registry for quantization strategies, explicitly registering built-in modes (Int8, Float8, Int4, Ternary, GPTQ, and AWQ) to ensure deterministic validation and configuration resolution. This change introduces dedicated strategy classes for each mode—such as \Int8Strategy\ for dynamic W8A8 quantization, \Float8Strategy\ for QDQ mixed-precision training, and \CalibrationStrategy\ as a shared base for post-training methods like GPTQ and AWQ—along with common geometry dispatch logic and helper utilities. Users benefit from a consistent interface for enabling and configuring these quantization modes across supported layer types.

keras/src/quantizers/modes · high confidence

Introduction of Convolutional LSTM layers (1D, 2D, 3D) and Bidirectional wrapper

This change introduces the \ConvLSTM1D\, \ConvLSTM2D\, and \ConvLSTM3D\ layers, which apply convolutional transformations in both the input and recurrent steps for spatiotemporal data. These layers support configurable strides, dilation rates, and dropout, with validation to prevent incompatible stride/dilation combinations. Additionally, the \Bidirectional\ layer wrapper is provided to apply any RNN (including the new ConvLSTMs) in both forward and backward directions, supporting various merge modes (concat, sum, ave, mul) and custom backward layers.

keras/src/layers/rnn · high confidence

Introduction of Keras Applications module with comprehensive model implementations and tests

The \keras/src/applications\ directory has been introduced, providing a complete suite of pre-trained image classification models including ConvNeXt, DenseNet, EfficientNet (v1 and v2), Inception, MobileNet (v1, v2, v3), NASNet, ResNet (v1 and v2), VGG, and Xception. This release includes the core application modules, shared ImageNet utilities for preprocessing and prediction, and a comprehensive test suite (\applications\_test.py\) that validates model instantiation, input shape compatibility, and backend support across all listed architectures.

keras/src/applications · high confidence

Introduction of a unified DataAdapter system for multi-backend data handling

Keras now uses a new \DataAdapter\ architecture in \keras/src/trainers/data\_adapters\ to manage input data for \model.fit()\. This system introduces dedicated adapters for NumPy arrays, Python generators, TensorFlow \tf.data.Dataset\, PyTorch \DataLoader\, and the new \grain\ library, along with a central \get\_data\_adapter\ dispatcher that routes inputs to the correct handler. The change standardizes how data is sliced, shuffled, and converted across backends (NumPy, JAX, TensorFlow, PyTorch) and adds support for distributed data sharding, class weight normalization, and better error handling for empty or malformed inputs.

_keras/src/trainers/data\adapters · high confidence

Introduction of core model classes and cloning utilities

This change introduces the foundational model architecture for Keras, adding the \Model\, \Functional\, and \Sequential\ classes to \keras/src/models\. It also provides the \clone\_model\ utility in \cloning.py\, which allows users to create independent copies of Functional or Sequential models with fresh weights, supporting custom layer cloning and input tensor injection. Comprehensive test suites are included to validate model construction, cloning correctness, and input/output structure handling.

keras/src/models · high confidence

Introduction of the BackupAndRestore callback for fault-tolerant training

Users can now use the \keras.callbacks.BackupAndRestore\ callback to automatically recover training from interruptions. This callback saves the model weights and training metadata (such as the current epoch and batch) to a specified directory at the end of each epoch or at configurable batch intervals. If training is interrupted and restarted, the callback restores the most recent state, allowing the model to continue from where it left off. It also supports a \double\_checkpoint\ mode to improve fault tolerance against file corruption by keeping a backup of the previous checkpoint.

keras/src/callbacks · high confidence

Keras 3 initial release with multi-backend support and pluggable architecture

This entry marks the initial public release of Keras 3, a high-level deep learning API that supports JAX, TensorFlow, PyTorch, and OpenVINO (inference-only) as backends. The release introduces a pluggable backend architecture, allowing users to switch engines via the \KERAS\_BACKEND\ environment variable or configuration file. It includes a new \pip\_build.py\ script for creating and installing wheel packages, an \api\_gen.py\ tool for generating the public API surface, and a \CITATION.cff\ file for repository citation. The project also establishes a new security policy in \SECURITY.md\, updates the license to Apache 2.0, and sets a minimum Python version of 3.10.

(repo-wide) · high confidence

Keras layers module restructured and expanded with new preprocessing and quantization layers

The \keras/src/layers\ package has been reorganized into a modular structure, with the main \\_\init\\_.py\ now explicitly exporting a comprehensive set of layers including new image preprocessing augmentations (such as AugMix, CutMix, RandAugment, and various random color/geometry transforms), specialized normalization layers (RMSNormalization), and ternary-weight dense layers. The core \Layer\ base class has been updated to support pluggable backends, rematerialization (remat) for memory optimization, and improved input validation via \InputSpec\, while \InputSpec\ itself now supports optional inputs and clearer error messaging for mismatched dictionary inputs. Additionally, the module introduces support for quantization protocols, including \QuantizedWeight\ views and fine-grained control via \QuantizationConfig\, and integrates new layers like \ReversibleEmbedding\ and \TernaryDense\ directly into the public API.

keras/src/layers · high confidence

New AWQ quantization support and unified quantization configuration system

Users can now apply Activation-aware Weight Quantization (AWQ) to models using the new \AWQConfig\ class, which handles calibration data, tokenizer integration, and per-channel scale search. This feature is built on a new \QuantizationConfig\ base class that standardizes how quantization modes (including AWQ, GPTQ, INT4, INT8, Float8, and Ternary) are configured, serialized, and deserialized. The \keras.quantizers\ module now exposes a unified registry and \get()\ API to resolve quantizer identifiers, ensuring that quantization settings are consistently applied and saved across different model types.

keras/src/quantizers · high confidence

New Keras examples demonstrating custom workflows and multi-backend usage

Added a suite of new example scripts in the \examples/\ directory that demonstrate advanced Keras usage patterns. These include custom training loops for JAX (using \stateless\_call\ and \stateless\_apply\), TensorFlow (using \tf.GradientTape\), and PyTorch (using native \torch\ optimizers and loss functions). The examples also showcase backend-agnostic custom layer implementation, the functional API, model subclassing, and distributed training setups for both JAX (TPU VMs) and PyTorch (multi-GPU DDP).

examples · high confidence

New activation functions and serialization support added

The \keras.activations\ module now exposes a significantly expanded set of activation functions, including celu, glu, hard\_shrink, hard\_tanh, log\_sigmoid, soft\_shrink, sparse\_plus, sparse\_sigmoid, sparsemax, squareplus, tanh\_shrink, and threshold, in addition to existing ones like relu, sigmoid, and softmax. This update also introduces robust serialization and deserialization capabilities for these activations, allowing users to save and load models that utilize these functions without errors. The \get\ function has been updated to resolve activations by name or configuration, ensuring compatibility with saved model formats.

keras/src/activations · high confidence

New attention layers: Additive, GroupedQuery, and MultiHeadAttention

The \keras/src/layers/attention\ module now includes new implementations for \AdditiveAttention\, \MultiHeadAttention\, and \GroupedQueryAttention\. \AdditiveAttention\ (Bahdanau-style) supports optional scaling and dropout. \MultiHeadAttention\ and \GroupedQueryAttention\ introduce support for sliding windows, causal masking, and optional gated attention mechanisms to improve training stability. Both multi-head variants also integrate flash attention for accelerated computation on supported backends (JAX, Torch) and allow configuring dropout seeds for reproducibility.

keras/src/layers/attention · high confidence

New bounding box utility functions and validation logic

This change introduces a new \bounding\_boxes\ module under \keras/src/layers/preprocessing/image\_preprocessing\ that provides core utilities for handling bounding box data. It adds \convert\_format\ for converting between multiple coordinate systems (such as \xyxy\, \xywh\, \center\_xywh\, and their relative variants), \clip\_to\_image\_size\ to constrain boxes within image boundaries, and \affine\_transform\ to apply geometric transformations like rotation, scaling, and shearing. The module also includes \compute\_iou\ and \compute\_ciou\ for calculating Intersection over Union and Complete IoU metrics, along with \densify\_bounding\_boxes\ to handle variable-length box lists and ragged tensors by padding them to a fixed size. These utilities are exported under \keras.utils.bounding\_boxes\ and are accompanied by comprehensive tests covering format conversions, geometric operations, and IOU calculations.

_keras/src/layers/preprocessing/image\_preprocessing/bounding\boxes · high confidence

New correlation metrics and updated metric infrastructure

Users can now use PearsonCorrelation and ConcordanceCorrelation metrics for regression tasks, available as both classes and functional APIs. The metrics module has been restructured with a new \_\init\\_.py that centralizes exports and provides serialize/deserialize/get utilities, while accuracy, confusion, and F-score metrics have been refactored to support configurable thresholds, sample weighting, and consistent dtype handling across all implementations.

keras/src/metrics · high confidence

New image preprocessing layers and bounding box support

This release introduces several new image preprocessing layers including AugMix, AutoContrast, ContrastLimitedAdaptiveHistogramEqualization (CLAHE), and CutMix, alongside a refactored base layer architecture. A key behavioral change is the addition of bounding box transformation support across multiple layers (such as CenterCrop, RandomShear, RandomTranslation, RandomFlip, and RandomZoom), ensuring that bounding box coordinates are correctly adjusted when images are augmented. Additionally, segmentation masks now preserve their original data type and class indices by using nearest-neighbor interpolation during transformations, preventing the introduction of invalid class values.

_keras/src/layers/preprocessing/image\preprocessing · high confidence

New layer-based activation implementations for ReLU, Softmax, ELU, LeakyReLU, and PReLU

The \keras/src/layers/activations\ module now provides dedicated layer classes (\keras.layers.ReLU\, \keras.layers.Softmax\, \keras.layers.ELU\, \keras.layers.LeakyReLU\, \keras.layers.PReLU\, and \keras.layers.Activation\) that wrap the functional activation API. These layers support serialization via \get\_config\ and \from\_config\, allow masking (e.g., \Softmax\ now validates mask shapes and handles fully masked axes by outputting zeros), and include input validation for parameters like \negative\_slope\ and \threshold\. This change introduces a consistent layer-based interface for activations, replacing or supplementing the previous functional-only approach.

keras/src/layers/activations · high confidence

New learning rate schedule API in keras.optimizers.schedules

The \keras.optimizers.schedules\ module now exposes a dedicated API for learning rate scheduling, making it easier to apply dynamic learning rates to optimizers. This location introduces the \LearningRateSchedule\ base class and several built-in schedules—including \ExponentialDecay\, \PiecewiseConstantDecay\, \CosineDecay\, \CosineDecayRestarts\, \InverseTimeDecay\, and \PolynomialDecay\—all of which are serializable and can be passed directly as the \learning\_rate\ argument to any Keras optimizer.

keras/src/optimizers/schedules · high confidence

New merging layers (Add, Subtract, Multiply, Average, Maximum, Minimum, Concatenate, Dot) with masking support

This change introduces a new set of element-wise and merging layers in \keras.layers\, including \Add\, \Subtract\, \Multiply\, \Average\, \Maximum\, \Minimum\, \Concatenate\, and \Dot\, along with their functional interfaces (e.g., \keras.layers.add\). These layers are built on a new \Merge\ base class that enables proper masking propagation: \Multiply\ correctly handles masks by replacing masked values with 1s during multiplication and restoring 0s in the output, while \Maximum\ and \Minimum\ use an OR-reduction of input masks. \Concatenate\ also supports masking by concatenating and reducing input masks. The \Dot\ layer is included but explicitly skips masking tests, indicating masking is not supported for it. These layers allow users to perform standard tensor merging operations with correct behavior when inputs have associated masks.

keras/src/layers/merging · high confidence

New model benchmarking scripts for BERT and image classification

Added new benchmarking scripts in the \model\_benchmark\ directory to measure model performance. The \bert\_benchmark.py\ script benchmarks BERT models on the GLUE/MRPC task, supporting various model sizes and mixed precision policies. The \image\_classification\_benchmark.py\ script benchmarks image classification models (EfficientNetV2B0, Xception, ResNet50V2) on the Cats vs Dogs dataset. Both scripts utilize a shared \BenchmarkMetricsCallback\ to track throughput and report wall time, validation accuracy, and examples per second.

_benchmarks/model\benchmark · high confidence

New optimizers added: Muon, ScheduleFreeAdamW, and Adafactor

The \keras.optimizers\ module now includes three new optimization algorithms: Muon, ScheduleFreeAdamW, and Adafactor. Muon is a new optimizer designed for specific training dynamics, ScheduleFreeAdamW provides a schedule-free variant of AdamW for potentially faster convergence without learning rate scheduling, and Adafactor is a memory-efficient optimizer particularly suited for large models like those in NLP. These are now available via \keras.optimizers.Muon\, \keras.optimizers.ScheduleFreeAdamW\, and \keras.optimizers.Adafactor\ respectively, and are included in the standard serialization/deserialization and \get\ lookup mechanisms.

keras/src/optimizers · high confidence

New preprocessing layers and FeatureSpace utility for structured data

This change introduces several new preprocessing capabilities for structured data. The \FeatureSpace\ layer provides a unified interface to preprocess, encode, and cross multiple features (float, integer, string) in a single step, supporting both concatenated vector and dictionary outputs. It internally leverages new or refactored layers: \CategoryEncoding\ for fixed-vocabulary integer encoding (one-hot, multi-hot, count), \Discretization\ for bucketing continuous values into bins, and \HashedCrossing\ for generating interaction features via hashing. Additionally, a \DataLayer\ base class is added to ensure these preprocessing layers operate safely and correctly within \tf.data\ and \Grain\ pipelines by handling backend-specific execution contexts.

keras/src/layers/preprocessing · high confidence

New regularization layers: ActivityRegularization, AlphaDropout, GaussianDropout, GaussianNoise, and SpatialDropout variants

The \keras/src/layers/regularization\ module now includes several new regularization layers. \ActivityRegularization\ applies L1/L2 penalties to layer outputs. \AlphaDropout\ implements self-normalizing dropout for SELU activations. \GaussianDropout\ and \GaussianNoise\ add multiplicative and additive Gaussian noise respectively. \SpatialDropout1D\, \SpatialDropout2D\, and \SpatialDropout3D\ drop entire feature maps instead of individual elements to better handle correlated spatial data. All layers are exported under \keras.layers\ and include corresponding tests.

keras/src/layers/regularization · high confidence

New reshaping layers: Cropping1D, Cropping2D, Cropping3D, Flatten, Permute, RepeatVector, and Reshape

The \keras/src/layers/reshaping\ module now includes implementations for Cropping1D, Cropping2D, and Cropping3D, which trim spatial dimensions with configurable left/right or top/bottom cropping and support both channels-first and channels-last formats. The Flatten layer now handles sparse tensors and dynamic dimensions, while Permute supports sparse tensor permutation. RepeatVector validates that its repetition count is a positive integer. The Reshape layer validates its target shape and supports sparse tensors. Comprehensive tests are included for all new layers.

keras/src/layers/reshaping · high confidence

New unified export API with LiteRT, ONNX, and OpenVINO support

The \keras/src/export\ module now provides a standardized, backend-agnostic export system. Users can export models to LiteRT (\.tflite\), ONNX, OpenVINO (\.xml\/\.bin\), and SavedModel formats via new \export\_litert\, \export\_onnx\, \export\_openvino\, and \export\_saved\_model\ functions. The system supports complex input structures (dicts, lists, tuples) and handles backend-specific requirements, such as static input signatures for PyTorch-to-LiteRT and dynamic shape handling for ONNX. It also includes a dispatcher pattern (\ExportArchive\) to manage backend-specific export logic and a new \TFSMLayer\ for loading SavedModels.

keras/src/export · high confidence

New utility modules for backend switching, configuration, and dataset handling

The \keras.utils\ package now includes several new modules to support multi-backend workflows and data management. \backend\_utils\ introduces the \DynamicBackend\ class and \set\_backend\ function, allowing users to switch between backends (TensorFlow, JAX, PyTorch, NumPy) at runtime and resolve operations dynamically. A new \Config\ class provides a frozen, dict-like container for managing named configuration values with attribute-style access and JSON serialization. Additionally, \dataset\_utils\ adds \split\_dataset\, which supports splitting \tf.data\, \torch.utils.data\, and array-based datasets into train/validation splits with optional shuffling, and \audio\_dataset\_utils\ provides \audio\_dataset\_from\_directory\ to load audio data from directories into \tf.data\ or Grain datasets.

keras/src/utils · high confidence

New visualization utilities for bounding boxes and segmentation masks

Adds a new \keras.visualization\ module providing functions to visualize model outputs. \draw\_bounding\_boxes\ overlays bounding boxes with optional class labels and confidences on images, while \draw\_segmentation\_masks\ blends segmentation masks onto input images. Gallery helpers \plot\_image\_gallery\, \plot\_bounding\_box\_gallery\, and \plot\_segmentation\_mask\_gallery\ allow displaying these annotated images in grids, supporting side-by-side comparison of ground truth and predictions with legends.

keras/src/visualization · high confidence

Restructure Keras Ops into a modular package

The \keras.ops\ module has been reorganized from a flat structure into a modular package with dedicated submodules for core operations (\core.py\), linear algebra (\linalg.py\), math functions (\math.py\), neural network layers (\nn.py\), NumPy-compatible operations (\numpy.py\), and image processing (\image.py\). This change introduces new high-level control flow operations such as \map\, \scan\, and \vectorized\_map\ in the core module, adds einops-style tensor rearrangement via \ops.rearrange\, and provides a new \keras.Function\ class for capturing and reusing computation graphs. Image operations are now centralized in \ops.image\, including color space conversions like \rgb\_to\_hsv\ and \rgb\_to\_grayscale\, while linear algebra operations like \cholesky\ and \eigh\ are exposed under \ops.linalg\.

keras/src/ops · high confidence

TensorFlow backend implementation for Keras

The TensorFlow backend is now fully implemented in the \keras/src/backend/tensorflow\ directory, providing the core infrastructure for running Keras models on TensorFlow. This includes the \TFOptimizer\ for handling distributed training strategies like \MirroredStrategy\, the \TFExportArchive\ for SavedModel export, and specialized modules for random number generation, RNNs, and sparse tensor support. The backend exposes configuration flags such as \IS\_THREAD\_SAFE\, \SUPPORTS\_GRADIENT\, and \SUPPORTS\_COMPLEX\_DTYPES\ to define its capabilities, and includes comprehensive tests for distributed variable creation, optimizer behavior, and model serialization.

keras/src/backend/tensorflow · high confidence

Security

Secure built-in dataset loaders with restricted unpickling

The built-in dataset utilities (CIFAR-10, CIFAR-100, IMDB, and Reuters) now use a custom \RestrictedUnpickler\ to safely load data files. This change prevents arbitrary code execution vulnerabilities that could arise from maliciously crafted \.npz\ or pickle files, ensuring that only safe numpy array reconstruction is permitted during data loading.

keras/src/datasets · high confidence

Architecture

JAX backend restructured into a pluggable module with native distribution and export support

The JAX backend has been reorganized into a modular, pluggable architecture, introducing dedicated modules for distribution strategies, model export, and layer integration. Users can now leverage native JAX distribution capabilities, including multi-process initialization, device listing, and tensor sharding via \distribution\_lib\, alongside a new \JaxExportArchive\ for exporting models to TensorFlow SavedModel format. The backend also exposes backend-specific flags (e.g., \IS\_THREAD\_SAFE\, \SUPPORTS\_COMPLEX\_DTYPES\) and integrates with Flax NNX when enabled, providing a more robust foundation for distributed training and model serving on JAX.

keras/src/backend/jax · high confidence

PyTorch backend ops reorganized into modular subpackages

The PyTorch backend operations have been restructured from a flat structure into a dedicated \ops\ folder containing modular subpackages (\core\, \image\, \linalg\, \math\, \nn\, \numpy\). This change improves code organization and maintainability for the PyTorch backend without altering the public API surface.

keras/src/backend/torch/ops · high confidence

Reorganize NumPy backend operations into a modular ops package

The NumPy backend operations have been restructured from a flat namespace into a dedicated \keras/src/backend/numpy/ops\ package. This change introduces a modular layout with separate modules for core utilities, image processing, linear algebra, math functions, neural network layers, and general NumPy operations, all re-exported through a central \\_\init\\_.py\. This refactoring improves code organization and maintainability for the NumPy backend implementation without altering the public API surface.

keras/src/backend/numpy/ops · high confidence

TensorFlow backend ops reorganized into modular subpackages

The TensorFlow backend operations have been restructured from a flat structure into a dedicated \ops\ folder containing modular subpackages (\core\, \image\, \linalg\, \math\, \nn\, and \numpy\). This change improves code organization and maintainability by grouping related operations, while preserving the existing public API surface through the updated \\_\init\\_.py\ exports.

keras/src/backend/tensorflow/ops · high confidence

Behavioural changes

Autogenerated public API surface for Keras and \_tf\_keras

The \keras/api\ directory now contains autogenerated \\_\init\\_.py\ files that define the public API surface for both the main \keras\ package and the \keras.\_tf\_keras\ compatibility shim. These files expose the full set of modules (such as \layers\, \ops\, \applications\, \optimizers\, and \distillation\) and key classes (like \Model\, \Layer\, \Optimizer\, and \DTypePolicy\) to end users, ensuring that imports like \from keras import layers\ resolve correctly. This change establishes the public interface contract for the library, reflecting the current state of the underlying implementation modules.

keras/api · high confidence

Convolutional layers now support LoRA and validate output shapes

Convolutional layers (Conv1D, Conv2D, Conv1DTranspose, Conv2DTranspose, DepthwiseConv, SeparableConv) now support Low-Rank Adaptation (LoRA) via the \lora\_rank\ and \lora\_alpha\ parameters, allowing users to fine-tune models with reduced computational cost. Additionally, these layers now strictly validate output shapes during the build phase and fail fast on invalid configurations (such as \output\_padding\ being greater than or equal to \strides\ in transpose convolutions), preventing runtime crashes and ensuring consistent behavior across backends.

keras/src/layers/convolutional · high confidence

Core layers refactored with quantization geometry protocol and LoRA support

The core layer implementations (Dense, EinsumDense, Embedding, InputLayer, Identity) have been rewritten to integrate a new quantization geometry protocol, enabling fine-grained int8 and int4 quantization via QuantizationConfig, and adding configurable LoRA (Low-Rank Adaptation) support with lora\_rank and lora\_alpha parameters. The Dense and EinsumDense layers now expose unpacked int4 kernels via their kernel property and support quantization modes like GPTQ and AWQ. Embedding layers now validate input\_dim and output\_dim, support ragged tensors, and integrate with the quantization protocol. InputLayer now supports optional inputs and stricter validation when input\_tensor is provided. These changes improve model compression capabilities and fine-tuning efficiency for core layers.

keras/src/layers/core · high confidence

Initializers module restructured with direct tensor support and distribution layout handling

The \keras.initializers\ module has been reorganized into dedicated files (\constant\_initializers\, \random\initializers\, \initializer\) and now exposes a comprehensive \get\ function that accepts not only string names and configuration dicts, but also backend tensors or NumPy arrays to define initializer values directly. Additionally, the base \Initializer\ class and random initializers have been updated to support distribution layouts (via an optional \layout\ argument in \\\call\\_\), enabling proper tensor sharding across devices, while maintaining backward compatibility through aliases like \IdentityInitializer\ and \STFTInitializer\.

keras/src/initializers · high confidence

JAX backend ops reorganized into modular sub-packages

The JAX backend operations have been restructured from a flat structure into a dedicated \ops\ folder containing modular sub-packages (\core\, \image\, \linalg\, \math\, \nn\, \numpy\). This change introduces a new \JaxVariable\ class in \core.py\ to handle variable initialization and layout distribution, and adds support for Flax NNX variables when NNX is enabled. Specific behavioral improvements include promoting integer inputs to float in \leaky\_relu\, \hard\_sigmoid\, and \hard\_silu\ to match expected output specs, fixing \keras.ops.linalg.norm\ to accept lists for the \axis\ argument, and correcting \convert\_to\_tensor\ to preserve input dtype when \floatx\ is set to bfloat16.

keras/src/backend/jax/ops · high confidence

Keras 3.16.0 release with new API export infrastructure

This update releases Keras version 3.16.0, introducing a new \keras\_export\ decorator system in \keras/src/api\export.py\ that integrates with the \namex\ library to manage public API symbols and internal serialization registration. The \keras/src/\\init\\_.py\ module has been restructured to explicitly import and expose core components such as \KerasTensor\, \Input\, \Layer\, \Model\, \Functional\, and \Sequential\, alongside standard submodules like \activations\, \layers\, \models\, and \visualization\. A new \keras.version\ function is now available to programmatically retrieve the current version string.

keras/src · high confidence

Losses module restructured with new base class and expanded API

The \keras/src/losses\ module has been reorganized to introduce a new \Loss\ base class that standardizes reduction modes (including a new \mean\_with\_sample\_weight\ option), dtype handling, and serialization. This refactor updates the public API by exporting a comprehensive set of loss functions and classes (such as \Circle\, \SparseCategoricalFocalCrossentropy\, and \CTC\) via \keras.losses\, and provides utility functions for serialization, deserialization, and retrieval. Existing loss implementations have been refactored to inherit from this new base, ensuring consistent behavior across the library.

keras/src/losses · high confidence

New modular training infrastructure with structured loss and metric compilation

The training loop has been restructured into distinct components: \BaseTrainer\ now delegates data iteration to \EpochIterator\ and handles loss/metric aggregation via new \CompileLoss\ and \CompileMetrics\ utilities. This change introduces structured support for multi-output models, allowing users to pass nested lists, tuples, or dictionaries for \loss\, \metrics\, and \loss\_weights\ in \model.compile()\. The system now automatically resolves output names for metrics and losses, handles sample weighting through \CompileMetrics\, and provides more granular control over the training flow via \EpochIterator\'s separation of data adaptation and epoch enumeration.

keras/src/trainers · high confidence

Normalization layers are rewritten with improved stability and validation

The normalization layers in \keras/src/layers/normalization\ have been rewritten to improve numerical stability, input validation, and API consistency. \BatchNormalization\ now supports Batch Renormalization via the \renorm\ argument and validates the \momentum\ parameter. \GroupNormalization\ enforces positive \epsilon\ and validates group constraints, while also upcasting to float32 internally to prevent overflow in mixed precision. \LayerNormalization\ now raises clear \ValueError\ messages for out-of-bounds or duplicate axes, sorts axes for consistent behavior, and deprecates the \rms\_scaling\ argument in favor of the new \RMSNormalization\ layer. \RMSNormalization\ is a new layer that normalizes inputs based on their root mean square. \SpectralNormalization\ has been updated to use \ops.stop\_gradient\ for stable weight normalization during GAN training.

keras/src/layers/normalization · high confidence

Refactored regularizer module with improved serialization and validation

The regularizer module has been restructured to provide a cleaner public API and more robust behavior. The \\_\init\\_.py\ file now explicitly exports \serialize\, \deserialize\, and \get\ functions, allowing users to programmatically retrieve regularizer instances by string identifier (e.g., 'l1', 'l2', 'l1\_l2') or dictionary config. The \L1L2\ regularizer now correctly handles \None\ values for its coefficients, defaulting them to 0.0 to prevent errors when only one penalty type is specified. Additionally, the \OrthogonalRegularizer\ now validates its \mode\ argument (accepting only 'rows' or 'columns') and ensures input tensors have the required rank 2, raising clear errors for invalid configurations.

keras/src/regularizers · high confidence

Restructure int4 quantization into geometry-specific strategy handlers

The int4 quantization mode is now organized as a package with a central \Int4Strategy\ that dispatches to geometry-specific handlers for \Dense\/\EinsumDense\ (projection) and \Embedding\/\ReversibleEmbedding\ (lookup). This structure introduces explicit support for grouped (sub-channel) quantization via a \block\_size\ configuration, enabling asymmetric quantization with zero points and group indices for both projection kernels and embedding tables, while maintaining per-channel quantization as the default for legacy compatibility.

keras/src/quantizers/modes/int4 · high confidence

Test coverage

Added integration tests for Keras dataset loaders; Added test infrastructure and utilities for Keras; Added tests for backend compute\_output\_spec and device scope handling; New integration test suite for Keras 3.

Dependencies

Introduce multi-backend dependency structure and Python 3.11+ requirement

The project now requires Python 3.11 or higher and replaces the previous single requirements file with a structured set of dependency manifests. A new pyproject.toml defines core dependencies (absl-py, numpy, rich, namex, h5py, optree, ml-dtypes, packaging) and configures Ruff for linting. Common requirements are centralized in requirements-common.txt, while backend-specific environments are managed via requirements-jax-cuda.txt, requirements-jax-tpu.txt, requirements-tensorflow-cuda.txt, requirements-tensorflow-tpu.txt, and requirements-torch-cuda.txt. These files explicitly pin TensorFlow versions (2.20.0 for CUDA, 2.19.1 for TPU) and include necessary testing and conversion tools like ai-edge-litert, litert-torch, and jax2onnx.

(dependencies) · high confidence

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Baseline

  • First survey — no prior run to compare against. CAI 58.

Lenses

  • Code Health 67
  • Architecture 91
  • Maturity 50
  • Readiness 52
  • Security 83
  • Domain Modelling 100

Changes since last survey

  • 300 commits — 199 feature/other, 101 fixes

By area

  • keras/src — 255 commits
  • .github/workflows — 28 commits
  • (root) — 4 commits
  • .gemini/styleguide.md — 3 commits
  • .github/PULL_REQUEST_TEMPLATE.md — 3 commits
  • .github/CODEOWNERS — 2 commits
  • .github/dependabot.yml — 2 commits
  • guides/custom_train_step_in_jax.py — 1 commit
  • integration_tests/dataset_tests — 1 commit
  • keras/api — 1 commit

Notable commits

  • fix: # Fix uncaught StopIteration during validation on empty datasets in JAX trainer (#23690)
  • fix: Add top-level permissions to stale workflow and fix zizmor ignores (#23844)
  • fix: Fix in TF backend and for NumPy inputs (#23728)
  • fix: Fix #23133: erfinv returns Inf for largest float32 value below 1.0 (#23207)
  • fix: Fix AttributeError in in_top_k for list/tuple inputs with rank > 2 (#23465)
  • fix: Fix BatchNorm.compute_output_spec crash when offset is provided and scale is None (#23739)
  • fix: Fix CategoricalCrossentropy.compute_output_spec to respect axis argument (#23737)
  • fix: Fix ConvTranspose.call argument order by passing keywords (#23838)
  • fix: Fix Functional dict inputs with extra keys (#23261)
  • fix: Fix GPTQ Hessian test that fails on all backends (#23534)
  • fix: Fix GPTQ/AWQ calibration: dead hooks, zero-point range, group cache, and sequential Hessians (#23512)
  • fix: Fix GPTQ/AWQ policy names corrupting to _from_None (#23763)
  • fix: Fix GPTQ/AWQ quantization of layers outside the quantization structure (#23321)
  • fix: Fix Huber, CosineSimilarity and SparseCategoricalCrossentropy losing delta/axis on serialization (#23286)
  • fix: Fix IoU.result when axis is not the last dimension (#23668)
  • fix: Fix Logsumexp symbolic output dtype inference (#23307)
  • fix: Fix MultiHot.compute_output_spec to use self.dtype instead of inputs.dtype (#23738)
  • fix: Fix MultiProcessInitializeTest causing TorchInductor compilation failures (#23389)
  • fix: Fix NumPy normalization for axis=0 in the keras.utils.normalize (#23328)
  • fix: Fix NumPy normalize shape for 1D inputs (#23428)
  • …and 280 more

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

keras-team/keras was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 11 October 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit 2a1edb2faabc3c8259a77b85be2f14b57d5ef159 — the exact code this score is about.
  • Scored under rubric-2026.10.5 — the same rubric and the same method as every other entry in this index.
  • Measured by watchdog.canine.dev using codehealth-analyzer preprod-fe8540b5da9b.