How do you save a Neural Network to file using Ruby's ai4r gem?
I'm using ruby's ai4r gem, building a neural network. Version 1.1 of the gem allowed me to simply do a Marshal.dump(network) to a file, and I could load the network back up whenever I wanted.
With version 1.9 a couple years later, I'm no longer able to do this. It generates this error when I try:
no marshal_dump is defined for class Proc
I know the reason for the error - Marshal can't handle procs in an object. Fair enough.
So is there something built in to ai4r? I've been searching with no luck. I can't imagine any practical use for a neural network you have to rebuild开发者_如何学C from scratch every time you want to use it.
I just fixed that problem. Version 1.10 should work OK.
However, if you customize the propagation function with a lambda function, you will have to restore it manually after loading the instance. This is because lambda functions cannot be serialized, so the implementation reset it to the default function. Sorry for not solving it sooner, but I have been having some crazy months at work.
Cheers,
Sergio Fierens.
精彩评论