From 73d6fa01e2e6fecb6bc20cd7f56192e80717bb4f Mon Sep 17 00:00:00 2001 From: wehub-resource-sync Date: Mon, 13 Jul 2026 10:09:45 +0000 Subject: [PATCH] docs: make Chinese README the default --- README.md | 116 +++++++++++++++++++++++++++--------------------------- 1 file changed, 57 insertions(+), 59 deletions(-) diff --git a/README.md b/README.md index 52ecbec..c24252e 100644 --- a/README.md +++ b/README.md @@ -1,77 +1,80 @@ -# Keras 3: Deep Learning for Humans + +> [!NOTE] +> 本文档由 WeHub 基于上游 README 翻译整理,属于社区翻译,非官方中文文档。 +> [English](./README.en.md) · [原始项目](https://github.com/keras-team/keras) · [上游 README](https://github.com/keras-team/keras/blob/HEAD/README.md) +> 原作者、版权与许可证归属以原始项目及本仓库 LICENSE 文件为准。 -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. +# Keras 3:面向人类的深度学习 -- **Accelerated model development**: Ship deep learning solutions faster thanks to the high-level UX of Keras -and the availability of easy-to-debug runtimes like PyTorch or JAX eager execution. -- **State-of-the-art performance**: By picking the backend that is the fastest for your model architecture (often JAX!), -leverage speedups ranging from 20% to 350% compared to other frameworks. [Benchmark here](https://keras.io/getting_started/benchmarks/). -- **Datacenter-scale training**: Scale confidently from your laptop to large clusters of GPUs or TPUs. +Keras 3 是一个多后端深度学习框架,支持 JAX、TensorFlow、PyTorch 和 OpenVINO(仅用于推理)。 +可轻松构建并训练用于计算机视觉、自然语言处理、音频处理、 +时间序列预测、推荐系统等领域的模型。 -Join nearly three million developers, from burgeoning startups to global enterprises, in harnessing the power of Keras 3. +- **加速模型开发**:借助 Keras 的高级用户体验,以及 PyTorch 或 JAX 急切执行(eager execution)等易于调试的运行时,更快交付深度学习解决方案。 +- **业界领先的性能**:选择最适合您模型架构的后端(通常是 JAX!),相比其他框架可获得 20% 至 350% 的加速。[基准测试在这里](https://keras.io/getting_started/benchmarks/). +- **数据中心级训练**:自信地从笔记本电脑扩展到大型 GPU 或 TPU 集群。 + +与近三百万开发者一起,从新兴初创公司到全球企业,共同发挥 Keras 3 的威力。 -## Installation +## 安装 -### Install with pip +### 使用 pip 安装 -Keras 3 is available on PyPI as `keras`. Note that Keras 2 remains available as the `tf-keras` package. +Keras 3 在 PyPI 上提供为 `keras`。请注意,Keras 2 仍以 `tf-keras` 包的形式提供。 -1. Install `keras`: +1. 安装 `keras`: ``` pip install keras --upgrade ``` -2. Install backend package(s). +2. 安装后端包。 -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. +要使用 `keras`,您还需要安装所选的后端:`tensorflow`、`jax` 或 `torch`。此外, +`openvino` 后端可用,但仅支持模型推理。 -### 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: +Keras 3 兼容 Linux 和 macOS 系统。对于 Windows 用户,我们建议使用 WSL2 运行 Keras。 +要安装本地开发版本: -1. Install dependencies: +1. 安装依赖: ``` pip install -r requirements.txt ``` -2. Run installation command from the root directory. +2. 从根目录运行安装命令。 ``` python pip_build.py --install ``` -3. Run API generation script when creating PRs that update `keras_export` public APIs: +3. 在创建更新 `keras_export` 公共 API 的 PR 时,运行 API 生成脚本: ``` ./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): +下表列出了最新稳定版 Keras(v3.x)对各后端的最低支持版本: -| Backend | Minimum Supported Version | +| 后端 | 最低支持版本 | |------------|---------------------------| | TensorFlow | 2.16.1 | | JAX | 0.4.20 | | PyTorch | 2.1.0 | | OpenVINO | 2025.3.0 | -#### Adding GPU support +#### 添加 GPU 支持 -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`: +`requirements.txt` 文件将安装仅 CPU 版本的 TensorFlow、JAX 和 PyTorch。如需 GPU 支持,我们还 +为 TensorFlow、JAX 和 PyTorch 提供了单独的 `requirements-{backend}-cuda.txt`。这些会通过 `pip` 安装所有 CUDA +依赖,并期望已预装 NVIDIA 驱动。我们建议为每个后端使用干净的 Python 环境,以避免 CUDA 版本不匹配。例如,以下是如何使用 `conda` 创建 JAX GPU 环境: ```shell conda create -y -n keras-jax python=3.10 @@ -80,16 +83,16 @@ 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: +您可以导出环境变量 `KERAS_BACKEND`,或编辑本地配置文件 `~/.keras/keras.json` +来配置后端。可用的后端选项有:`"tensorflow"`、`"jax"`、`"torch"`、`"openvino"`。示例: ``` export KERAS_BACKEND="jax" ``` -In Colab, you can do: +在 Colab 中,您可以: ```python import os @@ -98,36 +101,31 @@ 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. +**注意:** 必须在导入 `keras` 之前配置后端,导入包后无法更改后端。 -**Note:** The OpenVINO backend is an inference-only backend, meaning it is designed only for running model -predictions using `model.predict()` method. +**注意:** OpenVINO 后端是仅推理后端,意味着它仅设计用于通过 `model.predict()` 方法运行模型预测。 -## 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. +Keras 3 旨在作为 `tf.keras` 的直接替代(使用 TensorFlow 后端时)。只需拿出现有的 `tf.keras` 代码,确保对 `model.save()` 的调用使用最新的 `.keras` 格式,即可完成。 -If your `tf.keras` model does not include custom components, you can start running it on top of JAX or PyTorch immediately. +如果您的 `tf.keras` 模型不包含自定义组件,您可以立即在 JAX 或 PyTorch 上运行它。 -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. +如果确实包含自定义组件(例如自定义层或自定义 `train_step()`),通常只需几分钟即可将其转换为与后端无关的实现。 -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`. +此外,无论使用哪个后端,Keras 模型都可以使用任何格式的数据集: +您可以使用现有的 `tf.data.Dataset` 流水线或 PyTorch `DataLoaders` 训练模型。 -## Why use Keras 3? +## 为何使用 Keras 3? -- Run your high-level Keras workflows on top of any framework -- benefiting at will from the advantages of each framework, -e.g. the scalability and performance of JAX or the production ecosystem options of TensorFlow. -- Write custom components (e.g. layers, models, metrics) that you can use in low-level workflows in any framework. - - You can take a Keras model and train it in a training loop written from scratch in native TF, JAX, or PyTorch. - - You can take a Keras model and use it as part of a PyTorch-native `Module` or as part of a JAX-native model function. -- Make your ML code future-proof by avoiding framework lock-in. -- As a PyTorch user: get access to power and usability of Keras, at last! -- As a JAX user: get access to a fully-featured, battle-tested, well-documented modeling and training library. +- 在任何框架之上运行高级 Keras 工作流——按需受益于各框架的优势, +例如 JAX 的可扩展性与性能,或 TensorFlow 的生产生态系统选项。 +- 编写可在任何框架的低级工作流中使用的自定义组件(例如层、模型、指标)。 + - 您可以获取 Keras 模型,并在用原生 TF、JAX 或 PyTorch 从头编写的训练循环中训练它。 + - 您可以获取 Keras 模型,将其作为 PyTorch 原生 `Module` 的一部分,或作为 JAX 原生模型函数的一部分。 +- 通过避免框架锁定,让您的 ML 代码面向未来。 +- 作为 PyTorch 用户:终于可以使用 Keras 的强大功能与易用性! +- 作为 JAX 用户:终于可以使用功能齐全、久经考验、文档完善的建模与训练库。 -Read more in the [Keras 3 release announcement](https://keras.io/keras_3/). +在 [Keras 3 发布公告](https://keras.io/keras_3/). 中了解更多