Change in fitness function

4 ビュー (過去 30 日間)
taytob
taytob 2014 年 12 月 29 日
コメント済み: taytob 2015 年 1 月 2 日
Hi,
In a feedforward neural network, I have :
x = Inputs a = Outputs y = f(a) z = Targets
I want to do :
mse = sum((y-z)²)/length(y)
How can I do it in matlab please. Thanks

採用された回答

Greg Heath
Greg Heath 2014 年 12 月 31 日
Faulty notation. Typical usage is input x, target t, output y . See the documentation examples for the regression/curve-fitting function FITNET.
See PATTERNNET for classification/pattern-recognition documentation examples.
Both functions call FEEDFORWARDNET which never has to be explicitly used.
help fitnet
doc fitnet
[x, t] = simplefit_dataset;
net = fitnet(10);
net = train(net,x,t);
view(net)
y = net(x);
perf = perform(net,t,y) % Unscaled number doesn't tell you much
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% An expanded modification. Search the NEWSGROUP and ANSWERS using
greg fitnet
% Ending semicolons removed from selected commands so that results are automatically printed to the screen
[ x, t ] = simplefit_data;
[ I N ] = size(x)
[ O N ] = size(t)
figure(1)
plot(x,t) % Smooth curve with two local max and mins suggest at least 4 hidden nodes (H>=4)
% MATLAB Default trn/val/tst data division ratio is 0.7/0.15/0.15
Ntrn = N-2*round(0.15*N) % Default No. of training examples
Ntrneq = Ntrn*O % No of training equations
net = fitnet; % Uses default of one hidden layer with H = 10 hidden nodes
Nw = (I+1)*H+(H+1)*O % Nw = 31 unknown weights to estimate (Nw <= Ntrneq?)
[ net tr y e ] = train(net,x,t);
% y = net(x);
% e = t-y;
NMSE = mse(e)/var(t,1) % Normalized mean-square-error ( NMSE < 0.01 ?)
R2 = 1 -NMSE % Fraction of target variance modeled by the net (R2 > 0.99 ?)
Hope this helps.
Thank you for formally accepting my answer
Greg % See Wikipedia/Rsquared
  1 件のコメント
taytob
taytob 2015 年 1 月 2 日
Thank you Greg for your answer, Your tutorials are good and can be useful but I did not find my solution.
I will try another way with right notation
if performance function of neural network can be: net.performFcn = 'mse'
How can I change de variables used in mse :
I need to change :
mse = sum((y-t)²)/length(t)
to :
mse = sum((a-t)²)/length(t)
with a = f(y)
I hope that it is more understandable.

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

その他の回答 (0 件)

カテゴリ

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