You are on page 1of 36

9.

Introduction to Neural Networks and Its Application to Control of SMAs

Part 1

Control of Smart Structures


Topic 9

Introduction to Neural Networks and Its Application to Control of SMAs

Part 1 Introduction to Neural Networks


Contribution from Mr. Ning Ma is greatly appreciated.
Dept. of Mechanical Engineering Instructor: Dr. Song

1 1

9. Introduction to Neural Networks and Its Application to Control of SMAs

Part 1

Outline
Introduction to neural networks. Application of neural networks in system identification and control. Implementation of neural networks using Matlab.

Dept. of Mechanical Engineering

Instructor: Dr. Song

2 2

9. Introduction to Neural Networks and Its Application to Control of SMAs

Part 1

Introduction to Neural Networks


What is neural networks? Why use neural networks? General architecture of neural networks. Models of a neuron. Connections. Learning of neural networks.

Dept. of Mechanical Engineering

Instructor: Dr. Song

3 3

9. Introduction to Neural Networks and Its Application to Control of SMAs

Part 1

What is Neural Networks


A neural network is a massively parallel distributed processor made of simple processing units, which has a natural propensity for storing experiential knowledge and making it available for use. It resembles the brain in two respects:
1. Knowledge is acquired by the network from its environment through a learning process. 2. Interneuron connection strengths, known as synaptic weights, are used to store the acquired knowledge.

This definition is adapted from Aleksander and Morton (1990)

Dept. of Mechanical Engineering

Instructor: Dr. Song

4 4

9. Introduction to Neural Networks and Its Application to Control of SMAs

Part 1

Why use neural networks


Nonlinear function mapping. Nonlinear function mapping of neural networks makes it possible to approximate the physical world which is inherently nonlinear. Learning and adaptation. Networks are trained using past data measured from the plant. A well-trained network then has the ability to generalize when presented with inputs not appearing in the training data. Networks have also a build-in capability to adapt their synaptic weights to changes. Parallel distributed processing. Networks have a highly parallel structure which lends itself to a higher degree of error tolerance than conventional schemes and fast computing. Multivariable systems. Neural Networks naturally process many inputs and have many outputs.

Dept. of Mechanical Engineering

Instructor: Dr. Song

5 5

9. Introduction to Neural Networks and Its Application to Control of SMAs

Part 1

General Architecture of Neural Networks


The neural network architecture is defined by the basic processing elements: neurons, and the way in which they are interconnected. In literature, there are several types of neural networks presented. Each type of neural networks is characterized by its architecture. Due to their various architectures, those types of neural networks show different performances for a certain application.

Dept. of Mechanical Engineering

Instructor: Dr. Song

6 6

9. Introduction to Neural Networks and Its Application to Control of SMAs

Part 1

Models of A Neuron (1)


Three basic elements of the neuron model: A set of connecting links; An adder for summing the input signals; An activation function.

Dept. of Mechanical Engineering

Instructor: Dr. Song

7 7

9. Introduction to Neural Networks and Its Application to Control of SMAs

Part 1

Models of A Neuron (2)


In mathematical view, the neuron may be described by following equations:

j=1

kj

and y k = (u

+ bk

Dept. of Mechanical Engineering

Instructor: Dr. Song

8 8

9. Introduction to Neural Networks and Its Application to Control of SMAs

Part 1

Models of A Neuron (3)


Three basic types of activation function:

Dept. of Mechanical Engineering

Instructor: Dr. Song

9 9

9. Introduction to Neural Networks and Its Application to Control of SMAs

Part 1

10

Connections
The neurons by themselves are not very powerful in terms of computation or representation. But, their interconnections allows us to encode relations between the variables giving different powerful processing capabilities. In general, three fundamental types of interconnections of neural networks are defined in literature : single-layer feedforward networks, multilayer feedforward networks and recurrent networks. There exist numerous neural network architectures, such as Hopfield nets, Boltzmann machine, etc.

Dept. of Mechanical Engineering

Instructor: Dr. Song

10 10

9. Introduction to Neural Networks and Its Application to Control of SMAs

Part 1

11

Single-Layer Feedforward Networks


This type of networks consists of a input layer of input nodes and a output layer of neurons

Dept. of Mechanical Engineering

Instructor: Dr. Song

11 11

9. Introduction to Neural Networks and Its Application to Control of SMAs

Part 1

12

Multilayer Feedforward Networks


The multilayer feedforward networks distinguish themselves by the presence of one or more hidden layers. In addition, the neurons in each layer have as their inputs the output signals of the preceding layer only.

Dept. of Mechanical Engineering

Instructor: Dr. Song

12 12

9. Introduction to Neural Networks and Its Application to Control of SMAs

Part 1

13

Recurrent Networks
The recurrent network distinguishes itself in that it has at lest one feedback loop. The feedback loop can be either self-feedback loop or global feedback loop.Moreover, the feedback loop and the unit-delay elements result in a nonlinear dynamical behavior of the network.

Dept. of Mechanical Engineering

Instructor: Dr. Song

13 13

9. Introduction to Neural Networks and Its Application to Control of SMAs

Part 1

14

Learning of Neural Networks


Learning is a process by which the free parameters of a neural network are adapted through a process of stimulation by the environment in which the network is embedded. The type of learning is determined by the manner in which the parameter changes take place. The learning process involves three events: The neural network is stimulated by the environment. The neural network undergoes changes in its free parameters. The neural network responds in a new way to the environment. In literature, there exist many learning algorithms. Learning algorithms can be classified into two main group: supervised learning and unsupervised learning.

Dept. of Mechanical Engineering

Instructor: Dr. Song

14 14

9. Introduction to Neural Networks and Its Application to Control of SMAs

Part 1

15

Back-Propagation Learning Algorithm


Back-Propagation (BP) learning algorithm is based on the error-correction learning. BP learning algorithm is the most efficient algorithm used in adapting Multilayer Feedforward Networks. BP learning consists of two passes through the different layers of the network: a forward pass and a backward pass. In the forward pass, the input is applied to the network, and its effect propagates through the layers. Finally, a set of outputs is produced as the actual response of the network. During this forward pass the synaptic weights of the network are fixed. During the backward pass, though, the synaptic weights are all adjusted in accordance with an error-correction rule. The actual response of the network is subtracted from the target response to generate the error signal. This error is then back-propagated through the network, against the direction of synaptic connections, and hence the term back-propagation.
15 15

Dept. of Mechanical Engineering

Instructor: Dr. Song

9. Introduction to Neural Networks and Its Application to Control of SMAs

Part 1

16

Application of neural networks in system identification and control.


Brief review of application of neural network in system identification and control. System identification using neural networks. Control themes using neural networks.

Dept. of Mechanical Engineering

Instructor: Dr. Song

16 16

9. Introduction to Neural Networks and Its Application to Control of SMAs

Part 1

17

Brief review of application of neural network in system identification and control.


The nonlinear mapping property of the neural network are central to its use in the system identification and control. The ability of the ANN to represent an arbitrary nonlinear relations is already established. It could be stated that any continuous function can be approximated by just a multilayer network, if there are a sufficient number of hidden neurons in the networks. For networks application in system identification and control, the key questions are how many hidden layers should be used and how many neurons are required in each layer.
Instructor: Dr. Song

Dept. of Mechanical Engineering

17 17

9. Introduction to Neural Networks and Its Application to Control of SMAs

Part 1

18

System Identification Using Neural Networks


Feedforward Modeling
d

+
U Plant yp

+ + _
error

Neural Netw ork Model

ym

Learning Algorithm

Dept. of Mechanical Engineering

Instructor: Dr. Song

18 18

9. Introduction to Neural Networks and Its Application to Control of SMAs

Part 1

19

System Identification Using Neural Networks


Inverse Modeling
Direct method
d

Neural Netw ork Inverse Model

ym

Plant

yp

_
error

Learning Algorithm

Dept. of Mechanical Engineering

Instructor: Dr. Song

19 19

9. Introduction to Neural Networks and Its Application to Control of SMAs

Part 1

20

System Identification Using Neural Networks


Inverse Modeling
Direct method
d

Conceptually the simplest approach is direct inverse training [Psaltis et al, 1988] as shown schematically in right figure. The output of the plant is used as input to the neural network. Then, the output of the network is compared with the plants input. The error is used to train the neural network. It is clear that the training procedure will force the network to represent the inverse model of the plant. However, this training method has two drawbacks. First, it is not goal directed [Jordan and Rumelhart, 1991]. Second, if the nonlinear system is not invertible, an incorrect inverse can be obtained.
Dept. of Mechanical Engineering Instructor: Dr. Song

Neural Netw ork Inverse Model

ym

Plant

yp

error Learning Algorithm

20 20

9. Introduction to Neural Networks and Its Application to Control of SMAs

Part 1

21

System Identification Using Neural Networks


Inverse Modeling
Specialized method (the NN Models output is used)
d

Neural Netw ork Inverse Model

Plant

yp

Learning Algorithm

Neural Netw ork Model

ym

error

Dept. of Mechanical Engineering

Instructor: Dr. Song

21 21

9. Introduction to Neural Networks and Its Application to Control of SMAs

Part 1

22

System Identification Using Neural Networks


Inverse Modeling
Specialized method
r d

The other approach to overcome these problems was known as specialized inverse learning [Psaltis et al, 1988], which is illustrated in right figure. In this approach, the network inverse model precedes the plant. The command signal is fed into this network and the output of the network will be sent to the plant, as well as an established network feedforward model parallel with the plant. The error signal for the training algorithm in this case is the difference between the output of the network feedforward model and the command signal. This approach trends to make unity transfer function from the command signal to the output of the plant.
Dept. of Mechanical Engineering Instructor: Dr. Song

Neural Netw ork Inverse Model

Plant

yp

Learning Algorithm

Neural Netw ork Model

ym

error

22 22

9. Introduction to Neural Networks and Its Application to Control of SMAs

Part 1

23

Control themes Using Neural Networks


Direct inverse control. Model reference control. Internal Model control. Predictive control.

Dept. of Mechanical Engineering

Instructor: Dr. Song

23 23

9. Introduction to Neural Networks and Its Application to Control of SMAs

Part 1

24

Direct Inverse Control


d

Neural Netw ork Inverse Model

Plant

yp

Dept. of Mechanical Engineering

Instructor: Dr. Song

24 24

9. Introduction to Neural Networks and Its Application to Control of SMAs

Part 1

25

Model Reference Control (MRC)

Represents desired performance

NN Controller

Dept. of Mechanical Engineering

Instructor: Dr. Song

25 25

9. Introduction to Neural Networks and Its Application to Control of SMAs

Part 1

26

Internal Model Control (IMC)

Linear Filter Inverse Model (NN Controller)

Plant

NN Plant Model

Limited to open-loop stable systems.

Dept. of Mechanical Engineering

Instructor: Dr. Song

26 26

9. Introduction to Neural Networks and Its Application to Control of SMAs

Part 1

27

Predictive Control
Iterative optimization

Iterative algorithm NN Plant Model (predict the plant future)

Optimal solution

NN Controller

Dept. of Mechanical Engineering

Instructor: Dr. Song

27 27

9. Introduction to Neural Networks and Its Application to Control of SMAs

Part 1

28

Implementation of Neural Networks Using Matlab


Introduction to fundamental commands and concepts in Matlab Neural Network Toolbox. Example: construct a Multilayer Feedforward Network.

Dept. of Mechanical Engineering

Instructor: Dr. Song

28 28

9. Introduction to Neural Networks and Its Application to Control of SMAs

Part 1

29

Introduction to fundamental functions and concepts in Matlab Neural Network Toolbox


A neural network is represented as an object in Matlab toolbox. Using Matlab, users can construct Feedforward Networks, Recurrent Networks, Radial Basis Networks, Competitive Neural Networks, etc. For different types of neural networks, Matlab provides corresponding functions to create and train the neural networks. Users can specify the weights, activation functions, learning algorithms, initial values and bias respectively. The following introduction and example are only applicable to Multilayer Feedforward Networks.

Dept. of Mechanical Engineering

Instructor: Dr. Song

29 29

9. Introduction to Neural Networks and Its Application to Control of SMAs

Part 1

30

Introduction to fundamental functions and concepts in Matlab Neural Network Toolbox(2)


newff(PR,[S1 S2...SNl],{TF1 TF2...TFNl},BTF,BLF,PF)
creates a new N layer feed-forward backpropagation network. PR - R x 2 matrix of min and max values for R input elements. Si - Size of ith layer, for Nl layers. TFi - Transfer function of ith layer, default is Hyperbolic tangent sigmoid transfer function. BTF - Backpropagation network training function, default is Gradient descent with momentum and adaptive learning rate backpropagation. BLF - Backpropagation weight/bias learning function, default is Gradient descent with momentum weight and bias learning function. PF - Performance function, default is Mean squared error performance function.

Dept. of Mechanical Engineering

Instructor: Dr. Song

30 30

9. Introduction to Neural Networks and Its Application to Control of SMAs

Part 1

31

Introduction to fundamental functions and concepts in Matlab Neural Network Toolbox(3)


train (NET,P,T,Pi,Ai,VV,TV)
net - Neural Network created by function newff(). P - Network inputs. T - Network targets, default = zeros. Pi - Initial input delay conditions, default = zeros. Ai - Initial layer delay conditions, default = zeros. VV - Structure of validation vectors, default = []. TV - Structure of test vectors, default = [].

Train function trains a network net according to net.trainFcn and net.trainParam. Before start of training, two parameters must be specified.
Net.trainparam.epochs: the upper limit of training iteration. Net.trainparam.goal: the value of performance function.
31 31

Dept. of Mechanical Engineering

Instructor: Dr. Song

9. Introduction to Neural Networks and Its Application to Control of SMAs

Part 1

32

Introduction to fundamental functions and concepts in Matlab Neural Network Toolbox(4)


sim(net,P,Pi,Ai,T)
Simulate the well-trained network net - Network. P - Network inputs. Pi - Initial input delay conditions, default = zeros. Ai - Initial layer delay conditions, default = zeros. T - Network targets, default = zeros. Return the output of the network.

gensim(net,st)
Generate Simulink block of the network. net - Neural network. st - Sample time (default = 1).

Dept. of Mechanical Engineering

Instructor: Dr. Song

32 32

9. Introduction to Neural Networks and Its Application to Control of SMAs

Part 1

33

Example: construct a Multilayer Feedforward Network.


The systems input and measured output are shown in the figures below. From these data, a Multilayer Feedforward Network is employed to model the unknown system.
the input signal 4 input signal magnitude 2 0 -2 -4

20

40

60

80

100 120 time the output signal

140

160

180

200

output signal magnitude

5 0 -5 -10 -15

20

40

60

80

100 time

120

140

160

180

200

Dept. of Mechanical Engineering

Instructor: Dr. Song

33 33

9. Introduction to Neural Networks and Its Application to Control of SMAs

Part 1

34

Example: construct a Multilayer Feedforward Network.


A Multilayer Feedforward Network was used to model the system. The network has one hidden layer in which there are eight neurons. The inputs of the network are current value of input to the system and previous value inputs to the system, because we consider this is a dynamic process.
U(k) U(k-1)

U(k-2)

Input Layer

Hidden Layer (8 cells)

Output Layer

Dept. of Mechanical Engineering

Instructor: Dr. Song

34 34

9. Introduction to Neural Networks and Its Application to Control of SMAs

Part 1

35

Matlab Code
%Using first 500 data to train the network U=u(1:500);U_delay1=[0 u(1:499)];U_delay2=[0 0 u(1:498)]; Y=y(1:500); %construct the input matrix to the network P=[U;U_delay1;U_delay2]; %define the feedforward neural network with two layers Netexample=newff([minmax(U);minmax(U_delay1);minmax(U_delay2)],[8 1],{'tansig' 'purelin'},'trainlm'); %set up the train parameters Netexample.trainparam.epochs=2000;Netexample.trainparam.goal=0.01; %train the network predictor=train(Netexample,P,Y); %test and verify the network using later 500 data U=u(501:999);U_delay1=u(500:998);U_delay2=u(499:997);P=[U;U_delay1;U_delay2]; NetOutput=sim(Netexample,P);

Dept. of Mechanical Engineering

Instructor: Dr. Song

35 35

9. Introduction to Neural Networks and Its Application to Control of SMAs

Part 1

36

Comparison of Networks output and systems output


5 the plot of the real output and Networks output 0

output/prediction

-5

-10

-15 Network output real output

-20

-25 500

550

600

650

700 750 800 time instant

850

900

950

1000

Dept. of Mechanical Engineering

Instructor: Dr. Song

36 36

You might also like