Skip to content

fix: correct Bi-LSTM output shape comment (n_hidden*2 not n_hidden)#90

Open
Mukller wants to merge 1 commit into
graykode:masterfrom
Mukller:fix/bilstm-attention-output-shape-comment
Open

fix: correct Bi-LSTM output shape comment (n_hidden*2 not n_hidden)#90
Mukller wants to merge 1 commit into
graykode:masterfrom
Mukller:fix/bilstm-attention-output-shape-comment

Conversation

@Mukller

@Mukller Mukller commented Jul 9, 2026

Copy link
Copy Markdown

Fix: Incorrect output shape comment in Bi-LSTM(Attention)

The comment for the LSTM output after permute(1, 0, 2) incorrectly states
[batch_size, len_seq, n_hidden] when it should be [batch_size, len_seq, n_hidden * num_directions(=2)].

A bidirectional LSTM concatenates forward and backward hidden states, so the
last dimension is n_hidden * 2, not n_hidden.

Before (wrong comment):

output = output.permute(1, 0, 2) # output : [batch_size, len_seq, n_hidden]

After (correct comment):

output = output.permute(1, 0, 2) # output : [batch_size, len_seq, n_hidden * num_directions(=2)]

This matches the existing comments on surrounding lines (e.g., attention_net's
docstring already correctly states n_hidden * num_directions(=2)).

Closes #84

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The comment in the Bi-LSTM (Attention) model has an issue.

1 participant