代码之家  ›  专栏  ›  技术社区  ›  Anonymous

MXNet中LSTMCell使用示例

  •  0
  • Anonymous  · 技术社区  · 3 年前

    根据本教程,我正在尝试使用LSTM Cell: https://mxnet.apache.org/versions/1.2.1/api/python/gluon/rnn.html

    model = mx.gluon.rnn.SequentialRNNCell()
    model.add(mx.gluon.rnn.LSTMCell(20))
    model.add(mx.gluon.rnn.LSTMCell(20))
    states = model.begin_state(batch_size=32)
    input = mx.nd.random.uniform(shape=(32, 10))
    model.initialize()
    model(input, states)
    

    我收到以下错误: ValueError: Deferred initialization failed because shape cannot be inferred. Operator FullyConnected registered in backend is known as FullyConnected in Python. This is a legacy operator which can only accept legacy ndarrays, while received an MXNet numpy ndarray. Please call as_nd_ndarray() upon the numpy ndarray to convert it to a legacy ndarray, and then feed the converted array to this operator.

    它怎么了?我使用的是MXnet“2.0.0”,找不到任何最新的教程。

    0 回复  |  直到 3 年前