All problems
Positional Embedding Addition
Problem
Return the element-wise sum of a token embedding and a positional embedding.
The two lists are assumed to have equal length, and zipping truncates to the shorter one.
Hint
A list comprehension over zip adds corresponding coordinates.
Test cases
case 1
in: [[1,2],[0.5,0.5]]
expected: [1.5,2.5]
case 2
in: [[0,0],[-1,1]]
expected: [-1,1]
case 3
in: [[1],[2]]
expected: [3]
case 4
in: [[],[]]
expected: []
Starter codePython
def positional_embedding_add(token_emb, pos_emb):
# Your code here
pass4 test cases · run your code against them in the editor