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

Function prepare_sequence

beginner_source/nlp/advanced_tutorial.py:136–138  ·  view source on GitHub ↗
(seq, to_ix)

Source from the content-addressed store, hash-verified

134
135
136def prepare_sequence(seq, to_ix):
137 idxs = [to_ix[w] for w in seq]
138 return torch.tensor(idxs, dtype=torch.long)
139
140
141# Compute log sum exp in a numerically stable way for the forward algorithm

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected