import torch
import numpy as np
def f(x):
return torch.mean(x)
x = torch.tensor([1.,4.,3.,4.], requires_grad=True)
y=f(x)
y.backward()
print(x.grad)
print(torch.mean(x))
這個是標題對向量求導,為什么結果是:
tensor([0.2500, 0.2500, 0.2500, 0.2500])
求解釋
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/271037.html
