target and input matrix in Neural network (ANN)
3 views (last 30 days)
Show older comments
Hi. I'm trying to learn Artificial Neural Network in Matlab and i want to do a simple task of recognizing if an image is a flower or not. So, i have taken 2 pictures of flowers and extracted 8 features from each of them which means i have 16 features in total. I'm using GUI instead of matlab commands to train my network. My question is how do i define the input and target matrix? in=[fa1, fb1 ; fa2, fb2 ;fa3, fb3 ;fa4, fb4 ;fa5, fb5 ;fa6, fb6 ;fa7, fb7 ;fa8, fb8]
where fa1 is the first feature of the first sample image and so on and fb1 is the first feature of the second sample image and so on
is this the correct way to define the input matrix? or do i use this matrix
in=[fa1, fa2, fa3, fa4 ,fa5, fa6 ,fa7, fa8 ;fb1, fb2 ,fb3, fb4 ,fb5, fb6 ,fb7, fb8]
Also, how do i define the target matrix? what will be the size of the target matrix? should it constitute of only 0s and 1s?
And lastly, once i've trained my network, how will i use it to determine if an unknown image is a flower or not?
Thank you
0 Comments
Accepted Answer
Greg Heath
on 25 Jun 2015
For good generalization to unseen data:
For each class the number of samples should exceed the number of input features by a large factor. The input matrix for N I-dimensional inputs has the shape
[ I N ] = size(input)% N >> I
Similarly, for the {0,1} c-class target matrix with columns from eye(c)
[ c N ] = size(target)% N >> c
The relationships between the class indices (1:c) and the target matrix are
target = ind2vec(trueclassindices)
trueclassindices = vec2ind(target)
Similarly, the relationships between the classifier output matrix and the assigned class indices are
assignedclassindices = vec2ind(outputt)
err = (assignedclassindices ~= trueclassindices)% (0,1) vector
Nerr = sum(err)
PctErr = 100*Nerr/N
Individual class errors are obtained by taking the class indices into account.
Hope this helps.
Thank you for formally accepting my answer
Greg
More Answers (1)
See Also
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!