文章目录
🎉进入深度神经网络与PyTorch进阶专栏 | 🚀查看更多专栏内容
部分参考:https://zhuanlan.zhihu.com/p/51385110
定义求导属性
所有的tensor都有.requires_grad属性,都可以设置成自动求导。具体方法就是在定义tensor的时候,让这个属性为True
import torch
# create a tensor with setting its .requires_grad as Ture
x = torch.ones(2