Viewing the ouput of a neural network
1 view (last 30 days)
Show older comments
Hello,
I have tried out the matlab example on 'Training a deep neural network for image classification'. I am getting the results as in the specified example. But my question is how do I view an output for a given input ? Note : My commands are exactly similar to the example just for trial purposes.
So after deepnet is formed : I do something like :
y = deepnet(xTest);
----------------------------------Till here same as the code
finalnet = configure(deepnet,xTrainImages{1}, tTrain(:,1))
U = imread('YYY.png')
imshow(U)
images_chk{1} = U
idj = sim(finalnet, images_chk{1})
This results in a weird decimal matrix, I would ideally like it to output the class of the input image eg a column containing 1 for 1 entry and 0 for remaining. How can I do that ?
Thanks
0 Comments
Accepted Answer
Greg Heath
on 9 Jan 2016
Edited: Greg Heath
on 9 Jan 2016
For classification into c classes, the target matrix columns should be {0,1} columns from the eye(c) matrix. The transformation between target (and output) vectors and class indices are provided by the VEC2IND & IND2VEC functions :
>> clc, classind = [ 5 3 1 4 2 ],
target = full(ind2vec(classind)),
output = target + 0.1*randn(5),
classind = vec2ind(output)
classind = 5 3 1 4 2
target = 0 0 1 0 0
0 0 0 0 1
0 1 0 0 0
0 0 0 1 0
1 0 0 0 0
output =
-0.053682 0.13094 1.073 0.057452 0.079318
-0.030203 -0.10447 0.049075 0.028184 0.91016
0.18136 0.96517 -0.058613 0.11393 0.015624
0.091485 0.14126 0.07449 0.95741 0.15973
0.99429 0.15024 -0.082815 0.063614 0.011244
classind = 5 3 1 4 2
Hope this helps
Thank you for formally accepting my answer
Greg
0 Comments
More Answers (1)
Walter Roberson
on 8 Jan 2016
It is common that you would need to round() to get the class number.
0 Comments
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!