Is there a way to save a trained neural network for future use after the current run ends?
20 views (last 30 days)
Show older comments
Sree Srinivasan
on 9 Nov 2012
Commented: Khurrum Mughal
on 14 Nov 2019
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.
0 Comments
Accepted Answer
Greg Heath
on 14 Nov 2012
save net01
When you need it later
load net01
Voila!
3 Comments
Khurrum Mughal
on 14 Nov 2019
I am also training multiple networks for forecasting. Were you ever able to solve the problem of saving each one of the nets through a For Loop. Because the code above only names it, as u said, literally.
More Answers (2)
Cyrus McCandless
on 6 Mar 2019
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.
0 Comments
See Also
Categories
Find more on AI for Wireless 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!