Clustering and Classification
145
Example 7.7
In this example, we solve the OR gate problem using MATLAB. First, we define
a perceptron net as net = newp([0 1; −2 2],1). Next, we define the input
values P = [0 0 1 1; 0 1 0 1] and target values T = [0 1 1 1] and then
apply the “train” command to train the network with the specified input and target
(output) values. And finally, using “sim” command, we simulate the network and
compare the predicted output values generated by the trained network against the
true target values. The complete code has been shown as follows:
net= newp([0 1; −2 2],1);
P = [0 0 1 1; 0 1 0 1];
T = [0 1 1 1];
net = train(net, P,T);
Y = sim(net, P)
7.7.2 SIGMOID NEURAL NETWORKS
For a few decades, it was experimentally believed that single-layer neural networks
such as perceptron have certain limitations that prevent the use of these methods for
real-world problems. One such limitation was the observation made about the perceptron that such structures cannot separate patterns that are not linearly separable.
But after a few decades, multilayer sigmoid neural networks were proposed to solve
the problems of single-layer neural networks. Simply put, it turned out that with multiple layers of perceptrons and other types of neurons, any complex pattern, linear or
nonlinear, can be effectively classified. Figure 7.6 shows a multilayer backpropagation
neural network.
Y 1
Y k
Y m
Z p
Z l
Z 1
1
w o1
v o1
w l1
v l1
w l1
v l1
v n1
v o1
v l1
v l1
v n1
v op
v np
v lp
v lp
w ok
w lk
w lk
w nk
w om
w lm w lm w om
X n
X l
X 1
1
FIGURE 7.6 Typical multilayer sigmoid neural network with one hidden layer.
145
Example 7.7
In this example, we solve the OR gate problem using MATLAB. First, we define
a perceptron net as net = newp([0 1; −2 2],1). Next, we define the input
values P = [0 0 1 1; 0 1 0 1] and target values T = [0 1 1 1] and then
apply the “train” command to train the network with the specified input and target
(output) values. And finally, using “sim” command, we simulate the network and
compare the predicted output values generated by the trained network against the
true target values. The complete code has been shown as follows:
net= newp([0 1; −2 2],1);
P = [0 0 1 1; 0 1 0 1];
T = [0 1 1 1];
net = train(net, P,T);
Y = sim(net, P)
7.7.2 SIGMOID NEURAL NETWORKS
For a few decades, it was experimentally believed that single-layer neural networks
such as perceptron have certain limitations that prevent the use of these methods for
real-world problems. One such limitation was the observation made about the perceptron that such structures cannot separate patterns that are not linearly separable.
But after a few decades, multilayer sigmoid neural networks were proposed to solve
the problems of single-layer neural networks. Simply put, it turned out that with multiple layers of perceptrons and other types of neurons, any complex pattern, linear or
nonlinear, can be effectively classified. Figure 7.6 shows a multilayer backpropagation
neural network.
Y 1
Y k
Y m
Z p
Z l
Z 1
1
w o1
v o1
w l1
v l1
w l1
v l1
v n1
v o1
v l1
v l1
v n1
v op
v np
v lp
v lp
w ok
w lk
w lk
w nk
w om
w lm w lm w om
X n
X l
X 1
1
FIGURE 7.6 Typical multilayer sigmoid neural network with one hidden layer.
