Abnormal outputs in Neural Networks Blind tests (new tests after the net is trained).
조회 수: 3 (최근 30일)
이전 댓글 표시
The data divisions in my ANN model is trn 60 - val 20 - tst 20 . All of my input and target values are in between 0 - 1 (numeric values). The problem that i am facing with is >> when the network is trained, i insert new data set (five new input variables but samples number are 35) to estimate the output variable, as it was already trained with the target variable. Unfortunately the output becomes exactly same for all the 35 samples. It must not happen, there is something wrong that i might have done. Could you please light some shed on these. I am using Matlab R2012b version. Matlab codes are given as follows:
Inp_var1 = xlsread('Training data.xlsx','B2:B165241');
Inp_var2 = xlsread('Training data.xlsx','D2:D165241');
Inp_var3 = xlsread('Training data.xlsx','C2:C165241');
Inp_var4 = xlsread('Training data.xlsx','E2:E165241');
Inp_var5 = xlsread('Training data.xlsx','F2:F165241');
Tar_var1 = xlsread('Training data.xlsx','K2:K165241');
Input(1,:) = Inp_var1;
Input(2,:) = Inp_var2;
Input(3,:) = Inp_var3;
Input(4,:) = Inp_var4;
Input(5,:) = Inp_var5;
Target(1,:) = Tar_var1;
net = feedforwardnet;
net = configure(net,Input,Target);
net.layers{1}.transferFcn = 'tansig';
net.layers{1}.initFcn = 'initnw';
net.layers{2}.transferFcn = 'purelin';
net.layers{2}.initFcn = 'initnw';
net = init(net);
net.IW{1,1}
net.b{1}
net.adaptFcn = 'adaptwb';
net.inputWeights{1,1}.learnFcn = 'learnp';
net.biases{1}.learnFcn = 'learnp';
inputs = Input;
targets = Target;
hiddenLayerSize = 3; % number of hidden neurons
net = fitnet(hiddenLayerSize);
net.inputs{1}.processFcns = {'removeconstantrows','mapminmax','mapstd'};
net.outputs{2}.processFcns = {'removeconstantrows','mapminmax','mapstd'};
net.divideFcn = 'dividerand';
net.divideMode = 'sample';
net.divideParam.trainRatio = 60/100;
net.divideParam.valRatio = 20/100;
net.divideParam.testRatio = 20/100;
net.trainFcn = 'trainlm';
net.performFcn = 'mse';
net.plotFcns = {'plotperform','plottrainstate','ploterrhist', ...
'plotregression', 'plotfit'};
net.efficiency.memoryReduction = 1;
[net,tr] = train(net,inputs,targets);
outputs = net(inputs);
errors = gsubtract(targets,outputs);
performance = perform(net,targets,outputs);
trainTargets = targets .* tr.trainMask{1};
valTargets = targets .* tr.valMask{1};
testTargets = targets .* tr.testMask{1};
trainPerformance = perform(net,trainTargets,outputs)
valPerformance = perform(net,valTargets,outputs)
testPerformance = perform(net,testTargets,outputs)
net.trainParam.epochs;
net.trainParam.time;
net.trainParam.goal;
net.trainParam.min_grad;
net.trainParam.mu_max;
net.trainParam.max_fail;
net.trainParam.show;
end
댓글 수: 0
채택된 답변
Greg Heath
2014년 2월 24일
Most of your code is useless. It is equivalent to
Input(1,:) = xlsread('Training data.xlsx','B2:B165241');
Input(2,:) = xlsread('Training data.xlsx','D2:D165241');
Input(3,:) = xlsread('Training data.xlsx','C2:C165241');
Input(4,:) = xlsread('Training data.xlsx','E2:E165241');
Input(5,:) = xlsread('Training data.xlsx','F2:F165241');
Target(1,:) = xlsread('Training data.xlsx','K2:K165241');
hiddenLayerSize = 3; % number of hidden neurons
net = fitnet(hiddenLayerSize);
net.inputs{1}.processFcns = {'removeconstantrows','mapminmax','mapstd'};
net.outputs{2}.processFcns = {'removeconstantrows','mapminmax','mapstd'};
net.divideParam.trainRatio = 60/100;
net.divideParam.valRatio = 20/100;
net.divideParam.testRatio = 20/100;
[net,tr] = train(net,inputs,targets);
outputs = net(inputs);
errors = gsubtract(targets,outputs);
performance = perform(net,targets,outputs);
trainTargets = targets .* tr.trainMask{1};
valTargets = targets .* tr.valMask{1};
testTargets = targets .* tr.testMask{1};
trainPerformance = perform(net,trainTargets,outputs)
valPerformance = perform(net,valTargets,outputs)
testPerformance = perform(net,testTargets,outputs)
Make sure the input summary statistics (mean/covariance-matrix) for the original and new data are close enough to be assumed to be drawn from the same probability distribution.
Thank you for formally accepting my answer
Greg
댓글 수: 6
Greg Heath
2014년 2월 26일
편집: Greg Heath
2014년 2월 26일
With N this large you do not need val and test
net.divide.Fcn = 'dividetrain'; %100/0/0
and try to minimize H, the number of hidden nodes.
Hope this helps.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Sequence and Numeric Feature Data Workflows에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!