All problems
Attention Padding Mask Scores
Problem
Padding positions receive a large negative score so their softmax weight vanishes. Use -1e9 for masked entries.
Given the scores and a 1/0 keep mask, return the masked scores.
Hint
Keep scores where the mask is one.
Test cases
case 1
in: [[1,2,3],[1,0,1]]
expected: [1,-1000000000,3]
case 2
in: [[0.5,0.5],[0,0]]
expected: [-1000000000,-1000000000]
case 3
in: [[1],[1]]
expected: [1]
Starter codePython
def attention_padding_mask_scores(scores, mask):
# Your code here
pass3 test cases · run your code against them in the editor