1. 首页
  2. 数据库
  3. 其它
  4. pytorch tensor

pytorch tensor

上传者: 2020-12-23 02:45:46上传 PDF文件 24.13KB 热度 25次
创建一个 Tensor 并设置 requires_grad=True : import torch x = torch.ones(2, 2, requires_grad=True) print(x) print(x.grad_fn) 输出: tensor([[1., 1.], [1., 1.]], requires_grad=True) None 再做一下运算操作: y = x + 2 print(y) print(y.grad_fn) 输出: tensor([[3., 3.], [3., 3.]], grad_fn=) 注意x是直接创建的,所以它没有
用户评论