Sorry, it was not clear.
W1 and W2 are both weights of the neural network but at two distinct moment.
L is the loss function
grad(W, x) is the gradient of x w.r.t. W
net(W, x) is the output of the neural network for x as input when the network is in state W.
I want to compute grad(W1, L(net(W2,x))) where x corresponds to training data.