Keras

Latest version: v3.9.0

Safety actively analyzes 715081 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 1 of 13

3.9.0

New features

- Add new Keras rematerialization API: `keras.RematScope` and `keras.remat`. It can be used to turn on rematerizaliation for certain layers in fine-grained manner, e.g. only for layers larger than a certain size, or for a specific set of layers, or only for activations.
- Increase op coverage for OpenVINO backend.
- New operations:
- `keras.ops.rot90`
- `keras.ops.rearrange` (Einops-style)
- `keras.ops.signbit`
- `keras.ops.polar`
- `keras.ops.image.perspective_transform`
- `keras.ops.image.gaussian_blur`
- New layers:
- `keras.layers.RMSNormalization`
- `keras.layers.AugMix`
- `keras.layers.CutMix`
- `keras.layers.RandomInvert`
- `keras.layers.RandomErasing`
- `keras.layers.RandomGaussianBlur`
- `keras.layers.RandomPerspective`
- Minor additions:
- Add support for `dtype` argument to `JaxLayer` and `FlaxLayer` layers
- Add boolean input support to `BinaryAccuracy` metric
- Add `antialias` argument to `keras.layers.Resizing` layer.
- Security fix: disallow object pickling in saved `npz` model files (numpy format). Thanks to [Peng Zhou](https://github.com/zpbrent) for reporting the vulnerability.


New Contributors

* harshaljanjani made their first contribution in https://github.com/keras-team/keras/pull/20745
* doncarlos999 made their first contribution in https://github.com/keras-team/keras/pull/20641
* sonali-kumari1 made their first contribution in https://github.com/keras-team/keras/pull/20775
* jurca made their first contribution in https://github.com/keras-team/keras/pull/20810
* zskendall made their first contribution in https://github.com/keras-team/keras/pull/20805
* apehex made their first contribution in https://github.com/keras-team/keras/pull/20803
* nikolasavic3 made their first contribution in https://github.com/keras-team/keras/pull/20896
* ibraaaa made their first contribution in https://github.com/keras-team/keras/pull/20926
* AsVoider made their first contribution in https://github.com/keras-team/keras/pull/20921
* abheesht17 made their first contribution in https://github.com/keras-team/keras/pull/20932
* Mohamed-Ashraf273 made their first contribution in https://github.com/keras-team/keras/pull/20934
* kuanxian1 made their first contribution in https://github.com/keras-team/keras/pull/20951
* praveenhosdrug123 made their first contribution in https://github.com/keras-team/keras/pull/20916

**Full Changelog**: https://github.com/keras-team/keras/compare/v3.8.0...v3.9.0

3.8.0

Not secure
New: OpenVINO backend

OpenVINO is now available as an infererence-only Keras backend. You can start using it by setting the `backend` field to `"openvino"` in your `keras.json` config file.

OpenVINO is a deep learning inference-only framework tailored for CPU (x86, ARM), certain GPUs (OpenCL capable, integrated and discrete) and certain AI accelerators (Intel NPU).

Because OpenVINO does not support gradients, you cannot use it for training (e.g. `model.fit()`) -- only inference. You can train your models with the JAX/TensorFlow/PyTorch backends, and when trained, reload them with the OpenVINO backend for inference on a target device supported by OpenVINO.

New: ONNX model export

You can now export your Keras models to the ONNX format from the JAX, TensorFlow, and PyTorch backends.

Just pass `format="onnx"` in your `model.export()` call:

python
Export the model as a ONNX artifact
model.export("path/to/location", format="onnx")

Load the artifact in a different process/environment
ort_session = onnxruntime.InferenceSession("path/to/location")

Run inference
ort_inputs = {
k.name: v for k, v in zip(ort_session.get_inputs(), input_data)
}
predictions = ort_session.run(None, ort_inputs)


New: Scikit-Learn API compatibility interface

It's now possible to easily integrate Keras models into Sciki-Learn pipelines! The following wrapper classes are available:

- `keras.wrappers.SKLearnClassifier`: implements the sklearn `Classifier` API
- `keras.wrappers.SKLearnRegressor`: implements the sklearn `Regressor` API
- `keras.wrappers.SKLearnTransformer`: implements the sklearn `Transformer` API


Other feature additions

- Add new ops:
- Add `keras.ops.diagflat`
- Add `keras.ops.unravel_index`
- Add new activations:
- Add `sparse_plus` activation
- Add `sparsemax` activation
- Add new image augmentation and preprocessing layers:
- Add `keras.layers.RandAugment`
- Add `keras.layers.Equalization`
- Add `keras.layers.MixUp`
- Add `keras.layers.RandomHue`
- Add `keras.layers.RandomGrayscale`
- Add `keras.layers.RandomSaturation`
- Add `keras.layers.RandomColorJitter`
- Add `keras.layers.RandomColorDegeneration`
- Add `keras.layers.RandomSharpness`
- Add `keras.layers.RandomShear`
- Add argument `axis` to `tversky` loss

JAX specific changes

- Add support for JAX named scope

TensorFlow specific changes

- Make `keras.random.shuffle` XLA compilable

PyTorch specific changes

- Add support for `model.export()` and `keras.export.ExportArchive` with the PyTorch backend, supporting both the TF SavedModel format and the ONNX format.

New Contributors

* LavanyaKV1234 made their first contribution in https://github.com/keras-team/keras/pull/20553
* jakubxy08 made their first contribution in https://github.com/keras-team/keras/pull/20563
* dhantule made their first contribution in https://github.com/keras-team/keras/pull/20565
* roebel made their first contribution in https://github.com/keras-team/keras/pull/20575
* Surya2k1 made their first contribution in https://github.com/keras-team/keras/pull/20613
* edge7 made their first contribution in https://github.com/keras-team/keras/pull/20584
* adrinjalali made their first contribution in https://github.com/keras-team/keras/pull/20599
* mmicu made their first contribution in https://github.com/keras-team/keras/pull/20655
* rkazants made their first contribution in https://github.com/keras-team/keras/pull/19727
* lkk7 made their first contribution in https://github.com/keras-team/keras/pull/20682
* Furkan-rgb made their first contribution in https://github.com/keras-team/keras/pull/20684
* punkeel made their first contribution in https://github.com/keras-team/keras/pull/20694
* kas2020-commits made their first contribution in https://github.com/keras-team/keras/pull/20709

**Full Changelog**: https://github.com/keras-team/keras/compare/v3.7.0...v3.8.0

3.7.0

Not secure
API changes

- Add `flash_attention` argument to `keras.ops.dot_product_attention` and to `keras.layers.MultiHeadAttention`.
- Add `keras.layers.STFTSpectrogram` layer (to extract STFT spectrograms from inputs as a preprocessing step) as well as its initializer `keras.initializers.STFTInitializer`.
- Add `celu`, `glu`, `log_sigmoid`, `hard_tanh`, `hard_shrink`, `squareplus` activations.
- Add `keras.losses.Circle` loss.
- Add image visualization utilities `keras.visualization.draw_bounding_boxes`, `keras.visualization.draw_segmentation_masks`, `keras.visualization.plot_image_gallery`, `keras.visualization.plot_segmentation_mask_gallery`.
- Add `double_checkpoint` argument to `BackupAndRestore` to save a fallback checkpoint in case the first checkpoint gets corrupted.
- Add bounding box preprocessing support to image augmentation layers `CenterCrop`, `RandomFlip`, `RandomZoom`, `RandomTranslation`, `RandomCrop`.
- Add `keras.ops.exp2`, `keras.ops.inner` operations.

Performance improvements

- JAX backend: add native Flash Attention support for GPU (via cuDNN) and TPU (via a Pallas kernel). Flash Attention is now used automatically when the hardware supports it.
- PyTorch backend: add native Flash Attention support for GPU (via cuDNN). It is currently opt-in.
- TensorFlow backend: enable more kernel fusion via `bias_add`.
- PyTorch backend: add support for Intel XPU devices.

New Contributors

* mostafa-mahmoud made their first contribution in https://github.com/keras-team/keras/pull/20313
* TrAyZeN made their first contribution in https://github.com/keras-team/keras/pull/20321
* dryglicki made their first contribution in https://github.com/keras-team/keras/pull/20353
* jm-willy made their first contribution in https://github.com/keras-team/keras/pull/20352
* Gopi-Uppari made their first contribution in https://github.com/keras-team/keras/pull/20377
* nicolaspi made their first contribution in https://github.com/keras-team/keras/pull/20383
* sineeli made their first contribution in https://github.com/keras-team/keras/pull/20368
* LakshmiKalaKadali made their first contribution in https://github.com/keras-team/keras/pull/20403
* mwtoews made their first contribution in https://github.com/keras-team/keras/pull/20427
* mrry made their first contribution in https://github.com/keras-team/keras/pull/20438
* rohithpudari made their first contribution in https://github.com/keras-team/keras/pull/20447
* ma7555 made their first contribution in https://github.com/keras-team/keras/pull/20452
* jakevdp made their first contribution in https://github.com/keras-team/keras/pull/20469
* lcs-crr made their first contribution in https://github.com/keras-team/keras/pull/20503
* rameshdange5191 made their first contribution in https://github.com/keras-team/keras/pull/20525

**Full Changelog**: https://github.com/keras-team/keras/compare/v3.6.0...v3.7.0

3.6.0

Not secure
Highlights

* New file editor utility: `keras.saving.KerasFileEditor`. Use it to inspect, diff, modify and resave Keras weights files. [See basic workflow here](https://colab.research.google.com/drive/1b1Rxf8xbOkMyvjpdJDrGzSnisyXatJsW?usp=sharing).
* New `keras.utils.Config` class for managing experiment config parameters.

BREAKING changes

* When using `keras.utils.get_file`, with `extract=True` or `untar=True`, the return value will be the path of the extracted directory, rather than the path of the archive.

Other changes and additions

* Logging is now asynchronous in `fit()`, `evaluate()`, `predict()`. This enables 100% compact stacking of `train_step` calls on accelerators (e.g. when running small models on TPU).
- If you are using custom callbacks that rely on `on_batch_end`, this will disable async logging. You can force it back by adding `self.async_safe = True` to your callbacks. Note that the `TensorBoard` callback isn't considered async safe by default. Default callbacks like the progress bar are async safe.
* Added `keras.saving.KerasFileEditor` utility to inspect, diff, modify and resave Keras weights file.
* Added `keras.utils.Config` class. It behaves like a dictionary, with a few nice features:
- All entries are accessible and settable as attributes, in addition to dict-style (e.g. `config.foo = 2` or `config["foo"]` are both valid)
- You can easily serialize it to JSON via `config.to_json()`.
- You can easily freeze it, preventing future changes, via `config.freeze()`.
* Added bitwise numpy ops:
* `bitwise_and`
* `bitwise_invert`
* `bitwise_left_shift`
* `bitwise_not`
* `bitwise_or`
* `bitwise_right_shift`
* `bitwise_xor`
* Added math op `keras.ops.logdet`.
* Added numpy op `keras.ops.trunc`.
* Added `keras.ops.dot_product_attention`.
* Added `keras.ops.histogram`.
* Allow infinite `PyDataset` instances to use multithreading.
* Added argument `verbose` in `keras.saving.ExportArchive.write_out()` method for exporting TF SavedModel.
* Added `epsilon` argument in `keras.ops.normalize`.
* Added `Model.get_state_tree()` method for retrieving a nested dict mapping variable paths to variable values (either as numpy arrays or backend tensors (default)). This is useful for rolling out custom JAX training loops.
* Added image augmentation/preprocessing layers `keras.layers.AutoContrast`, `keras.layers.Solarization`.
* Added `keras.layers.Pipeline` class, to apply a sequence of layers to an input. This class is useful to build a preprocessing pipeline. Compared to a `Sequential` model, `Pipeline` features a few important differences:
- It's not a `Model`, just a plain layer.
- When the layers in the pipeline are compatible with `tf.data`, the pipeline will also remain `tf.data` compatible, independently of the backend you use.


New Contributors
* alexhartl made their first contribution in https://github.com/keras-team/keras/pull/20125
* Doch88 made their first contribution in https://github.com/keras-team/keras/pull/20156
* edbosne made their first contribution in https://github.com/keras-team/keras/pull/20151
* ghsanti made their first contribution in https://github.com/keras-team/keras/pull/20185
* joehiggi1758 made their first contribution in https://github.com/keras-team/keras/pull/20223
* AryazE made their first contribution in https://github.com/keras-team/keras/pull/20228
* sanskarmodi8 made their first contribution in https://github.com/keras-team/keras/pull/20237
* himalayo made their first contribution in https://github.com/keras-team/keras/pull/20262
* nate2s made their first contribution in https://github.com/keras-team/keras/pull/20305
* DavidLandup0 made their first contribution in https://github.com/keras-team/keras/pull/20316

**Full Changelog**: https://github.com/keras-team/keras/compare/v3.5.0...v3.6.0

3.5.0

Not secure
What's Changed

* Add integration with the Hugging Face Hub. You can now save models to Hugging Face Hub directly from `keras.Model.save()` and load `.keras` models directly from Hugging Face Hub with `keras.saving.load_model()`.
* Ensure compatibility with NumPy 2.0.
* Add `keras.optimizers.Lamb` optimizer.
* Improve `keras.distribution` API support for very large models.
* Add `keras.ops.associative_scan` op.
* Add `keras.ops.searchsorted` op.
* Add `keras.utils.PyDataset.on_epoch_begin()` method.
* Add `data_format` argument to `keras.layers.ZeroPadding1D` layer.
* Bug fixes and performance improvements.


**Full Changelog**: https://github.com/keras-team/keras/compare/v3.4.1...v3.5.0

3.4.1

Not secure
This is a minor bugfix release.

Page 1 of 13

© 2025 Safety CLI Cybersecurity Inc. All Rights Reserved.