Changing the output of a neural network
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi there,
I have a problem with the output of a neural network for data classification. The network has 4 target vectors.
Say for example the output (column vector) is
0.1 0 0.4 0.3
0.1 0.52 0.45 0.25
0.25 0.08 0.1 0.1
0.65 0.4 0.05 0.35
and then I round the output to get a one in each column, and get this
0 0 0 0
0 1 0 0
0 0 0 0
1 0 0 0
and then I use vec2ind(output) to return the rows that contain 1
It returns [4 2].
But columns 3 and 4 and are not classified.
How can I make it return the row with the highest probability estimate? So this example would return [4 2 2 4]
Many thanks
0 commentaires
Réponse acceptée
Greg Heath
le 5 Fév 2012
>> t = [ 0 0 0 0 % target
0 1 1 0
0 0 0 0
1 0 0 1]
y = [ 0.1 0 0.4 0.3 % output
0.1 0.52 0.45 0.25
0.25 0.08 0.1 0.1
0.65 0.4 0.05 0.35 ]
[ ymax class] = max(y)
t =
0 0 0 0
0 1 1 0
0 0 0 0
1 0 0 1
y =
0.1000 0 0.4000 0.3000
0.1000 0.5200 0.4500 0.2500
0.2500 0.0800 0.1000 0.1000
0.6500 0.4000 0.0500 0.3500
ymax =
0.6500 0.5200 0.4500 0.3500
class =
4 2 2 4
Hope this helps.
Greg
1 commentaire
Greg Heath
le 5 Fév 2012
If posterior probability estimates are desired, use the SOFTMAX activation function. However, if LOGSIG is used a reasonable approximation is to normalize the outputs to have a unity sum:
>> yn = y./repmat(sum(y),4,1)
yn =
0.0909 0 0.4000 0.3000
0.0909 0.5200 0.4500 0.2500
0.2273 0.0800 0.1000 0.1000
0.5909 0.4000 0.0500 0.3500
>> sum(yn)
ans =
1.0000 1.0000 1.0000 1.0000
Hope this helps.
Greg
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Sequence and Numeric Feature Data Workflows dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!