I'm new at Artificial Neural Network and I'm using MATLAB developing Facial expression recognition and There are six expressions ; I'm not able to understand about How to create a target matrix? My Question is if I have SampleMatrix containing samples rows*columns. While rows are the features and 29 columns represents a single sample I meant to say 29 columns belongs to the same class and If SampleMatrix dimensions are 21007*174. 174 columns because I have 6 classes 6*29=179 What would the target matrix?

Kindly Help me out! Thanks.

  • $\begingroup$ Can you please clarify your question? What sort of application are you working with? How does 29 becomes 174? What are the features? What are the classes? $\endgroup$
    – A_A
    Commented Feb 6, 2017 at 0:13
  • $\begingroup$ working on facial expression recognition system I have computed Eigenfaces of sample images, classes are the 6 expressions. 29 columns for single expression So for 6 expressions; 6 multiply by 29 =174 $\endgroup$ Commented Feb 6, 2017 at 8:05

1 Answer 1


Example with the following numbers (I use random numbers):

  • There are 6 possible classes (face expressions in your case).
  • You have 2000 examples (lets say 2000 photos of faces from which you know the correct face expression).
  • There are 30 features. From each example you have extracted the 30 features and know the correct class.

With these numbers, the input matrix would be a matrix of $30 \times 2000$, where each column $j$ is an example, and it has the 30 features of it. Hence, the position $(i,j)$ contains the feature $i$ of the example $j$.

The target matrix would be a matrix of $6\times 2000$. Where each column $j$ represents the correct class of the example $j$. The column is formed by zeros, and it has a $1$ at the row that indicates the class. If we have 6 classes, and the first example corresponds to class 3, the first column of the target matrix will be $[0 \ 0 \ 1\ 0\ 0\ 0]$. If the second example corresponds to class 5, the second column of the target matrix will be: $[0 \ 0 \ 0 \ 0 \ 1\ 0]$, and so on.

More info here.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.