0
votes

I have trained a neural network using MATLAB and I need to save it to be able to test it in the future.

I would like the appropriate syntax on how I can do this. Please note that I am aware of the graphical toolbox which easily lets you save a trained network, but unfortunately the options provided are not sufficient for me and so I have to create and train a network of my own using code.

I have tried the following syntax to save a trained network. (Most of the syntax is copy paste from the internet with little experimentation of my own.)

save('net.mat', net) save(net) save('net.net', net, '-mat') save('net.net', net)

But I always seem to get the same error: ??? Error using ==> save Argument must contain a string.

If there are experienced users who could lead me to a concrete answer which is sure to work, I would be very grateful.

1

1 Answers

0
votes

From here.

When using parentheses (function syntax) you need to use quotes around the object name. Note that the function requires an object description and not the object itself. This makes sense since it can also take wildcards that describe multiple objects and then save them all into the '.mat' file.
In short, when you're using parentheses, use this:

save('net.mat', 'net')

Alternatively you can use the command syntax (no parentheses) and then quotes are optional. All options below are valid (and equivalent):

save net.mat net
save net.mat 'net'
save 'net.mat' net
save 'net.mat' 'net'

See also Command vs. Function Syntax