フィルターのクリア

Neural Network program problem in classification

2 ビュー (過去 30 日間)
farzad
farzad 2015 年 2 月 26 日
コメント済み: farzad 2015 年 3 月 3 日
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 ?

採用された回答

Greg Heath
Greg Heath 2015 年 3 月 1 日
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 件のコメント
farzad
farzad 2015 年 3 月 2 日
I have searched all the web , never found a similar example in classification problem , that the indice of the vectors is always one number
farzad
farzad 2015 年 3 月 3 日
Dear Professor I think I have managed to create to appropriate file , If I am not wrong , but now I have a problem with what that is happening with matlab when starts to train the network , the GRADIENT is NaN , and the performance is to infinity , and not accessible , could you please help me with this problem

サインインしてコメントする。

その他の回答 (2 件)

Brendan Hamm
Brendan Hamm 2015 年 2 月 26 日
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 件のコメント
farzad
farzad 2015 年 2 月 26 日
Thank you dear Brendan , This was Exactly my question , also in my previous questions , thank you , ok , I am searching in the posts , to understand the classification , or find a method , but first I don't really find a good example , for my case , and I don't know the strategy , like the first photo I have inserted , how could it help me ? and if there is any suggestion for distinguishing , please help me , thanks a lot

サインインしてコメントする。


Greg Heath
Greg Heath 2015 年 2 月 27 日
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 件のコメント
farzad
farzad 2015 年 2 月 28 日
my target vector should look like a [0 1 0;0 1 0;0 1 0 ;........;0 1 0] but I see that the lines of the example code , do not do this for my case
farzad
farzad 2015 年 2 月 28 日
Also , Talking about the first code , there is no difference between the input vector x and x2 at all !!! my question is , if all the data go to the same class , is this correct ?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeImage Data Workflows についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by