How upload a saved neural network in the GUI?

1 回表示 (過去 30 日間)
Hessam
Hessam 2014 年 9 月 9 日
回答済み: salvatore lupo 2017 年 6 月 20 日
I am creating a GUI where there are two options to choose a network to use;
-Uploading an already trained net.
-Training a Network.
For the first choice I want to have the option to go to different directory and upload it. I am using the following command, but it loads the net as a character!! net = uigetfile; handles.net=net;
I will appreciate any help!

採用された回答

Salaheddin Hosseinzadeh
Salaheddin Hosseinzadeh 2014 年 9 月 10 日
Dear Hessam,
Thanks so much for making it clear.
You saved the files with .mat extension, you need load command to load them to MATLAB not dlmread or fopen.
ListOfVariables = load(uigetfile);
If you saved tr and net in one file, they all will be loaded in ListofVariables, ListOfVariables is a structure, that contains all the variables in the .mat file.
You can use tr an net then, in your GUI.
handles.tr = ListOfVariables.tr;
Good Luck!

その他の回答 (6 件)

Salaheddin Hosseinzadeh
Salaheddin Hosseinzadeh 2014 年 9 月 9 日
Hi Hessam,
uigetfile returns the file name and file address only, it will not open or load your selected file!
You can select the file and store its path and name, then using other commands to load the net or file or ...
[filename,filepath] = uigetfile();
So now you have the file name and file path, as characters or strings or variables, whatever you prefer. Then we have to load it. Or if its a text file you have to open it if its an excel file you can read it and ...
load([filepath,filename]);
or
fopen([filepath,filename]);
Depends how you store your network really, which you haven't provide any info about, hopefully you know how to open it load it or ...
Plase refer to MATLAB documentation to see how to use uigetfile, I may made a mistake in the order of its output variables
doc uigetfile
good luck!

Hessam
Hessam 2014 年 9 月 9 日
Thank you Salaheddin
I used [filename,filepath] = uigetfile(); handles.data = dlmread(filename);
to import data files. But the case of a network, after the command,
[filename,filepath] = uigetfile();
since I save the network and training info, net and tr, respectively, I need to assign them to two different file names, How can I do that?
load([filepath,filename]); gives me two files, but I am not sure how to assign them separately to 2 names.
Thanks, Hessam

Salaheddin Hosseinzadeh
Salaheddin Hosseinzadeh 2014 年 9 月 9 日
Hi Hessam,
Sounds like you're progressing, that's good.
- Would you please tell me how did you save the network?
- Do you want to save tr and net? Or you already saved them and you want to open them?
Load command supports some specific files, such as .mat files, if you saved your data using 'save' command, then you can load them with 'load' command.
I'm afraid your comment is not clear, I don't understand if you want to save or load!
If you have two variables in the workspace, and you want to save them in separate files, then all you have to do is
save([filePath,fileName],'tr');
Instead of tr you can use other variable names you have in the workspace.
You can use uiputfile to assign a name and path for your file
save(uiputfile(),'tr'); % something similar to this
Please clearly explain what's the situation step by step so that we can fix your prob asap.
Good Luck!

Hessam
Hessam 2014 年 9 月 10 日
Thank you Salaheddin
It is an already trained network and I have save the net & tr in a a single file named net.mat
I want to select this saved net which in in a certain path (uigetfile) and then use it to perform other procedure in the GUI.
Then I want to pass the net to the handles of the corresponding pushbutton in the GUI, e.g. network=handles.net and traininginfo=handles.tr.
let me know if I am not clear enough.
Thanks

Hessam
Hessam 2014 年 9 月 10 日
It worked. Thanks Sakaheddin.
Hessam
  1 件のコメント
Salaheddin Hosseinzadeh
Salaheddin Hosseinzadeh 2014 年 9 月 11 日
You're very welcomed.
If you're satisfied please accept an answer so I stop following your question :)
Regards,
Salah

サインインしてコメントする。


salvatore lupo
salvatore lupo 2017 年 6 月 20 日
Hi, I'm trying to load my neural network from GUI. I add the command
"net_sentence=load('net_sentence.mat')" in a function contained inside "function pushbutton2_Callback(hObject, eventdata, handles)" but it doesn't load corretly Neural network. Do you know why?

カテゴリ

Help Center および File ExchangeSequence and Numeric Feature Data Workflows についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by