How can I reuse the same neural network to recreate the same results I had while training/creating the network?

5 ビュー (過去 30 日間)
Hello,
I am new to neural networking, so my question may sound stupid.
I have trained/created a neural network, I have saved the script of the network, but each time I run the script, it gives different R values. How can I get the same R value I had while training the network and how do I plug in new input data to see the results by using the same network.

採用された回答

Greg Heath
Greg Heath 2014 年 3 月 16 日
I don't think you want to save the script.
You want to save the net
save net
Hope this helps.
Greg

その他の回答 (2 件)

the cyclist
the cyclist 2014 年 3 月 5 日
Presumably you need to set the random number generator seed.
If you have a relatively new version of MATLAB, you can do this with the rng() command, for example, put
rng(1)
at the beginning of your code.
doc rng
for details.
  2 件のコメント
Karthik
Karthik 2014 年 3 月 6 日
Thanks for the fast reply, it works:)
But, when I run the network, with through ''nnstart'' and train it, it gives an R value of 0.98 , but once I save the script and rut it its gives 0.60 as R value, each time I run, not 0.98. Also how Can i use the saved network for new testing new datas.
Greg Heath
Greg Heath 2014 年 3 月 6 日
1. (0.6 vs 0.98): Need more info
2. ynew =net(xnew);

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


Karthik
Karthik 2014 年 3 月 6 日
I fixed the first problem. _ | *Regarding the 2nd question, I trained a network, then I saved the script as 'ntwk'. Then I went to my matlab file, which has the data that was used for training, and created a new array called 'xnew', to check how my saved network works on the new data, then i tried to execute the command _ .|*
ynew=ntwk(xnew)
IT GIVES THE ERROR MESSAGE
'' Attempt to execute SCRIPT ntwk as a function: H:\NEURAL NETWORK\ntwk.m
Error in valmetrutpercent (line 112) ynew=ntwk(xnew) ''
THE NETWORK CODE I SAVED WAS
% Solve an Input-Output Fitting problem with a Neural Network % Script generated by NFTOOL % Created Thu Mar 06 18:11:55 CET 2014 % % This script assumes these variables are defined: % % ci10_1 - input data. % z10_1 - target data.
rng(1)
inputs = ci10_1; targets = z10_1;
% Create a Fitting Network hiddenLayerSize = 10; net = fitnet(hiddenLayerSize);
% Setup Division of Data for Training, Validation, Testing net.divideParam.trainRatio = 70/100; net.divideParam.valRatio = 15/100; net.divideParam.testRatio = 15/100;
% Train the Network [net,tr] = train(net,inputs,targets);
% Test the Network outputs = net(inputs); errors = gsubtract(targets,outputs); performance = perform(net,targets,outputs)
% View the Network view(net)
% Plots % Uncomment these lines to enable various plots. %figure, plotperform(tr) %figure, plottrainstate(tr) %figure, plotfit(net,inputs,targets) %figure, plotregression(targets,outputs) %figure, ploterrhist(errors)
  1 件のコメント
Greg Heath
Greg Heath 2014 年 3 月 8 日
Please do not use the ANSWER box for comments. In this case
1. copy your comments in the answer bos
2. paste them in the comment box
3. delete your answer box

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

カテゴリ

Help Center および File ExchangeDeep Learning Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by