Skip to content

dnn: Allow LSTM layer to operate in reverse direction - #15580

Merged
opencv-pushbot merged 1 commit into
opencv:3.4from
smbz:dnn-lstm-reverse
Sep 25, 2019
Merged

opencv-pushbot merged 1 commit into
opencv:3.4from
smbz:dnn-lstm-reverse

Conversation

@smbz

@smbz smbz commented Sep 24, 2019

Copy link
Copy Markdown
Contributor

This can be used to produce a bidirectional LSTM by having two operating in parallel on the same input, but operating in different directions.

This pullrequest changes

This PR lets cv::dnn::LSTMLayer interpret a new boolean parameter in the LayerParams called "reverse". If it is true, the LSTM operates in the reverse direction to normal.

@dkurt

dkurt commented Sep 25, 2019

Copy link
Copy Markdown
Member

@smbz, thanks for contribution!

Please change the target branch to 3.4 (we will cherry pick this commit to master after that).

@dkurt dkurt self-assigned this Sep 25, 2019
@smbz
smbz changed the base branch from master to 3.4 September 25, 2019 11:49
@smbz
smbz changed the base branch from 3.4 to master September 25, 2019 11:50
@smbz
smbz changed the base branch from master to 3.4 September 25, 2019 12:25
@smbz

smbz commented Sep 25, 2019

Copy link
Copy Markdown
Contributor Author

You're welcome! Changed to 3.4 and squashed to a single commit (now that I've read the contribution guidelines properly :P )

Comment thread modules/dnn/test/test_layers.cpp Outdated
LayerParams lp;
lp.set("reverse", true);
lp.set("use_timestamp_dim", true);
lp.blobs = std::vector<cv::Mat>{ Wh, Wx, bias };

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenCV 3.4 code should be C++98 compatible.

lp.blobs.push_back(Wh);
lp.blobs.push_back(Wx);
lp.blobs.push_back(bias);

dkurt
dkurt previously approved these changes Sep 25, 2019

@dkurt dkurt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Thank you!

@dkurt
dkurt dismissed their stale review September 25, 2019 13:06

changes requested

@smbz

smbz commented Sep 25, 2019

Copy link
Copy Markdown
Contributor Author

I've just replaced the initializer lists and "auto"; I think everything else is C++98 compatible.

This is useful for bidirectional LSTMs.

@dkurt dkurt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@opencv-pushbot
opencv-pushbot merged commit b88435f into opencv:3.4 Sep 25, 2019
@alalek alalek mentioned this pull request Sep 25, 2019
@smbz
smbz deleted the dnn-lstm-reverse branch August 20, 2021 15:44
SavyaSanchi-Sharma pushed a commit to SavyaSanchi-Sharma/opencv that referenced this pull request Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants