Filter löschen
Filter löschen

What are the application of defining the Classes in Neural Network ?

4 Ansichten (letzte 30 Tage)
Hi All
I was reading a comment in Neural Network to learn this topic more to develop my code
one thing I yet have not understood is that in the code we define classes in the code , what is that and why is it used ?
here is the comment :
%A quick way to see if any of the variables or classes appear to be different from the others is to standardize the inputs to zero-mean/unit-variance and compare the rows and columns of W0
%STANDARDIZATION (To compare Linear Model coefficients)
zinputs = zscore(inputs')';
W0z = targets/[ones(1,N); zinputs];
minmaxW0z = minmax(W0z); % [ 50 2 ]
minmaxW0zp = minmax(W0z'); % [ 61 2 ]
whos
figure
subplot(2,1,1)
hold on
plot(1:50,minmaxW0z(:,1),'bo')
plot(1:50,minmaxW0z(:,2),'ro')
subplot(2,1,2)
hold on
plot(1:61,minmaxW0zp(:,1),'bo')
plot(1:61,minmaxW0zp(:,2),'ro')
%When the inputs are standardized, I see no significant differences between the weights associated with different classes or different variables
  2 Kommentare
Greg Heath
Greg Heath am 23 Feb. 2015
What is this supposed to mean:
minmaxW0z = minmax(W0z); % [ 50 2 ]
minmaxW0zp = minmax(W0z'); % [ 61 2 ]
?
farzad
farzad am 23 Feb. 2015
Dear Professor Heath
well Maybe I just did not use the right code , my major question is on the code you have written me , I don't precisely understand every line of it , the mapminmax is supposed to mean to normalize the data of input and target between -1 and +1 so we could say if the data belong to the same class , this is just one thing I have read , I think you have explained the same thing here , but in this code that is familiar :
close all, clear all, clc, plt = 0
[ x, t ] = simpleclass_dataset;
[ I N ] = size(x) % [ 2 1000 ]
[ O N ] = size(t) % [ 4 1000 ]
trueclass = vec2ind(t);
class1 = find(trueclass==1);
class2 = find(trueclass==2);
class3 = find(trueclass==3);
class4 = find(trueclass==4);
N1 = length(class1) % 243
N2 = length(class2) % 247
N3 = length(class3) % 233
N4 = length(class4) % 277
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')
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 = newpr(x,t,h);
[ 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;
results = [ h PctErr ]
here i just don't get it , why 4 classes ? cause my target contains 4 outputs ? and all my data are collected as class 2 , is it ok ?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Greg Heath
Greg Heath am 24 Feb. 2015
I don't think that you understand that MATLAB differentiates 4 basic types of nets
Please read the command line documentation for
help nndatasets
and
doc nndatasets
What type of data is simpleclass_dataset?
How does it differ from simplefit_dataset?
What type of net is fitnet?
How does it differ from patternnet?
Then read the online documentation at mathworks.com
  1 Kommentar
farzad
farzad am 24 Feb. 2015
Thank You Dear Professor Heath
that is right , the simpleclass has two columns of data , so for more than one input we have to classify them , and I also have searched the mathworks, but still knowing them , does not precisely tell me what is happening when you use vec2ind , my question was , for my data , all the data go to class 2 , does it make a problem ?
I also do not get this part :
assignedclass = vec2ind(y);

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by