网页 综合 更新时间 2026-11-14 04:00:01

Getting started with Keras

自动蜘蛛 keras.io 正文约 2858 字
Getting started with Keras
Are you a machine learning engineer looking for a Keras introduction one-pager? Read our guide Introduction to Keras for engineers.
Want to learn more about Keras 3 and its capabilities? See the Keras 3 launch announcement.
Are you looking for detailed guides covering in-depth usage of different parts of the Keras API? Read our Keras developer guides.
Are you looking for tutorials showing Keras in action across a wide range of use cases? See the Keras code examples: over 150 well-explained notebooks demonstrating Keras best practices in computer vision, natural language processing, and generative AI.
You can install Keras from PyPI via:
You can check your local Keras version number via:
To use Keras 3, you will also need to install a backend framework, such as JAX, PyTorch, or MLX:
Still on Keras 2? See Using Keras 2 (legacy) in the migration guide.
KerasHub can be installed via pip:
You can export the environment variable KERAS_BACKEND or you can edit your local config file at ~/.keras/keras.json to configure your backend. Keras supports multiple pluggable backends; current options include "jax", "torch", and "tensorflow". Example:
In Colab, you can do:
Note: The backend must be configured before importing Keras, and the backend cannot be changed after the package has been imported.
If you are running on Colab or Kaggle, the GPU should already be configured, with the correct CUDA version. Installing a newer version of CUDA on Colab or Kaggle is typically not possible. Even though pip installers exist, they rely on a pre-installed NVIDIA driver and there is no way to update the driver on Colab or Kaggle.
If you want to attempt to create a "universal environment" where any backend can use the GPU, we recommend following the dependency versions used by Colab (which seeks to solve this exact problem). You can install the CUDA driver from here, then pip install backends by following their respective CUDA installation instructions: Installing JAX, Installing TensorFlow, Installing PyTorch
This setup is recommended if you are a Keras contributor and are running Keras tests. It installs all backends but only gives GPU access to one backend at a time, avoiding potentially conflicting dependency requirements between backends. You can use the following backend-specific requirements files:
These install all CUDA-enabled dependencies via pip. They expect a NVIDIA driver to be preinstalled. 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:
Keras 3 requires Python 3.11 or newer.
The following Keras + JAX versions are compatible with each other:
The following Keras + TensorFlow versions are compatible with each other:
To use Keras 2 (legacy):
The following Keras + PyTorch versions are compatible with each other:
访问原文 返回搜索 https://keras.io/getting_started/
本页为82搜索生成的网页快照,内容来自站内索引;演示数据的原文链接仅作示例。