You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2018/12/10 04:55:48 UTC
[GitHub] BeyonderXX commented on a change in pull request #13575: Fix the
bug of BidirectionalCell
BeyonderXX commented on a change in pull request #13575: Fix the bug of BidirectionalCell
URL: https://github.com/apache/incubator-mxnet/pull/13575#discussion_r240084381
##########
File path: tests/python/unittest/test_gluon_rnn.py
##########
@@ -243,6 +243,34 @@ def test_bidirectional():
assert outs == [(10, 200), (10, 200), (10, 200)]
+def test_bidirectional_unroll_valid_length():
+ # Test BidirectionalCell.
+ # In 1.3.1 version, after hybridize( ), BidirectionalCell would failed when pass valid_length to unroll( ).
+ class BiLSTM(gluon.nn.HybridBlock):
+ def __init__(self, rnn_size, time_step, **kwargs):
+ super(BiLSTM, self).__init__(**kwargs)
+ self.time_step = time_step
+ with self.name_scope():
+ self.bi_lstm = gluon.rnn.BidirectionalCell(
+ gluon.rnn.LSTMCell(rnn_size, prefix='rnn_l0_'),
+ gluon.rnn.LSTMCell(rnn_size, prefix='rnn_r0_'),
+ output_prefix='lstm_bi_')
+
+ def hybrid_forward(self, F, inputs, valid_len):
+ outputs, states = self.bi_lstm.unroll(self.time_step, inputs, valid_length=valid_len,
+ layout='TNC', merge_outputs='True')
Review comment:
Thank you so much!
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services