Change in fitness function
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
taytob
am 29 Dez. 2014
Kommentiert: taytob
am 2 Jan. 2015
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
0 Kommentare
Akzeptierte Antwort
Greg Heath
am 31 Dez. 2014
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
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Deep Learning Toolbox finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!