What is the use of the target matrix and how do i create one?

We are developing a neural network for classification there are 72 signals and there are 100 samples of each signal. We have extracted 49 parameters from each signal. What should my target matrix contain

 Accepted Answer

The current neural network classification function is PATTERNNET (replacing the obsolete NEWPR). The syntax of the target matrix for N I-dimensional column inputs that are to be assigned into into 1 of c classes is N c-dimensional {0,1} unit vectors from the unit matrix eye(c).
[ I N ] = size(input)
[ c N ] = size(target)
The transformation between the true class index row vector and the corresponding target matrix is
target = full(ind2vec(trueclassind))
trueclassind = ind2vec(target)
Therefore, if the classifier output is
output = target+ randn(1,N)
the estimated classindex and error vectors are
estclassind = vec2ind(output)
error = estclassind~=trueclassind
Nerr = sum(error)
PctErr = 100*Nerr/N
1. Test the above code with N = 9,
classind = [ 9 7 5 3 1 8 6 4 2 ]
2. See the online documentation
help patternnet
doc patternnet
3. Search both the NEWSGROUP and ANSWERS for my examples
greg patternnet
Hope this helps.
Thank you for formally accepting my answer
Greg

7 Comments

Hi! I have a question about the ind2vec. Is it use to make a target matrix from the sample data? If yes, I tried using it but there's an error "The data is not a row vector or cell array of row vectors.", so I tried again to make it a single row, but there's an error again "The data contains non-integer values." Can you help me understand the use of it? Thanks
Target matrices cannot contain string or struct or cell array of cell.
Oh, so I can only use a single row and only consists of integer value. I tried it, and then I get an output of sparse double and all the values are 1, how should I interpret it to make it a target matrix?
Just pass it in. Any location not defined as nonzero will be 0 in a sparse matrix
Ah yes I get it. Thanks. I hope my pattern recognition would work now.
If it does, then please accept Professor Heath's answer to give him credit for helping you.
I would glad to, but I'm not the one who asked the questions, I only asked through the comments. I would just give a vote because its the least I can do, same with mr. Roberson.

Sign in to comment.

More Answers (1)

It depends on which routine you are using. Typically the target matrix is a vector, one element per sample, which contains the nonnegative integer class number that the sample is to be assigned to. But for some routines, the target matrix is a 2D matrix, one row per sample, in which all of the elements in a row are 0 except that the N'th element is 1 to indicate that the sample belongs to the N'th class. (There are routines provided to convert between the two forms.)
You construct a target vector by populating it with the known class numbers for each of your training samples. You would have determined the known class numbers by some outside method. For example if those 72 signals are intended to be distinct, then the class number would be an integer in the range 1 to 72.

Categories

Find more on Deep Learning Toolbox in Help Center and File Exchange

Asked:

on 25 Jan 2016

Commented:

on 30 Jan 2016

Community Treasure Hunt

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

Start Hunting!