Code QuizIntermediate Word Embedding Lookup Index Bug
Spot why this embedding lookup indexes with the wrong key.
Codepython
def lookup(word, word2idx, embeddings):
idx = word2idx.get(word, 0)
return embeddings[word]
vocab = {'cat': 1, 'dog': 2}
emb = [[0, 0], [0.2, 0.9], [0.5, 0.1]]
print(lookup('cat', vocab, emb))What is the bug in this embedding lookup function?