Is there a way to save a trained neural network for future use after the current run ends?
Show older comments
For applications that do not require real-time predictions, the user may tolerate Matlab ANN runs that seem to take forever. Case in point: With about 300 variables (or descriptors), 2000 data points, 5 different variations of neurons in the hidden layer (5 to 25 in increments of 5),3 re-initializations (to avoid local minima), but no division into training & validation sets (unnecessary with Bayes regularization), trainbr (1 hidden layer) takes about a week (on a Windows 7 laptop with 4GB RAM, running the 64 bit version of Matlab).
The run also includes, for comparison, trainings based on 30 linear or nonlinear principal components or selected descriptors instead of the 300 raw descriptors. So, asking me to explore "dimension reduction" is not the answer.
It would be nice to save the network (weights, etc.) trained at such an expense of time, so that it can be evaluated on test data that may become available in the future, without having to spend a week training the network everytime a new set of test data becomes available.
Accepted Answer
More Answers (2)
Sean de Wolski
on 9 Nov 2012
0 votes
Can't you just save it?
4 Comments
Greg Heath
on 13 Nov 2012
I agree. Save the whole net instead of saving parameters and weights separately.
Sree Srinivasan
on 14 Nov 2012
Greg Heath
on 28 Nov 2012
I think all you need is
save net1
load net1
Devyani Parate
on 13 Jan 2018
do we write this in the code?
Cyrus McCandless
on 6 Mar 2019
0 votes
This doesn't work for me, and gives a save error saying my file may be corrupt. The syntax that works for me is:
save 'foo' net
...where 'foo' is the name you want to save it as, and 'net' is the trained network that you want to save as 'foo'. The file you save will be called foo.mat, and will be located in the current directory.
Categories
Find more on Networks in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!