Manually calculating the gradient

Hi, I’m going through the autograd tutorial http://pytorch.org/tutorials/beginner/blitz/autograd_tutorial.html and I’m confused about the first step in calculating the gradient. Why is o = 1/4 ∑z ?

Can someone explain this?

Thanks!

z is of size 2 X 2. So, in total has 4 elements. out = z.mean() is thus the same as (1/4) X Summation over elements of z.

1 Like

Ahhh, of course. Thanks!