NumPy allowed · plain Python earns 10 bonus points
Derive and compute the analytical backward gradients for a fully-connected affine layer.
Implement dense_backward(dout, x, w): given upstream gradient dout (N, D_out), input cache x (N, D_in), and weight matrix w (D_in, D_out), compute dx = dout @ w.T, dw = x.T @ dout, and db = sum(dout, axis=0). Return a dictionary {'dx': dx, 'dw': dw, 'db': db} with all numbers rounded to 4 decimal places.
dense_backward(dout: list[list[float]], x: list[list[float]], w: list[list[float]]) -> dict