All Things Techie With Huge, Unstructured, Intuitive Leaps


I decided to get fancy with my multilayer perceptron, Artificial Intelligence machine that I build over the Christmas season. It was a classical design of artificial neurons, arranged in a layered perceptron pattern with weights and firing thresholds.  Instead of loading a bunch of arrays that were the nodes in the perceptron, I created objects. There were the neurons themselves, and the axons feeding the neurons.  I had the problem of saving the weights, and instead of writing all of it to a file, and having a massive IO operation, I decided to serialize the whole machine.  That way, I could resurrect the whole machine by de-serializing it.

I also thought that I was being smart by having a property change listener on the last input of each layer.  When the final input changed state, I would use the property change listener to fire the neuron.  It all worked like a charm, except when it came time to save the machine.  I kept getting a

It turned out that the PropertyChangeListener is not serializable.  I marked it transient, which means that it wasn't serialized, but I wasn't crazy about the whole machine not being serialized.

So, I coded out the property change listener.  All this to say, is that if you get this exception, you can mark the field transient, to not serialize it, or you can code out the parts that won't serialize.

Hope this helps someone.

No comments:

Post a Comment