Neural Network program problem in classification
Ältere Kommentare anzeigen
Hi All
I am using this code to train my network, the problem is , if I give an input that is somehow among the value of the inputs I have chosen to train , it gives the right output , but if I give something out of this range , still the output is in the same range of the targets I have given to the code :
close all, clear all, clc, plt = 0
load('input.txt')
%load input
load ('target.txt')
%normalizing data
input=input';
target=target';
% input = mapstd(input);
% target = mapstd(target);
x=input;
t=target;
% [ x, t ] = simpleclass_dataset;
[ I N ] = size(x) % [ 2 1000 ]
[ O N ] = size(t) % [ 4 1000 ]
%vec2ind Transform vectors to indices. takes an NxM matrix V and returns a 1xM vector of indices
% indicating the position of the largest element in each column of V.
trueclass = vec2ind(t);
class1 = find(trueclass==1);
class2 = find(trueclass==2); %in my example all the largest elements are on the 2nd column
class3 = find(trueclass==3);
class4 = find(trueclass==4);
N1 = length(class1)
N2 = length(class2)
N3 = length(class3)
N4 = length(class4)
x1 = x(:,class1);
x2 = x(:,class2);
x3 = x(:,class3);
x4 = x(:,class4);
plt = plt + 1
hold on
plot(x1(1,:),x1(2,:),'ko')
plot(x2(1,:),x2(2,:),'bo')
plot(x3(1,:),x3(2,:),'ro')
plot(x4(1,:),x4(2,:),'go')
%
% Nw = (I+1)*H+(H+1)*O;
Hub = -1+ceil( (0.7*N*O-O)/(I+O+1)) % 399
Hmax = 40 % Hmax << Hub
dH = 4 % Design ~10 candidate nets
Hmin = 2 % I know 0 and 1 are too small
rng(0) % Allows duplicating the rsults
j=0
for h=Hmin:dH:Hmax
j = j+1
net = patternnet(10);
net = init(net); % Improving Results since we use patternet we should use init
[ net tr y ] = train( net, x, t );
assignedclass = vec2ind(y);
err = assignedclass~=trueclass;
Nerr = sum(err);
PctErr(j,1) = 100*Nerr/N;
end
h = (Hmin:dH:Hmax)'
PctErr = PctErr
I just want to know , according to the graphs of confusion , performance ,and the classes drawn , is the training enough or too much or little ?






Akzeptierte Antwort
Weitere Antworten (2)
Brendan Hamm
am 26 Feb. 2015
2 Stimmen
Just looking at this briefly, you have multiple output classes but only 1 class that is being used for training data. Therefore there is no distinction for the classification to make ... everything is of the same class. If you train me to classify everything I see as a circle, and then give me a square, I classify it as a circle still. You need a better training set or your neural net is pointless.
1 Kommentar
farzad
am 26 Feb. 2015
Greg Heath
am 27 Feb. 2015
1 Stimme
The code you are using is for 4 classes.
Revise the code for the number of classes that you have,
For c classes the columns of target are {0,1} c-dimensional unit vectors.
7 Kommentare
farzad
am 27 Feb. 2015
Greg Heath
am 27 Feb. 2015
For classification of c classes the columns of the target are columns of eye(c) with the 1 in the row corresponding to the corresponding class index.
If you do not understand that, look at the target matrices for the classification examples in the documentation
help nndatasets
farzad
am 28 Feb. 2015
farzad
am 28 Feb. 2015
farzad
am 28 Feb. 2015
Kategorien
Mehr zu Image Data Workflows finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!