[NEURAL NETWORK] How can I make MSE be the same in different trying times ?

The Mean Square Error (MSE) turns out to be different each time I train the network.
_net = feedforwardnet(10,'trainlm');
net.divideParam.trainRatio=1;
net.divideParam.valRatio=0;
net.divideParam.testRatio=0;
net.trainParam.epochs=10;
[net,tr]=train(net2,x,t);
MSE=sumsqr(net2(x)-t)_
I guess it come from net2.initFcn caused this problem. How do I change it to make MSE becomes the same ?

 採用された回答

Greg Heath
Greg Heath 2014 年 12 月 2 日
編集済み: Greg Heath 2014 年 12 月 2 日
Initialize the state of the random number generator ONCE AND ONLY ONCE before the random data division and random weight initialization.
In the following example, The design is not repeatable if either or both the first two commands in the loop are commented out.
clear all, clc
[ x, t ] = simplefit_dataset;
MSE00 = mean(var(t',1)) % 8.3378 Reference MSE
net = feedforwardnet; % Defaults used
for i = 1:2
rng('default') % Reset RNG state
net = configure(net,x,t); % Weight initialization
[net tr y e] = train(net,x,t); % y = net(x), e=t-y
NMSE = mse(e)/MSE00 % 1.7558e-05
ttrn = t(tr.trainInd);
MSEtrn00 = mean(var(ttrn',1)) % 8.8219
NMSEtrn = tr.best_perf/MSEtrn00 % 1.386e-05
NMSEval = tr.best_vperf/MSEtrn00 % 1.0019e-05
NMSEtst = tr.best_tperf/MSEtrn00 % 3.6061e-05
end
% P.S. Look at the results of the following command
tr = tr % No semicolon
Hope this helps.
Thank you for formally accepting my answer
Greg

3 件のコメント

Son Nguyen
Son Nguyen 2014 年 12 月 2 日
Appreciate very much. It really helps. Could you please help me a favor? How can I make it returns MSE per iterations ? The current MSE is applied only when training if finished.
Greg Heath
Greg Heath 2014 年 12 月 2 日
Obviously, you did not follow my advice to see what goodies tumble out of
tr = tr
Son Nguyen
Son Nguyen 2014 年 12 月 3 日
I apologize that I missed it, I got it already.
I still has one more question. Is there anyway to take out the initial weights of training ? I'm going to compare my algorithm with LM and BFGS. In order to do that, I have to make they have the same initial weights.
If you feel not comfortable to answer my question here, please let me know, I will make a new question for it.
Appreciate very much for your help.

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

その他の回答 (1 件)

Greg Heath
Greg Heath 2014 年 12 月 2 日

0 投票

Remove the underscores at the beginning and end.
Use net.divideFcn = 'dividetrain' to automatically get the (1/0/0) data division
I hope you don't use 10 epochs for serious work
net2 in never defined
MSE depends on net, not net2
sumsq yields SSE, not MSE
For repeatability you have to set the initial state of the random number generator before data divisions and weight initializations.
MSE is scale dependent. Better to normalize by the average target variance
Hope this helps.
Thank you for formerly accepting my answer
Greg

カテゴリ

ヘルプ センター および File ExchangeDeep Learning Toolbox についてさらに検索

質問済み:

2014 年 12 月 1 日

コメント済み:

2014 年 12 月 3 日

Community Treasure Hunt

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

Start Hunting!

Translated by