TensorFlow 是一个开源的机器学习库,用于数据流编程。以下是 TensorFlow 的安装教程。

系统要求

在开始安装 TensorFlow 之前,请确保您的系统满足以下要求:

  • 操作系统:Linux、macOS 或 Windows
  • Python 版本:Python 3.6 或更高版本

安装步骤

  1. 安装 Python:确保您的系统中已安装 Python 3.6 或更高版本。
  2. 安装 pip:Python 的包管理器 pip 可以用于安装 TensorFlow。确保您的 pip 版本是最新的。
    python -m pip install --upgrade pip
    
  3. 安装 TensorFlow:使用以下命令安装 TensorFlow:
    pip install tensorflow
    

安装 TensorFlow GPU 版本

如果您需要使用 GPU 加速,可以安装 TensorFlow GPU 版本:

pip install tensorflow-gpu

测试安装

安装完成后,可以通过以下命令测试 TensorFlow 是否安装成功:

import tensorflow as tf

print("TensorFlow 版本:", tf.__version__)

下一步

安装 TensorFlow 后,您可以查看更多关于如何开始使用 TensorFlow 的教程。TensorFlow 官方文档提供了丰富的资源和示例。

TensorFlow Logo