Join Our 5-Week ML/AI Engineer Interview Bootcamp 🚀 led by ML Tech Leads at FAANGs
Backpropagation through a linear (fully-connected) layer is a core deep learning building block, and you’ll implement its backward pass from scratch. Given an upstream gradient, compute gradients for the weights, bias, and inputs using the chain rule: .
Implement the function
Rules:
Output:
| Argument | Type |
|---|---|
| W | np.ndarray |
| X | np.ndarray |
| b | np.ndarray |
| dY | np.ndarray |
| Return Name | Type |
|---|---|
| value | tuple |
Return NumPy arrays
Use only NumPy; no autograd libraries
Single function; no helper modules
Use the given identities directly: dX = dY @ W.T and dW = X.T @ dY. Check shapes to avoid transpose mistakes.
For the bias gradient, remember bias is broadcast across the batch: db is the sum of dY over the batch dimension (axis=0).