Autograd does this for you. Interviewers ask you to do it by hand because knowing which axis to sum over is the difference between understanding backprop and having read about it.
Implement linear_backward(x, w, b, grad_out) for the layer y = x @ w + b:
x has shape (batch, in_features)w has shape (in_features, out_features)b has shape (out_features,)grad_out has shape (batch, out_features): the gradient of the loss with respect to yYou have read the opening. The rest is free with a Bezen account, and no card is needed.
Behind the sign-in