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 CenterFile Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by