keras README

The project's README from github.com/keras-team/keras. As one markdown file: README.md.

Keras 3: Deep Learning for Humans

Keras 3 is a multi-backend deep learning framework, with support for JAX, TensorFlow, PyTorch, and OpenVINO (for inference-only). Effortlessly build and train models for computer vision, natural language processing, audio processing, timeseries forecasting, recommender systems, etc.

Join nearly three million developers, from burgeoning startups to global enterprises, in harnessing the power of Keras 3.

Installation

Install with pip

Keras 3 is available on PyPI as keras. Note that Keras 2 remains available as the tf-keras package.

  1. Install keras:
pip install keras --upgrade
  1. Install backend package(s).

To use keras, you should also install the backend of choice: tensorflow, jax, or torch. Additionally, The openvino backend is available with support for model inference only.

Local installation

Minimal installation

Keras 3 is compatible with Linux and macOS systems. For Windows users, we recommend using WSL2 to run Keras. To install a local development version:

  1. Install dependencies:
pip install -r requirements.txt
  1. Run installation command from the root directory.
python pip_build.py --install
  1. Run API generation script when creating PRs that update keras_export public APIs:
./shell/api_gen.sh

Backend Compatibility Table

The following table lists the minimum supported versions of each backend for the latest stable release of Keras (v3.x):

Backend Minimum Supported Version
TensorFlow 2.16.1
JAX 0.4.20
PyTorch 2.1.0
OpenVINO 2026.2.0

Adding GPU support

The requirements.txt file will install a CPU-only version of TensorFlow, JAX, and PyTorch. For GPU support, we also provide a separate requirements-{backend}-cuda.txt for TensorFlow, JAX, and PyTorch. These install all CUDA dependencies via pip and expect a NVIDIA driver to be pre-installed. We recommend a clean Python environment for each backend to avoid CUDA version mismatches. As an example, here is how to create a JAX GPU environment with conda:

conda create -y -n keras-jax python=3.10
conda activate keras-jax
pip install -r requirements-jax-cuda.txt
python pip_build.py --install

Configuring your backend

You can export the environment variable KERAS_BACKEND or you can edit your local config file at ~/.keras/keras.json to configure your backend. Available backend options are: "tensorflow", "jax", "torch", "openvino". Example:

export KERAS_BACKEND="jax"

In Colab, you can do:

import os
os.environ["KERAS_BACKEND"] = "jax"

import keras

Note: The backend must be configured before importing keras, and the backend cannot be changed after the package has been imported.

Note: The OpenVINO backend is an inference-only backend, meaning it is designed only for running model predictions using model.predict() method.

Backwards compatibility

Keras 3 is intended to work as a drop-in replacement for tf.keras (when using the TensorFlow backend). Just take your existing tf.keras code, make sure that your calls to model.save() are using the up-to-date .keras format, and you're done.

If your tf.keras model does not include custom components, you can start running it on top of JAX or PyTorch immediately.

If it does include custom components (e.g. custom layers or a custom train_step()), it is usually possible to convert it to a backend-agnostic implementation in just a few minutes.

In addition, Keras models can consume datasets in any format, regardless of the backend you're using: you can train your models with your existing tf.data.Dataset pipelines or PyTorch DataLoaders.

Why use Keras 3?

Read more in the Keras 3 release announcement.

keras (keras-team/keras)

Searching Database…

64.4K ·GitHub
这是什么?Keras 3 是一个多后端深度学习框架,让你可以在 JAX、TensorFlow 或 PyTorch 之上构建和训练用于计算机视觉、自然语言处理、音频、时间序列和推荐系统的模型。
它是一个框架,还是只是 TensorFlow 的封装?它是一个高层框架,运行在你选择的任一后端(JAX、TensorFlow 或 PyTorch)之上,不再绑定 TensorFlow,并且可以直接替换 tf.keras 使用。
我该如何安装并选择后端?用 pip 安装 keras 包,然后安装你选定的后端(tensorflow、jax 或 torch);在导入 keras 之前,可以通过 KERAS_BACKEND 环境变量或 ~/.keras/keras.json 配置文件设置当前使用的后端。
它支持哪些后端,最低版本要求是多少?TensorFlow ≥2.16.1、JAX ≥0.4.20、PyTorch ≥2.1.0,以及仅用于推理的 OpenVINO ≥2026.2.0;使用 GPU 需要预先安装 NVIDIA 驱动,并按各后端的要求安装对应的 CUDA 依赖文件。
在 Windows 上安装有哪些需要注意的地方,或者 OpenVINO 后端有什么限制?本地安装不直接支持 Windows,README 建议使用 WSL2;另外,OpenVINO 后端只支持运行预测,不支持训练。
它是给研究人员用的,还是生产团队也能用?两者都适用:从在笔记本上做原型的独立开发者,到在 GPU/TPU 集群上扩展训练的大公司,都是它的目标用户,目前已有将近三百万开发者在使用。
为什么要选一个后端而不是另一个?你可以选择对你的模型结构最快的后端——据报告,JAX 往往速度最快,相比其他框架可提速 20% 到 350%——同时仍保持相同的 Keras 高层 API。
我现有的 tf.keras 代码还能用吗?可以。如果代码只使用标准组件,就可以原样运行;即使是自定义层或训练步骤,通常也只需几分钟的修改,就能变得与后端无关。
我能把 Keras 和原生 PyTorch 或 JAX 代码混合使用吗?可以——你可以在从零编写的原生 TF、JAX 或 PyTorch 训练循环中训练 Keras 模型,也可以把它嵌入到 PyTorch Module 或 JAX 模型函数中作为一部分使用。
Keras 2 怎么样了?Keras 2 仍然存在,但已被重命名,并以单独的 “tf-keras” 包在 PyPI 上发布。
Creator
keras-team
Size
56.3 MB
Stars
64.4K
Age
11y
Commits · 90 Days