Skip to content
This repository has been archived by the owner on Jul 10, 2021. It is now read-only.

Saving Convolution layers through pickle doesn't work #67

Closed
TyxTyxyc opened this issue Jun 4, 2015 · 1 comment
Closed

Saving Convolution layers through pickle doesn't work #67

TyxTyxyc opened this issue Jun 4, 2015 · 1 comment
Labels
Milestone

Comments

@TyxTyxyc
Copy link

TyxTyxyc commented Jun 4, 2015

Hello!
First of all: thank you for sknn!

I've started to use sknn, and encountered some problems.
First one: I wasn't able to save sknn.mlp with pickle if sknn.mlp contains convolutional layers.
Here's some code: https://github.com/TyxTyxyc/playground/blob/master/sknn_pickle_save_bug.py.
It appears with cPickle and pickle module alike.

However, saving nets without convolutional layers works. Example code here: https://github.com/TyxTyxyc/playground/blob/master/sknn_pickle_save_bug_2.py

Some output for sknn_pickle_save_bug.py:

Initializing neural network with 4 layers, 64 inputs and 10 outputs.
  - Convl: Rectifier  Output: (10, 10)   Channels: 12
  - Convl: Rectifier  Output: (8, 8)     Channels: 8
  - Dense: Rectifier  Units:  128 
  - Dense: Softmax    Units:  10  

Training on dataset of 1,437 samples with 106,338 total size.
  - Reshaping input array from (1437, 8, 8) to (1293, 8, 8, 1).
  - Train: 1,293      Valid: 144 
  - Terminating loop after 10 total iterations.
  - Early termination after 10 stable iterations.

Epoch    Validation Error    Time
---------------------------------
    1        2.301751        3.5s
    2        2.302129        0.7s
    3        2.302112        0.7s
    4        2.301825        0.7s
    5        2.301359        0.7s
    6        2.302563        0.7s
    7        2.302163        0.7s
    8        2.302140        0.7s
    9        2.301912        0.7s
   10        2.302340        0.7s

Early termination condition fired at 10 iterations.

Traceback (most recent call last):
  File "/home/tyxtyx2/work/playground/sknn_pickle_save_bug.py", line 58, in <module>
    pickle.dump(net, outfile)
  File "/usr/lib64/python2.7/copy_reg.py", line 84, in _reduce_ex
    dict = getstate()
  File "/usr/lib64/python2.7/site-packages/sknn/mlp.py", line 309, in __getstate__
    d['weights'] = self._mlp_to_array()
  File "/usr/lib64/python2.7/site-packages/sknn/mlp.py", line 317, in _mlp_to_array
    return [(l.get_weights(), l.get_biases()) for l in self.mlp.layers]
  File "/usr/lib64/python2.7/site-packages/sknn/pylearn2/models/model.py", line 254, in get_weights
    raise NotImplementedError(str(type(self)) + " does not implement "
NotImplementedError: <class 'pylearn2.models.mlp.ConvElemwise'> does not implement get_weights (perhaps by design)

Process finished with exit code 1
@alexjc
Copy link
Member

alexjc commented Jun 4, 2015

Thanks for the report! It definitely looks like a bug :-) Tagging for later...

@alexjc alexjc added the bug label Jun 4, 2015
@alexjc alexjc added this to the 0.3 milestone Jun 4, 2015
@alexjc alexjc changed the title Saving through pickle doesn't work Saving Convolution layers through pickle doesn't work Jun 4, 2015
alexjc added a commit that referenced this issue Jun 4, 2015
@alexjc alexjc closed this as completed in #69 Jun 4, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants