Skip to content

Commit 2b15cbb

Browse files
fsonntagchsasank
authored andcommitted
* Fixing pytorch#120 Fixing problem in advanced NLP tutorial * Fixed copy and paste errors, limited line length
1 parent b0cb64a commit 2b15cbb

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

beginner_source/nlp/advanced_tutorial.py

+5
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,11 @@ def __init__(self, vocab_size, tag_to_ix, embedding_dim, hidden_dim):
177177
self.transitions = nn.Parameter(
178178
torch.randn(self.tagset_size, self.tagset_size))
179179

180+
# These two statements enforce the constraint that we never transfer
181+
# to the start tag and we never transfer from the stop tag
182+
self.transitions.data[tag_to_ix[START_TAG], :] = -10000
183+
self.transitions.data[:, tag_to_ix[STOP_TAG]] = -10000
184+
180185
self.hidden = self.init_hidden()
181186

182187
def init_hidden(self):

0 commit comments

Comments
 (0)