Hi,
Setting the .grad field won’t have any effect.
If you want to backward by setting the gradient for the output’s gradient to a given value M, you can simply do: out.backward(M)
I don’t know what you expect to be doing in your example. The gradient of net.output.weight do not influence the gradients in the rest of the network (contrary to the gradients of out).