Skip to content

Using MXNet LSTM with SageMaker #51

Closed

Description

@aodhan-domhnaill

Going off of the MNIST Example for MXNet, I need to have a function like,

def save(net, model_dir):
    # save the model
    y = net(mx.sym.var('data'))
    y.save('%s/model.json' % model_dir)
    net.collect_params().save('%s/model.params' % model_dir)

But, if I try this with an LSTM I get an error. The minimal code to reproduce the bug is,

import mxnet as mx
from mxnet import gluon

net = gluon.rnn.LSTM(100)
net(mx.sym.var('dats'))

which gives,

$ python shape_error.py 
Traceback (most recent call last):
  File "shape_error.py", line 5, in <module>
    net(mx.sym.var('dats'))
  File "/usr/local/lib/python3.6/site-packages/mxnet/gluon/block.py", line 304, in __call__
    return self.forward(*args)
  File "/usr/local/lib/python3.6/site-packages/mxnet/gluon/rnn/rnn_layer.py", line 173, in forward
    batch_size = inputs.shape[self._layout.find('N')]
AttributeError: 'Symbol' object has no attribute 'shape'

How do I solve this?

Activity

  1. owen-t commented on Jan 22, 2018

    @owen-t
    Contributor

    I'm looking into this issue and will respond here with updates.

  2. jesterhazy commented on Jan 25, 2018

    @jesterhazy
    Contributor

    @aidan-plenert-macdonald this is more of an mxnet usage issue than a SageMaker one. I've updated your mxnet issue with a suggested workaround and will close this ticket.

  3. added a commit that references this issue on May 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions