Skip to content

(dnn) LSTM from ONNX#16817

Merged
opencv-pushbot merged 5 commits intoopencv:3.4from
dkurt:dnn_onnx_lstm
Mar 23, 2020
Merged

(dnn) LSTM from ONNX#16817
opencv-pushbot merged 5 commits intoopencv:3.4from
dkurt:dnn_onnx_lstm

Conversation

@dkurt
Copy link
Copy Markdown
Member

@dkurt dkurt commented Mar 15, 2020

Merge with extra: opencv/opencv_extra#730

related: #12533
related: #16662

  • Slice over constant values
  • ConstantFill and ConstantOfShape
  • LSTM (not bidirectional, with zeroed initial states h0 and c0)
  • Squeeze in case of no ones in dimensions is Identity
  • Gather without axis
class LSTM(nn.Module):

    def __init__(self, features, hidden, batch, num_layers=1):
        super(LSTM, self).__init__()
        self.lstm = nn.LSTM(features, hidden, num_layers)
        self.h0 = torch.zeros(num_layers, batch, hidden)
        self.c0 = torch.zeros(num_layers, batch, hidden)

    def forward(self, x):
        return self.lstm(x, (self.h0, self.c0))[0]

batch = 5
features = 4
hidden = 3
seq_len = 2

input = Variable(torch.randn(seq_len, batch, features))
lstm = LSTM(features, hidden, batch)
allow_multiple_commits=1
force_builders=Custom,Custom Win,Custom Mac
build_image:Custom=ubuntu-openvino-2020.1.0:16.04
build_image:Custom Win=openvino-2020.1.0
build_image:Custom Mac=openvino-2020.1.0

test_modules:Custom=dnn,python2,python3,java
test_modules:Custom Win=dnn,python2,python3,java
test_modules:Custom Mac=dnn,python2,python3,java

buildworker:Custom=linux-1
# disabled due high memory usage: test_opencl:Custom=ON
test_opencl:Custom=OFF
test_bigdata:Custom=1
test_filter:Custom=*

@dkurt dkurt changed the title Dnn onnx lstm (dnn) LSTM from ONNX Mar 15, 2020
@dkurt dkurt linked an issue Mar 16, 2020 that may be closed by this pull request
Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

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

Thank you!

@dkurt
Copy link
Copy Markdown
Member Author

dkurt commented Mar 23, 2020

@alalek, please do not merge. There are rebase artifacts: https://github.com/opencv/opencv/pull/16817/files#diff-944a2f910ed0152d4981909ad8d61d61R1152

update: resolved

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.

Error while loading pytorch model in opencv Feature Request: cv::dnn::readNetFromONNX does not support parsing LSTM layer

3 participants