-1

Using mxnet 1.1, When I try to run net(data) on the following network:

net = gluon.nn.HybridSequential()
    with net.name_scope():
        net.add(gluon.nn.Embedding(input_dim=MAX_EVENT_INDEX + 1, output_dim=EMBEDDING_VECTOR_LENGTH))
        net.add(gluon.nn.Conv1D(channels=conv1D_filters, kernel_size=conv1D_kernel_size, activation='relu'))
        net.add(gluon.nn.MaxPool1D(pool_size=max_pool_size, strides=2))
        net.add(gluon.rnn.LSTMCell(100))
        net.add(gluon.rnn.DropoutCell(dropout_rate))
        net.add(gluon.rnn.LSTMCell(100))
        net.add(gluon.rnn.DropoutCell(dropout_rate))
        net.add(gluon.rnn.LSTMCell(100))
        net.add(gluon.rnn.DropoutCell(dropout_rate))
        net.add(gluon.nn.Flatten())
        net.add(gluon.nn.Dense(1, activation="sigmoid"))
    net.hybridize()

Error: forward() missing 1 required positional argument: 'states'

Everything works when I use gluon.nn.Sequential() with net.add(gluon.rnn.LSTM(100, dropout=dropout_rate))

Thanks

ItachiUchiha
  • 36,135
  • 10
  • 122
  • 176
user3644809
  • 21
  • 1
  • 4

1 Answers1

0

If you look into implementation of LSTMCell you would notice, that hybrid_forward requires explicit states argument. LSTM class, using its base class implementation doesn't require states parameter (it can be None). So switching from one to another will definitely help you.

LSTM class is more than LSTMCell. It actually uses LSTMCell internally, but it also adds extra functionality on top of it. For example, you can specify LSTM to be multilayered or bidirectional, where LSTMCell is essentially just a bunch of LSTM-related formulas for calculating gates, c and h.

Sergei
  • 1,617
  • 15
  • 31