What is torch.mean(w1) for?
torch.mean(input) computes the mean value of the input tensor. See the documentation here: http://pytorch.org/docs/0.3.0/torch.html?highlight=torch%20mean#torch.mean 20


Yes. backward() do the BP work automatically, thanks for the autograd mechanism of PyTorch.
For example, for the operation mean, we have:
y = mean(x) = 1/N * \sum x_i
So,dy/dx_i = 1/N, where N is the element number of  x. This is why you got 0.333… in the grad.