1、定义变量
import torch
from torch.autograd import Variable
x = Variable(torch.ones(2,2),requires_grad=True)
其中变量x会有一个grad空间
y = x+1
print(y.grad_fn)
y会有一个grad_fn空间
2、反向传播求导
1)输出结果为一维时
z = y *
import torch
from torch.autograd import Variable
x = Variable(torch.ones(2,2),requires_grad=True)
其中变量x会有一个grad空间
y = x+1
print(y.grad_fn)
y会有一个grad_fn空间
1)输出结果为一维时
z = y *