MATLAB Answers


Saving a neural network within a GUI and opening it back up

Asked by Harold
on 1 May 2013

I'm having problems with saving a neural network and loading it back up. Refer to this post that I made in regards to loading a saved neural network ( saved from the workspace not the GUI)

I was having problems saving a trained neural network. I kept getting the error saying that 'handles.neural_net' is not a valid variable name. I then realized that Matlab does not like '.' in variable names. So within my save neural network callback I created a variable save_net = handles.neural_net. I used this variable in save(). This worked.

Now when I open this trained network and hit my "run neural network" button, I get an error saying 'model' parameter must be a string.

As mentioned in the link posted above, I use the code below to load the saved network. Can anyone find what I'm doing wrong with saving and loading neural networks using handles? I need to be able to use handles for the neural network because it gets passed around from the file select callback to the training or run callback (depending on if you are performing a training or run of the network).

trained_net_vars = load(FileName);
handles.neural_net =;

Note: The training, running, and saving of the network is all done in the GUI. I want to be able to simulate the network using a different input than the input used for training.



1 Answer

Answer by Walter Roberson
on 1 May 2013
 Accepted answer

If the variable you are saving into is named "save_net", then the field name you used after trained_net_vars needs to be "save_net".


Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!