Neural Network Toolbox |
Training
Now train the network for 500 epochs. Either train
or adapt
can be used.
Note that train
for competitive networks uses the training function trainr
. You can verify this by executing the following code after creating the network.
Thus, during each epoch, a single vector is chosen randomly and presented to the network and weight and bias values are updated accordingly.
Next, supply the original vectors as input to the network, simulate the network, and finally convert its output vectors to class indices.
We see that the network is trained to classify the input vectors into two groups, those near the origin, class 1, and those near (1,1), class 2.
It might be interesting to look at the final weights and biases. They are
(You may get different answers if you run this problem, as a random seed is used to pick the order of the vectors presented to the network for training.) Note that the first vector (formed from the first row of the weight matrix) is near the input vectors close to (1,1), while the vector formed from the second row of the weight matrix is close to the input vectors near the origin. Thus, the network has been trained, just by exposing it to the inputs, to classify them.
During training each neuron in the layer closest to a group of input vectors adjusts its weight vector toward those input vectors. Eventually, if there are enough neurons, every cluster of similar input vectors has a neuron that outputs 1 when a vector in the cluster is presented, while outputting a 0 at all other times. Thus, the competitive network learns to categorize the input.
Bias Learning Rule (learncon) | Graphical Example |
© 1994-2005 The MathWorks, Inc.