1. 环境准备 🛠️
- 安装 PyTorch
使用 pip 安装:pip install torch
使用 conda 安装:conda install pytorch -c pytorch
📎 查看详细安装指南
2. 核心概念入门 🧠
- 张量操作
基础数据结构,支持 GPU 加速计算 - 自动求导
使用 `torch.autograd` 实现梯度自动计算 - 神经网络构建
通过 `torch.nn` 模块搭建模型
3. 示例代码 📜
import torch
x = torch.tensor([2.0, 3.0])
y = torch.tensor([4.0, 5.0])
print(x + y) # 输出: tensor([6., 8.])