Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.

Commit a003132

Browse files
frankfliuszha
authored andcommitted
fix lstm layer with projection save params (#17266) (#17288)
Co-authored-by: Sheng Zha <szha@users.noreply.github.com>
1 parent ad1ff3a commit a003132

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

python/mxnet/gluon/rnn/rnn_layer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def __repr__(self):
126126
def _collect_params_with_prefix(self, prefix=''):
127127
if prefix:
128128
prefix += '.'
129-
pattern = re.compile(r'(l|r)(\d)_(i2h|h2h)_(weight|bias)\Z')
129+
pattern = re.compile(r'(l|r)(\d)_(i2h|h2h|h2r)_(weight|bias)\Z')
130130
def convert_key(m, bidirectional): # for compatibility with old parameter format
131131
d, l, g, t = [m.group(i) for i in range(1, 5)]
132132
if bidirectional:

tests/python/gpu/test_gluon_gpu.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ def test_lstmp():
126126
check_rnn_layer_forward(gluon.rnn.LSTM(10, 2, bidirectional=True, dropout=0.5, projection_size=5),
127127
mx.nd.ones((8, 3, 20)),
128128
[mx.nd.ones((4, 3, 5)), mx.nd.ones((4, 3, 10))], run_only=True, ctx=ctx)
129+
lstm_layer.save_parameters('gpu_tmp.params')
130+
lstm_layer.load_parameters('gpu_tmp.params')
129131

130132

131133
@with_seed()

0 commit comments

Comments
 (0)