Change in fitness function

4 visualizzazioni (ultimi 30 giorni)
taytob
taytob il 29 Dic 2014
Commentato: taytob il 2 Gen 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

Risposta accettata

Greg Heath
Greg Heath il 31 Dic 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
  1 Commento
taytob
taytob il 2 Gen 2015
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.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Deep Learning Toolbox in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by