How can use (if, end) inside the neural network script?
Show older comments
I have a script for neural network for 4 inputs and 1 target data (each one 104 times observation). when I run the network, the variety of performance in different runs are to much and it is sometime more and leas than 3, where my ideal performance is leas than 3. In order to solve this problem, I want to use a (if, then) inside the script. Although, I do not know this is applicable or not, but the network would not goes inside the loop. I would really appreciate to tell me how can I use (if, end) statement inside the script.
inputs = x;
targets = t;
[ I, N ]= size(x);
performance=10;
if performance>3
% Create a Fitting Network
H = 10;
TF={'tansig','purelin'};
net = newff(x,t,H,TF);
net = init(net);
net = train(net,x,t);
net.divideFcn = 'dividerand'; % Divide data randomly
net.divideMode = 'sample'; % Divide up every sample
net.divideParam.trainRatio = 70/100;
net.divideParam.valRatio = 15/100;
net.divideParam.testRatio = 15/100;
net.trainparam.max_fail=10;
% Train the Network
[net,tr] = train(net,inputs,targets);
% Test the Network
outputs = net(inputs);
errors = gsubtract(targets,outputs);
performance = perform(net,targets,outputs);
end
W = outputs / [ ones(1,N) ; x ];
y = W*[ ones(1,N) ;x ];
view(net)
Accepted Answer
More Answers (1)
Walter Roberson
on 13 Aug 2015
0 votes
newff() is officially obsolete, and the documentation has been removed from current releases. You should try to convert it to more modern routines. See http://www.mathworks.com/matlabcentral/answers/77741-newff-create-a-feed-forward-backpropagation-network-obsoleted-in-r2010b-nnet-7-0
You will probably want to train multiple times on different random subsets. I do not know what the best way of doing that is.
Categories
Find more on Deep Learning Toolbox in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!