All problems
Weighted Average Word Embeddings
Problem
Weighted pooling computes sum_i w_i v_i / sum_i w_i.
Given the word vectors and their weights, return the weighted mean vector.
Hint
Weights need not sum to one; normalize explicitly.
Test cases
case 1
in: [[[1,0],[0,1]],[3,1]]
expected: [0.75,0.25]
case 2
in: [[[2,2]],[1]]
expected: [2,2]
case 3
in: [[[1,1],[3,3]],[1,3]]
expected: [2.5,2.5]
Starter codePython
def weighted_average_word_embeddings(vectors, weights):
# Your code here
pass3 test cases · run your code against them in the editor