lmjohns3 / theanets

Neural network toolkit for Python
http://theanets.rtfd.org
MIT License
328 stars 74 forks source link

Problem saving a network with compound activations #116

Closed juliettema closed 8 years ago

juliettema commented 8 years ago

Hello, I am pretty new at theanets and I am facing an issue while trying to save a network. My code :

net = theanets.Regressor(layers=[3, (90,'sigmoid+tanh'), (10,'sigmoid+tanh'), (30,'sigmoid+tanh'), (60,'sigmoid+tanh'), 1], loss='mae')
net.train(training_data, validation_data, learning_rate=0.01)
net.save("model1")

I get the following error :
File "RdN.py", line 44, in net.save("model1") File "/home/juliette/Téléchargements/theanets/theanets/graph.py", line 621, in save pickle.dump(self, handle, -1) File "/usr/lib/python2.7/pickle.py", line 1370, in dump Pickler(file, protocol).dump(obj) File "/usr/lib/python2.7/pickle.py", line 224, in dump self.save(obj) File "/usr/lib/python2.7/pickle.py", line 331, in save self.save_reduce(obj=obj, rv) File "/usr/lib/python2.7/pickle.py", line 419, in save_reduce save(state) File "/usr/lib/python2.7/pickle.py", line 286, in save f(self, obj) # Call unbound method with explicit self File "/usr/lib/python2.7/pickle.py", line 548, in save_tuple save(element) File "/usr/lib/python2.7/pickle.py", line 286, in save f(self, obj) # Call unbound method with explicit self File "/usr/lib/python2.7/pickle.py", line 600, in save_list self._batch_appends(iter(obj)) File "/usr/lib/python2.7/pickle.py", line 633, in _batch_appends save(x) File "/usr/lib/python2.7/pickle.py", line 331, in save self.save_reduce(obj=obj, rv) File "/usr/lib/python2.7/pickle.py", line 419, in save_reduce save(state) File "/usr/lib/python2.7/pickle.py", line 286, in save f(self, obj) # Call unbound method with explicit self File "/usr/lib/python2.7/pickle.py", line 649, in save_dict self._batch_setitems(obj.iteritems()) File "/usr/lib/python2.7/pickle.py", line 681, in _batch_setitems save(v) File "/usr/lib/python2.7/pickle.py", line 286, in save f(self, obj) # Call unbound method with explicit self File "/usr/lib/python2.7/pickle.py", line 748, in save_global (obj, module, name)) pickle.PicklingError: Can't pickle <function c at 0x7fd7bf3e58c0>: it's not found as theanets.activations.c

Can anyone help me please?

lmjohns3 commented 8 years ago

Thanks for the report! I will have a look. I'm pretty sure this is a problem when trying to save a layer with multiple activation functions, e.g. 'sigmoid+tanh'.

juliettema commented 8 years ago

Hello lmjohns3, do you have any news on this issue?

Thanks

lmjohns3 commented 8 years ago

Sorry, haven't had much time for theanets development for the past month. I might be able to get to this in the next week or so.