Why is the mean square value changing to an another value for a different training function ?

1 次查看(过去 30 天)
clc; clear all;close all;
seed = 2;
rand('seed',0);
co=1; % Testing takes pleace for co number of runs and average is returned
meanTrain=0; %mean performacne of training data
meanTest=0; %mean performacne of testing data
tn_data = xlsread('D:\PROJECT\back prop\train_data.xlsx');
s1 = tn_data;
tn_test = xlsread('D:\PROJECT\back prop\train_test.xlsx');
s2 = tn_test;
tt_data = xlsread('D:\PROJECT\back prop\test_data.xlsx');
s3 = tt_data;
tt_test = xlsread('D:\PROJECT\back prop\test_test.xlsx');
s4 = tt_test;
in=s(:,3:3); %in contains all inputs
ou=s(:,2:2); %ou contains all outputs
for i=1:co
trainInput=[];
trainOutput=[];
testInput=[];
testOutput=[];
trainInput = s1;
trainOutput = s2;
testInput = s3;
testOutput = s4;
inn = [trainInput' testInput'];
in = inn(:)
% network initialization
net=newff(minmax(in'),[20,1],{'tansig','purelin'},'traingdm_new');
net.trainParam.show = 50;
net.trainParam.lr = 0.01;
net.trainParam.mc = 0.1;
net.trainParam.epochs = 5000;
net.trainParam.goal = 2e-2;
% training
[net,tr]=train(net,trainInput',trainOutput');
% testing on training data
a = sim(net,trainInput');
a=a';
corr=0;
for j=1:size(trainInput,1)
if a(j)< 0.49 ans=0; else ans=1; end
if trainOutput(j)==ans corr=corr+1;
fprintf('\n the %d th image is correctly classified',j);
end
end
corr;
corr/size(trainInput,1)*100; % percent train accuracy
meanTrain=meanTrain+corr;
% testing on testing data
a = sim(net,testInput');
a=a';
corr=0;
for j=1:size(testInput,1)
if a(j)< 0.49 ans=0; else ans=1; end
if testOutput(j)==ans corr=corr+1;
q(j) = corr;
fprintf('\n the %d th image is correctly classified',j);
end
end
corr;
meanTest=meanTest+corr;
corr/size(testInput,1)*100; % percent test accuracy
end
s=size(trainInput,1);
%'Mean Train Recognized'
ttt =meanTrain;
ttit=meanTrain/co;
'Mean Train Recognition Accuracy'
result1 = (meanTrain/co)/s*100 % mean percent train accuracy
s=size(testInput,1);
%'Mean Test Recognized'
ttet = meanTest;
tet = meanTest/co;
'Mean Test Recognition Accuracy'
result2 = (meanTest/co)/s*100 % mean percent test accuracy
e = testOutput - a;
perf1 = mse(e)
%%%%%%%%%%%%%%%%%%%%%%%%%%%% Code ends %%%%%%%%%%%%%%%%%%%%
The Test Accuracy that I get is 93.33 % and the mean square error is 0.1031
I have used the training function "traingdm".
If I use the training function "trainbr" and its corresponding training parameters, the classification percentage is 93.33%
But the mean square error changes to some other value. Why is this happening ????

采纳的回答

Greg Heath
Greg Heath 2014-1-15
help trainbr
Note that
"trainbr ... minimizes a combination of squared errors and weights"
Hope this helps.
Greg

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by