create target for neural network
Show older comments
Hi all,
I had extracted feature vector of an image and saved it in a excel document. feature vector is 42x42 dimension. I don't know how to create target for this input so i can train the neural network. I need to do emotion classification. 5 classes. So, how do i create target vector and train the network?
Accepted Answer
More Answers (1)
Greg Heath
on 14 Feb 2012
remo asked on 12 Feb 2012 at 12:29
>I had extracted feature vector of an image and saved it in a excel document. feature vector is 42x42 >dimension. I don't know how to create target for this input so i can train the neural network. I need to >do emotion classification. 5 classes
The input features must be column vectors. If you extract a feature matrix from an original matrix, you can convert it to a feature vector using the colon operator. For example, if you have a feature matrix fm with size(fm) = [ r, c ], then fv = fm(:) will be the corresponding feature vector with size(fv) = [ r*c, 1 ].
If you have N feature vectors from N images, the N columns form an input matrix, p, with size(p) = [ I N ] and I = r*c.
If the N images come from k classes, the corresponding target matrix, t, contains N columns of the k-dimensional unit matrix eye(k). The row containing the "1" is the class index for the corresponding input vector. size(t) = [ O N ] with O = k.
The output matrix is readily formed using the function IND2VEC. For example
>> t = full(ind2vec([ 1 3 5 2 4 ]))
t =
1 0 0 0 0
0 0 0 1 0
0 1 0 0 0
0 0 0 0 1
0 0 1 0 0
Given a feature vector, the resulting elements in the output vector can be interpreted as approximations to the input-conditional class posterior probabilities. The input vector is then assigned to the class corresponding to the maximum output.
A single hidden layer with H nodes is sufficient. The resulting node topology is I-H-O. This will result in Neq = N*O nonlinear equations to be "solved" for Nw = (I+1)*H+(H+1)*O unknown weights. For training to convergence, it is required that Neq >= Nw. However, the condition Neq >> Nw is preferable to mitigate real-world noise and measurement error. This is equivalent to requiring
H <= Hub is required but H << Hub is desired where the upper bound Hub is given by
Hub = ( Neq - O ) / ( I + O + 1 ).
A practical value for H can be obtained by trial and error keeping the above conditions in mind.
Hope this helps.
Greg
Categories
Find more on Deep Learning Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!