Changing the output of a neural network

1 次查看(过去 30 天)
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

采纳的回答

Greg Heath
Greg Heath 2012-2-5
>> 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 个评论
Greg Heath
Greg Heath 2012-2-5
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

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Sequence and Numeric Feature Data Workflows 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by