Is there a way to save and restore trained neural network weights?

I've been using artificial neural networks implemented in OpenCV, and it works well, but I just realized that the documentation doesn't explain a way to save and load trained weights. I'd like to do this so I don't have to train every time I start the program.

The neural networks class uses the CvStatModel class underneath, as does every machine learning technique to create the classifiers. As seen here this class has the save functionality, which will create an xml structure with the correct paramaters.

For recalling these parameters the same class suggests to use the load functionality.

However, from docs I am thinking this may not be possible on the neural network, but you could simply try it out. If it doesn't work out, you could save the data manually to a text file, which is not that hard, since you can get the number of layers and retrieve the weights based on the layer index, as mentioned here. However, it is not suggested that you can use the same information to input data into a new created network. Check if the code supports setters for the corresponding getters. It might be possible that they are not documented.

If this is not the case, I suggest creating a issue ticket, suggesting to add this to the library, which could not be that hard. If you don't know how to, I will do it for you.