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

empty shapes returned in RNN example #3477

Closed
nicklhy opened this issue Oct 8, 2016 · 1 comment
Closed

empty shapes returned in RNN example #3477

nicklhy opened this issue Oct 8, 2016 · 1 comment

Comments

@nicklhy
Copy link
Contributor

nicklhy commented Oct 8, 2016

Following the code in example/rnn/rnn_cell_demo.py, I create a RNN symbol like this:

data = mx.sym.Variable('data')
rnn_h_init = mx.sym.SwapAxis(mx.sym.Variable('LSTM_init_h'), dim1=0, dim2=1)
rnn_c_init = mx.sym.SwapAxis(mx.sym.Variable('LSTM_init_c'), dim1=0, dim2=1)
rnn = mx.sym.RNN(data=data, num_layers=5, state_size=512, mode='lstm', state=rnn_h_init, state_cell=rnn_c_init)
print rnn.list_arguments()
# ['data', 'rnn0_parameters', 'LSTM_init_h', 'LSTM_init_c']
print rnn.infer_shape(data=(15, 10, 1024))[0]
# [(15L, 10L, 1024L), (11554816L,), (), ()]

The returned shape of rnn_h_init and rnn_c_init are both empty tuple "()" and produce an error when initializing the parameters in FeedForward model.
If I change the code to

rnn_h_init = mx.sym.Variable('LSTM_init_h')
rnn_c_init = mx.sym.Variable('LSTM_init_c')
# [(15L, 10L, 1024L), (11554816L,), (5L, 10L, 512L), (5L, 10L, 512L)]

the returned shapes seem to be right now. But according to the instructions in rnn_cell_demo.py, both c and h are time major rather than batch major.
I am not familiar with RNN symbol in mxnet, can anyone provide some help about this? Should I define h and c without using SwapAxis?

@yajiedesign
Copy link
Contributor

This issue is closed due to lack of activity in the last 90 days. Feel free to reopen if this is still an active issue. Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants