Probabilistic Neural Networks
概率的神经网络可以用于分类问题。当呈现输入时,第一层计算从输入向量到训练输入向量的距离,并产生元素指示输入的训练输入的载体。第二层为每类输入提供这些贡献,以产生其净输出的概率矢量。最后,Acompetetransfer function on the output of the second layer picks the maximum of these probabilities, and produces a 1 for that class and a 0 for the other classes. The architecture for this system is shown below.
Network Architecture
It is assumed that there areQinput vector/target vector pairs. Each target vector hasK
元素。这些元素中的一个是1,其余的是0.因此,每个输入向量与其中一个相关联K
classes.
The first-layer input weights, IW1,1(net.IW{1,1}
), are set to the transpose of the matrix formed from theQtraining pairs,P'
. When an input is presented, the||
dist
||
框生成一个向量,其元素表示输入输入到训练集的矢量。这些元素乘以元素,由偏差乘以元素并发送到Radbas.
transfer function. An input vector close to a training vector is represented by a number close to 1 in the output vectora1. If an input is close to several training vectors of a single class, it is represented by several elements ofa1that are close to 1.
第二层重量,LW1,2(net.LW{2,1}
), are set to the matrixTof target vectors. Each vector has a 1 only in the row associated with that particular class of input, and 0s elsewhere. (Use functionind2vec
to create the proper vectors.) The multiplicationTa1sums the elements ofa1due to each of theK
input classes. Finally, the second-layer transfer function,compet
, produces a 1 corresponding to the largest element ofn2, and 0s elsewhere. Thus, the network classifies the input vector into a specificK
class because that class has the maximum probability of being correct.
Design (newpnn)
You can use the function纽瓜
to create aPNN. For instance, suppose that seven input vectors and their corresponding targets are
p = [0 0; 1 1; 0 3; 1 4; 3 1; 4 1; 4 3]'
which yields
P = 0 1 0 1 3 4 4 0 1 3 4 1 1 3 Tc = [1 1 2 2 3 3 3]
which yields
Tc = 1 1 2 2 3 3 3
You need a target matrix with 1s in the right places. You can get it with the functionind2vec
. It gives a matrix with 0s except at the correct spots. So execute
T = ind2vec(Tc)
这使
T = (1,1) 1 (1,2) 1 (2,3) 1 (2,4) 1 (3,5) 1 (3,6) 1 (3,7) 1
Now you can create a network and simulate it, using the inputP
to make sure that it does produce the correct classifications. Use the functionvec2ind
to convert the outputY
into a rowYc
使分类清楚。
net = newpnn(p,t);Y = SIM(NET,P);YC = vec2ind(y)
This produces
Yc = 1 1 2 2 3 3 3
You might try classifying vectors other than those that were used to design the network. Try to classify the vectors shown below inP2.
.
P2.= [1 4;0 1;5 2]' P2 = 1 0 5 4 1 2
Can you guess how these vectors will be classified? If you run the simulation and plot the vectors as before, you get
Yc 1 = 23
These results look good, for these test vectors were quite close to members of classes 2, 1, and 3, respectively. The network has managed to generalize its operation to properly classify vectors other than those used to design the network.
You might want to tryPNN Classification. It shows how to design a PNN, and how the network can successfully classify a vector not used in the design.