morb icon indicating copy to clipboard operation
morb copied to clipboard

Picklable models?

Open jorgehatccrma opened this issue 12 years ago • 0 comments

First off, thanks for this awesome library! I'm new to DeepLearning and Theano, but your lib makes it so much easier.

I was wondering if there's a way to save (pickle) MORB models? I tried modifying example_basic.py by adding the following lines at the end:

import cPickle
with open('model.pkl', 'wb') as f:
    cPickle.dump(rbm, f, protocol=cPickle.HIGHEST_PROTOCOL)

but I get the following trace:

...
Epoch 49
MSE = 0.0026
Took 6.69 seconds
Traceback (most recent call last):
  File "example_basic.py", line 61, in <module>
    cPickle.dump(rbm, f, protocol=cPickle.HIGHEST_PROTOCOL)
cPickle.PicklingError: Can't pickle <type 'function'>: attribute lookup __builtin__.function failed

If I remove the protocol=cPickle.HIGHEST_PROTOCOL argument I get:

Epoch 49
MSE = 0.0026
Took 6.96 seconds
Traceback (most recent call last):
  File "example_basic.py", line 61, in <module>
    cPickle.dump(rbm, f)
  File "/<removed path for privacy>/python2.7/copy_reg.py", line 70, in _reduce_ex
    raise TypeError, "can't pickle %s objects" % base.__name__
TypeError: can't pickle function objects

Is there another way to save MORB models for later use?

Thanks, Jorge

jorgehatccrma avatar Feb 28 '13 08:02 jorgehatccrma