TensorFlow.js 是一个用于 Web 的 JavaScript 库,支持在浏览器或 Node.js 环境中运行机器学习模型。以下是多种安装方式:

1. 📦 使用 npm 安装

npm install @tensorflow/tfjs

npm_install

2. 🌐 通过 CDN 引入

<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs"></script>

cdn_introduction

3. 📁 从源码编译(高级)

  • 克隆仓库:git clone https://github.com/tensorflow/tfjs.git
  • 安装依赖:npm install
  • 构建项目:npm run build
    source_code

4. 📚 扩展阅读

如需深入了解 TensorFlow.js 的安装配置,请访问官方安装文档获取更多示例与说明。

📌 提示:选择适合您项目需求的安装方式,浏览器环境推荐使用 CDN 或 npm。