Neural Network program problem in classification
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 ?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/147332/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/147333/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/147334/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/147335/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/147336/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/147337/image.jpeg)
0 Commenti
Risposta accettata
Greg Heath
il 1 Mar 2015
You are confused.
What is the physical problem you are trying to solve?
1. What are the inputs?
2. What are the corresponding outputs?
3. The targets are not unit vectors. Therefore they are not appropriate for use in a standard NN classifier.
7 Commenti
Più risposte (2)
Brendan Hamm
il 26 Feb 2015
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.
Greg Heath
il 27 Feb 2015
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 Commenti
Vedere anche
Categorie
Scopri di più su Image Data Workflows in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!