(self, input_seq, input_lengths, hidden=None)
| 661 | dropout=(0 if n_layers == 1 else dropout), bidirectional=True) |
| 662 | |
| 663 | def forward(self, input_seq, input_lengths, hidden=None): |
| 664 | # Convert word indexes to embeddings |
| 665 | embedded = self.embedding(input_seq) |
| 666 | # Pack padded batch of sequences for RNN module |
| 667 | packed = nn.utils.rnn.pack_padded_sequence(embedded, input_lengths) |
| 668 | # Forward pass through GRU |
| 669 | outputs, hidden = self.gru(packed, hidden) |
| 670 | # Unpack padding |
| 671 | outputs, _ = nn.utils.rnn.pad_packed_sequence(outputs) |
| 672 | # Sum bidirectional GRU outputs |
| 673 | outputs = outputs[:, :, :self.hidden_size] + outputs[:, : ,self.hidden_size:] |
| 674 | # Return output and final hidden state |
| 675 | return outputs, hidden |
| 676 | |
| 677 | |
| 678 | ###################################################################### |
nothing calls this directly
no outgoing calls
no test coverage detected