Neural Network Toolbox |
Adaptive Filter Example
First we will define a new linear network using newlin
.
Assume that the input values have a range from 0 to 10. We can now define our single output network.
We can specify the delays in the tapped delay line with
This says that the delay line is connected to the network weight matrix through delays of 0, 1, and 2 time units. (You can specify as many delays as you want, and can omit some values if you like. They must be in ascending order.)
We can give the various weights and the bias values with
Finally we will define the initial values of the outputs of the delays as
Note that these are ordered from left to right to correspond to the delays taken from top to bottom in the figure. This concludes the setup of the network. Now how about the input?
We assume that the input scalars arrive in a sequence, first the value 3, then the value 4, next the value 5, and finally the value 6. We can indicate this sequence by defining the values as elements of a cell array. (Note the curly brackets.)
Now we have a network and a sequence of inputs. We can simulate the network to see what its output is as a function of time.
This yields an output sequence
and final values for the delay outputs of
The example is sufficiently simple that you can check it by hand to make sure that you understand the inputs, initial values of the delays, etc.
The network that we have defined can be trained with the function adapt
to produce a particular output sequence. Suppose, for instance, we would like the network to produce the sequence of values 10, 20, 30, and 40.
We can train our defined network to do this, starting from the initial delay conditions that we used above. We specify 10 passes through the input sequence with
Then we can do the training with
This code returns the final weights, bias, and output sequence shown below.
wts = net.IW{1,1} wts = 0.5059 3.1053 5.7046 bias = net.b{1} bias = -1.5993 y = [11.8558] [20.7735] [29.6679] [39.0036]
Presumably, if we ran for additional passes the output sequence would have been even closer to the desired values of 10, 20, 30, and 40.
Thus, adaptive networks can be specified, simulated, and finally trained with adapt
. However, the outstanding value of adaptive networks lies in their use to perform a particular function, such as or prediction or noise cancellation.
Adaptive Filter | Prediction Example |
© 1994-2005 The MathWorks, Inc.