安装TensorFlow是开始使用这个强大的机器学习库的第一步。以下是在不同操作系统上安装TensorFlow的步骤。

系统要求

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

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

安装步骤

以下是在不同操作系统上安装TensorFlow的步骤:

Windows

  1. 打开命令提示符。
  2. 输入以下命令:
pip install tensorflow

macOS 和 Linux

  1. 打开终端。
  2. 输入以下命令:
pip install tensorflow

高级选项

如果您需要GPU支持,请使用以下命令:

pip install tensorflow-gpu

示例代码

安装完成后,您可以使用以下代码检查TensorFlow是否已正确安装:

import tensorflow as tf

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

如果您需要进一步了解TensorFlow,请访问我们的官方文档

相关资源

TensorFlow Logo