MCPcopy Create free account
hub / github.com/pytorch/tutorials / make_context_vector

Function make_context_vector

beginner_source/nlp/word_embeddings_tutorial.py:347–349  ·  view source on GitHub ↗
(context, word_to_ix)

Source from the content-addressed store, hash-verified

345
346
347def make_context_vector(context, word_to_ix):
348 idxs = [word_to_ix[w] for w in context]
349 return torch.tensor(idxs, dtype=torch.long)
350
351
352make_context_vector(data[0][0], word_to_ix) # example

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected