clab / clab/dynet

Padding bidirectional LSTM/GRU/RNN encoder

Open
#1,121 2 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
C++
Stars
3.4k
Forks
701
PR merge metrics
No merged PRs in 30d

Description

Hi everyone,

let's suppose I have a bidirectional LSTM encoder which is manually batched, let's also assume that my input sentences may have different lengths and thus I need to add PAD vectors for some of them.
My FW LSTM will have some PAD vectors at the end, and my BW LSTM will have some PAD vectors at the beginning (which is not nice).
I can of course mask it to run attention over it, etc, but if I want to use the summary of the LSTMs, they will include some useless information that may decrease my accuracy and produce some noise.

In pytorch, there is this thing called pack_padded_sequence and pad_packed_sequence which exploit cuda to make it fast and to do exactly what I want to do if I'm not mistaken,(http://pytorch.org/docs/0.3.0/nn.html?highlight=pack_padded_sequence#torch.nn.utils.rnn.pack_padded_sequence and http://pytorch.org/docs/0.3.0/nn.html?highlight=pad_packed_sequence#torch.nn.utils.rnn.pad_packed_sequence)

I wonder, if we have the same thing in Dynet.

and if not, what is the best strategy to work this around?

Thanks a lot!
Miguel

Contributor guide

No contributing guide indexed for this repository

Research direction

The issue names no DyNet files, tests, or entry points. Start by checking the existing recurrent encoder and batching APIs, then compare their behavior with PyTorch's pack_padded_sequence and pad_packed_sequence references. Done should establish whether equivalent packed-sequence support exists and, if not, define an accepted strategy for variable-length bidirectional encoders.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
machine-learning
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.