We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cffd379 commit 97da3c3Copy full SHA for 97da3c3
beginner_source/nlp/advanced_tutorial.py
@@ -124,7 +124,6 @@
124
import torch.autograd as autograd
125
import torch.nn as nn
126
import torch.optim as optim
127
-from sequence_models_tutorial import prepare_sequence
128
129
torch.manual_seed(1)
130
@@ -141,6 +140,13 @@ def argmax(vec):
141
140
_, idx = torch.max(vec, 1)
142
return to_scalar(idx)
143
+
144
+def prepare_sequence(seq, to_ix):
145
+ idxs = [to_ix[w] for w in seq]
146
+ tensor = torch.LongTensor(idxs)
147
+ return autograd.Variable(tensor)
148
149
150
# Compute log sum exp in a numerically stable way for the forward algorithm
151
152
0 commit comments