Home > other >  Pytorch derivative solving
Pytorch derivative solving

Time:04-02

 import torch 
The import numpy as np

Def f (x) :
Return the torch. Mean (x)

X=torch. Tensor ([1, 4, 3, 4], requires_grad=True)

Y=f (x)
Y.b ackward ()
Print (x.g rad)
Print (torch. Mean (x))


This is the title of vector derivation, why the result is:
Tensor ([0.2500, 0.2500, 0.2500, 0.2500])
Please explain
  • Related