MATLAB: MATLAB CODE FOR ANN is not producing the desired output,program code is given .

artifical neural networksartificial intelligeneDeep Learning Toolbox

inputs = [31 9650.00 3300.00 4350.00]; targets = [11 21 31 51];
% Create a Fitting Network hiddenLayerSize = 20; net = fitnet(hiddenLayerSize);
% Setup Division of Data for Training, Validation, Testing % For a list of all data division functions type: help nndivide 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;
% For help on training function 'trainlm' type: help trainlm % For a list of all training functions type: help nntrain net.trainFcn = 'trainlm'; % Levenberg-Marquardt
% Choose a Performance Function % For a list of all performance functions type: help nnperformance net.performFcn = 'mse'; % Mean squared error
% Choose Plot Functions % For a list of all plot functions type: help nnplot net.plotFcns = {'plotperform','plottrainstate','ploterrhist', … 'plotregression', 'plotfit'};
% Train the Network [net,tr] = train(net,inputs,targets);
% Test the Network outputs = net(inputs); errors = gsubtract(targets,outputs); performance = perform(net,targets,outputs)
% View the Network view(net) sim(net,outputs) % Plots % Uncomment these lines to enable various plots. %figure, plotperform(tr) %figure, plottrainstate(tr) %figure, plotfit(net,inputs,targets) %figure, plotregression(targets,outputs) %figure, ploterrhist(errors)
THE PROBLEM IS THAT I DONT GET OUTPUTS NEAR TO MY TARGETS

Best Answer

The problem is that you do not have enough training data to sufficiently characterize a net of that size.
inputs = [31 9650.00 3300.00 4350.00];
targets = [11 21 31 51];
% Create a Fitting Network hiddenLayerSize = 20;
H=20
[ I N ] = size(inputs) % [ 1 4 ]

[ O N ] = size(targets) % [ 1 4 ]
Ntst = round(0.15^N) % 1

Nval = Ntst % 1
Ntrn = N-Nval-Ntst % 2
Ntrneq = N*O % 2 = No. of training equations
CORRECTION:
Ntrneq = Ntrn*O % 2 = No. of training equations
Nw = (I+1)*H+(H+1)*O % 61 = No. of unknown weights
Two equations are not enough to estimate 61 unknowns