All problems
Attention Row Sums
Problem
Return the sum of each row of an attention weight matrix as a list, in order.
An empty matrix yields an empty list.
Hint
After a valid softmax each row sums to 1.0.
Test cases
case 1
in: [[[0.5,0.5],[0.2,0.8]]]
expected: [1,1]
case 2
in: [[[1]]]
expected: [1]
case 3
in: [[]]
expected: []
case 4
in: [[[],[]]]
expected: [0,0]
Starter codePython
def attention_row_sums(weights):
# Your code here
pass4 test cases · run your code against them in the editor