Solved by albanD in post #2 
              
              
                Hi, 
This code is a bit out of context. Where did you get it from? 
So I am going to guess that you try to do the backward pass by hand for a network whole loss function is loss = ||y_pred - y||^2 with weights w1 and w2. And y_pred = w2 * h_relu and h_relu = relu(w1 * x). 
If this is true, then the …