Growing Neural Gas can't be pickled
VioletM opened this issue · 6 comments
Hi,
When I pickle GNG model, and then load it, it can't continue training. It gives an error, connecting with edges. dill library has the same error.
~/python3.6/site-packages/neupy/algorithms/competitive/growing_neural_gas.py in train(self, input_train, summary, epochs)
299 input_test=None, target_test=None,
300 epochs=epochs, epsilon=None,
--> 301 summary=summary)
302
303 def train_epoch(self, input_train, target_train=None):
~/python3.6/site-packages/neupy/algorithms/base.py in train(self, input_train, target_train, input_test, target_test, epochs, epsilon, summary)
407
408 try:
--> 409 train_error = train_epoch(input_train, target_train)
410
411 if can_compute_validation_error:
~/python3.6/site-packages/neupy/algorithms/competitive/growing_neural_gas.py in train_epoch(self, input_train, target_train)
346 for to_neuron in list(graph.edges_per_node[closest_neuron]):
347 edge_id = make_edge_id(to_neuron, closest_neuron)
--> 348 age = graph.edges[edge_id]
349
350 if age >= max_edge_age:
KeyError: (<neupy.algorithms.competitive.growing_neural_gas.NeuronNode object at 0x7f2d9ecff780>, <neupy.algorithms.competitive.growing_neural_gas.NeuronNode object at 0x7f2d9ecff7f0>)
Hi, Thank you for reporting this issue. There is a flaw in the logic that needs to be fixed. I can make a separate release with a fix. I will let yo know when fix will be ready.
I added fix into the release/v0.7.3
branch, See PR #230
I will appreciate if you can test that it works for you. I added separate case for the pickle storage: https://github.com/itdxer/neupy/pull/230/files#diff-b10ea35f973f702cfca0ff6e3824230fR100
Tomorrow, I'll make small release and new version will include this fix. Thank you again for reporting this bug.
I've made separate release that include this fix, namely version 0.7.3 . Let me know if you have some other problems.
I close this issue since I've mange to reproduce it locally, fix it and added separate unit test for this problem. Feel free to reopen this issue in case if your problem wasn't resolved.
Release 0.7.3 works fine, thanks!