Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/pytorch/tutorials
/ prepare_sequence
Function
prepare_sequence
beginner_source/nlp/sequence_models_tutorial.py:126–128 ·
view source on GitHub ↗
(seq, to_ix)
Source
from the content-addressed store, hash-verified
124
# Prepare data:
125
126
def
prepare_sequence(seq, to_ix):
127
idxs = [to_ix[w]
for
w in seq]
128
return
torch.tensor(idxs, dtype=torch.long)
129
130
131
training_data = [
Callers
1
sequence_models_tutorial.py
File · 0.70
Calls
no outgoing calls
Tested by
no test coverage detected