from torch.autograd import Variable
import torch
xx = Variable(torch.rand(1), requires_grad=True)
cc = 89*xx
torch.autograd.grad(cc, xx)
output
(tensor([89.]),)
参考自
deepaksharma36 Deepak Sharma的回答
from torch.autograd import Variable
import torch
xx = Variable(torch.rand(1), requires_grad=True)
cc = 89*xx
torch.autograd.grad(cc, xx)
output
(tensor([89.]),)
参考自
deepaksharma36 Deepak Sharma的回答