You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2017/12/05 16:49:41 UTC
[GitHub] fedorzh opened a new issue #8955: Can't pickle MXNet Modules
fedorzh opened a new issue #8955: Can't pickle MXNet Modules
URL: https://github.com/apache/incubator-mxnet/issues/8955
## Description
Can't pickle mxnet Modules
## Environment info (Required)
```
print pickle.__version__
print mx.__version__
$Revision: 72223 $
0.12.0
```
## Error Message:
```
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-36-024323561f98> in <module>()
1 import pickle
----> 2 pickle.dumps(mlp_model)
/home/ubuntu/anaconda2/lib/python2.7/pickle.pyc in dumps(obj, protocol)
1378 def dumps(obj, protocol=None):
1379 file = StringIO()
-> 1380 Pickler(file, protocol).dump(obj)
1381 return file.getvalue()
1382
/home/ubuntu/anaconda2/lib/python2.7/pickle.pyc in dump(self, obj)
222 if self.proto >= 2:
223 self.write(PROTO + chr(self.proto))
--> 224 self.save(obj)
225 self.write(STOP)
226
/home/ubuntu/anaconda2/lib/python2.7/pickle.pyc in save(self, obj)
329
330 # Save the reduce() output and finally memoize the object
--> 331 self.save_reduce(obj=obj, *rv)
332
333 def persistent_id(self, obj):
/home/ubuntu/anaconda2/lib/python2.7/pickle.pyc in save_reduce(self, func, args, state, listitems, dictitems, obj)
423
424 if state is not None:
--> 425 save(state)
426 write(BUILD)
427
/home/ubuntu/anaconda2/lib/python2.7/pickle.pyc in save(self, obj)
284 f = self.dispatch.get(t)
285 if f:
--> 286 f(self, obj) # Call unbound method with explicit self
287 return
288
/home/ubuntu/anaconda2/lib/python2.7/pickle.pyc in save_dict(self, obj)
653
654 self.memoize(obj)
--> 655 self._batch_setitems(obj.iteritems())
656
657 dispatch[DictionaryType] = save_dict
/home/ubuntu/anaconda2/lib/python2.7/pickle.pyc in _batch_setitems(self, items)
667 for k, v in items:
668 save(k)
--> 669 save(v)
670 write(SETITEM)
671 return
/home/ubuntu/anaconda2/lib/python2.7/pickle.pyc in save(self, obj)
304 reduce = getattr(obj, "__reduce_ex__", None)
305 if reduce:
--> 306 rv = reduce(self.proto)
307 else:
308 reduce = getattr(obj, "__reduce__", None)
/home/ubuntu/anaconda2/lib/python2.7/copy_reg.pyc in _reduce_ex(self, proto)
68 else:
69 if base is self.__class__:
---> 70 raise TypeError, "can't pickle %s objects" % base.__name__
71 state = base(self)
72 args = (self.__class__, base, state)
TypeError: can't pickle module objects
```
## Minimum reproducible example
(If you are using your own code, please provide a short script that reproduces the error. Otherwise, please provide link to the existing example.)
## Steps to reproduce
```
net = mx.sym.Variable('data')
net = mx.sym.flatten(net)
net = mx.sym.FullyConnected(net, num_hidden=128)
net = mx.sym.Activation(net, act_type="relu")
net = mx.sym.FullyConnected(net, num_hidden = 64)
net = mx.sym.Activation(net, act_type="relu")
net = mx.sym.FullyConnected(net, num_hidden=10)
net = mx.sym.SoftmaxOutput(net, name='softmax')
mlp_model = mx.mod.Module(symbol=net, context=mx.gpu())
import pickle
pickle.dumps(mlp_model)
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services