Compute the backward pass of a dense layer Y=XW+b. Given the layer input X, the upstream gradient dY (same shape as Y) and the weights W, return the gradients with respect to the input, the weights and the bias.
Implement solve(X, dY, W).
Returns. Return a tuple (dX, dW, db) where dX = dY @ W.T, dW = X.T @ dY and db sums dY over the batch.
Example 1
Input:
solve([[1.0, 2.0]], [[1.0, -1.0]], [[1.0, 0.0], [0.0, 1.0]])
Output:
([[1.0, -1.0]], [[1.0, -1.0], [2.0, -2.0]], [1.0, -1.0])
Example 2
Input:
solve([[1.0], [2.0]], [[3.0], [4.0]], [[2.0]])
Output:
([[6.0], [8.0]], [[11.0]], [7.0])
No results yet
Run your code to check it against the examples, or submit to run every test.