MATLAB: Change in fitness function fitness functionMATLABneural networktutorial 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 Best Answer 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.15Ntrn = N-2*round(0.15*N) % Default No. of training examplesNtrneq = Ntrn*O % No of training equationsnet = fitnet; % Uses default of one hidden layer with H = 10 hidden nodesNw = (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 answerGreg % See Wikipedia/Rsquared Related SolutionsMATLAB: Normalize Inputs and Targets of neural network MAPMINMAX can be inappropriate only if there are outliers.Use MAPSTD to detect outliers that can be removed or modified.Hope this helps.Thank you for formally accepting my answerGreg MATLAB: MORE HELPFUL THAN CODE IN HELP/DOC/TYPE NEWFF The answer is in the question! Related QuestionI have a data set of 9X120. want to use feedforwardnet and want to know how to define dataset such as simplefit_dataMAPE for out-of-sample in neural networkHow to calculate the error in Neural Network Back Propagation NetworkHow to decrease the neural network error
Best Answer