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

Error when loading models with no params #15916

Closed
samskalicky opened this issue Aug 15, 2019 · 1 comment · Fixed by #15917
Closed

Error when loading models with no params #15916

samskalicky opened this issue Aug 15, 2019 · 1 comment · Fixed by #15917

Comments

@samskalicky
Copy link
Contributor

samskalicky commented Aug 15, 2019

When loading small unit test models (such as models that contain only an identity operator) there may not be any params in the params file. When this happens the "save_dict" is an empty list rather than a dict. In load_checkpoint an error is thrown when we call "*.items()" on a list when its expecting a dict.

https://github.com/apache/incubator-mxnet/blob/master/python/mxnet/model.py#L451-L454

We need to add a check before the for loop to avoid this problem

Example code

import mxnet as mx

a = mx.sym.var('data')
s = mx.sym.identity(a)

mod = mx.mod.Module(s)
mod.bind(for_training=False, data_shapes=[('data',(1,))])
mod.init_params()
mod.save_checkpoint('identity',0)

s,a,x = mx.model.load_checkpoint('identity',0)

Error Message

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/mxnet/model.py", line 452, in load_checkpoint
    for k, v in save_dict.items():
AttributeError: 'list' object has no attribute 'items'
@mxnet-label-bot
Copy link
Contributor

Hey, this is the MXNet Label Bot.
Thank you for submitting the issue! I will try and suggest some labels so that the appropriate MXNet community members can help resolve it.
Here are my recommended labels: Bug

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

Successfully merging a pull request may close this issue.

3 participants