Content-Length: 274572 | pFad | http://github.com/graykode/nlp-tutorial/commit/90dc12a3d4ba8e04e580f1851d1d30bfbcc3b185

F6 fix bi-LSTM hidden and cell state shape comments · graykode/nlp-tutorial@90dc12a · GitHub
Skip to content

Commit 90dc12a

Browse files
fix bi-LSTM hidden and cell state shape comments
1 parent cb4881e commit 90dc12a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

3-3.Bi-LSTM/Bi-LSTM-Torch.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ def __init__(self):
4747
def forward(self, X):
4848
input = X.transpose(0, 1) # input : [n_step, batch_size, n_class]
4949

50-
hidden_state = Variable(torch.zeros(1*2, len(X), n_hidden)) # [num_layers(=1) * num_directions(=1), batch_size, n_hidden]
51-
cell_state = Variable(torch.zeros(1*2, len(X), n_hidden)) # [num_layers(=1) * num_directions(=1), batch_size, n_hidden]
50+
hidden_state = Variable(torch.zeros(1*2, len(X), n_hidden)) # [num_layers(=1) * num_directions(=2), batch_size, n_hidden]
51+
cell_state = Variable(torch.zeros(1*2, len(X), n_hidden)) # [num_layers(=1) * num_directions(=2), batch_size, n_hidden]
5252

5353
outputs, (_, _) = self.lstm(input, (hidden_state, cell_state))
5454
outputs = outputs[-1] # [batch_size, n_hidden]
@@ -75,4 +75,4 @@ def forward(self, X):
7575

7676
predict = model(input_batch).data.max(1, keepdim=True)[1]
7777
print(sentence)
78-
print([number_dict[n.item()] for n in predict.squeeze()])
78+
print([number_dict[n.item()] for n in predict.squeeze()])

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/graykode/nlp-tutorial/commit/90dc12a3d4ba8e04e580f1851d1d30bfbcc3b185

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy