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

Function make_bow_vector

beginner_source/nlp/deep_learning_tutorial.py:283–287  ·  view source on GitHub ↗
(sentence, word_to_ix)

Source from the content-addressed store, hash-verified

281
282
283def make_bow_vector(sentence, word_to_ix):
284 vec = torch.zeros(len(word_to_ix))
285 for word in sentence:
286 vec[word_to_ix[word]] += 1
287 return vec.view(1, -1)
288
289
290def make_target(label, label_to_ix):

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected