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

Function tensorFromSentence

intermediate_source/seq2seq_translation_tutorial.py:552–555  ·  view source on GitHub ↗
(lang, sentence)

Source from the content-addressed store, hash-verified

550 return [lang.word2index[word] for word in sentence.split(' ')]
551
552def tensorFromSentence(lang, sentence):
553 indexes = indexesFromSentence(lang, sentence)
554 indexes.append(EOS_token)
555 return torch.tensor(indexes, dtype=torch.long, device=device).view(1, -1)
556
557def tensorsFromPair(pair):
558 input_tensor = tensorFromSentence(input_lang, pair[0])

Callers 2

tensorsFromPairFunction · 0.85
evaluateFunction · 0.85

Calls 1

indexesFromSentenceFunction · 0.70

Tested by

no test coverage detected