Compute scaled dot-product attention softmax(QK⊤/d)V with an optional boolean mask (same shape as the score matrix): positions where the mask is False are blocked, so they get (almost) zero attention weight.
Implement solve(Q,K,V,mask=None).
Returns. Return an array with one output row per query row. Rows of Q are queries (length d), rows of K are keys, rows of V are values.
Example 1
Input:
solve([[1.0, 0.0]], [[1.0, 0.0], [0.0, 1.0]], [[1.0, 2.0], [3.0, 4.0]], None)
Output:
[[1.660477, 2.660477]]
Example 2
Input:
solve([[1.0, 0.0]], [[1.0, 0.0], [0.0, 1.0]], [[1.0, 2.0], [3.0, 4.0]], [[True, False]])
Output:
[[1.0, 2.0]]
No results yet
Run your code to check it against the examples, or submit to run every test.