Skip to content
DeepForgeby svx
All problems
EasyNLPnlp-064

CBOW Average Context Vector

Problem

Return the element-wise average of a list of context vectors.

All vectors are assumed to have the same length. Return an empty list when there are no vectors.

Hint

Average each coordinate independently across all context vectors.

Test cases

case 1
in: [[[1,2],[3,4]]]
expected: [2,3]
case 2
in: [[[1,1,1]]]
expected: [1,1,1]
case 3
in: [[]]
expected: []
case 4
in: [[[1,0],[0,1],[1,1]]]
expected: [0.6666666666666666,0.6666666666666666]
Starter codePython
def cbow_average(context_vectors):
    # Your code here
    pass

4 test cases · run your code against them in the editor