torch的基础学习
作者:互联网
1.能带来什么
GPU加速
自动求导
import torch from torch import autograd x = torch.tensor(1.) a = torch.tensor(1., requires_grad=True) b = torch.tensor(2., requires_grad=True) c = torch.tensor(3., requires_grad=True) y = a ** 2 * x + b * x + c print('before=', a.grad, b.grad, c.grad) # before= None None None grads = autograd.grad(y, [a, b, c]) print('after=', grads[0], grads[1], grads[2]) # after= tensor(2.) tensor(1.) tensor(1.)
大量的Api,Tensor运算,神经网络
2.手写
标签:None,tensor,True,torch,基础,学习,grad,grads 来源: https://www.cnblogs.com/juncaoit/p/16291394.html