modelleerimine ja juhtimine tehisnärvivõrgudega identification and control with artificial neural...

12
Modelleerimine ja Juhtimine Tehisnärvivõrgudega Identification and Control with artificial neural networks (2nd part) Eduard Petlenkov, Automaatikainstituut uard Petlenkov, Automaatikainstituut, 2014

Upload: samuel-powell

Post on 31-Dec-2015

215 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Modelleerimine ja Juhtimine Tehisnärvivõrgudega Identification and Control with artificial neural networks (2nd part) Eduard Petlenkov, Automaatikainstituut

Modelleerimine ja Juhtimine Tehisnärvivõrgudega

Identification and Control with artificial neural

networks(2nd part)

Eduard Petlenkov, Automaatikainstituut

Eduard Petlenkov, Automaatikainstituut, 2014

Page 2: Modelleerimine ja Juhtimine Tehisnärvivõrgudega Identification and Control with artificial neural networks (2nd part) Eduard Petlenkov, Automaatikainstituut

Supervised learning

Eduard Petlenkov, Automaatikainstituut, 2014

Supervised learning is a training algorithm based on known input-output data.

0)( YYXNNY pp

X is an input vector;

Yp is a vector of reference outputs corresponding to input vector X

Y is a vector of NN’s outputs corresponding to input vector X NN is a mathematica function of the network (Y=NN(X))

Page 3: Modelleerimine ja Juhtimine Tehisnärvivõrgudega Identification and Control with artificial neural networks (2nd part) Eduard Petlenkov, Automaatikainstituut

Õpetamine (2)

Eduard Petlenkov, Automaatikainstituut, 2014

Network training procedure consists of the following 3 steps:

1. Computation of NN’s outputs corresponding to the current NN’s paraneters;

2. Computation of NN’s error;3. Updating NN’s parameters by using selected

training algorithm in order to minimize the error.

Page 4: Modelleerimine ja Juhtimine Tehisnärvivõrgudega Identification and Control with artificial neural networks (2nd part) Eduard Petlenkov, Automaatikainstituut

Gradient descent error backpropagation (1)

Eduard Petlenkov, Automaatikainstituut, 2014

k

dpp YYWJ 2)(),(Error function:

pY - NN’s output

),,( WXNNY pp

pX - inputs used for training;

NN- NN’s function; dpY - etalons (references) for outputs=desired outputs.

function to be minimized:

),(min WJ

Page 5: Modelleerimine ja Juhtimine Tehisnärvivõrgudega Identification and Control with artificial neural networks (2nd part) Eduard Petlenkov, Automaatikainstituut

Gradient descent error backpropagation (2)

Eduard Petlenkov, Automaatikainstituut, 2014

),( 1 nxxF

21

1 ),(x

F

x

FxxF n

21

1 ),(x

F

x

FxxF n

),( WJ

J

W

JWJ ),(

Page 6: Modelleerimine ja Juhtimine Tehisnärvivõrgudega Identification and Control with artificial neural networks (2nd part) Eduard Petlenkov, Automaatikainstituut

Global minimum problem

Eduard Petlenkov, Automaatikainstituut, 2014

Page 7: Modelleerimine ja Juhtimine Tehisnärvivõrgudega Identification and Control with artificial neural networks (2nd part) Eduard Petlenkov, Automaatikainstituut

Training of a double-layer perceptron using Gradient descent error backpropagation (1)

Eduard Petlenkov, Automaatikainstituut, 2014

))()()(()( 1 tBhtxtWhFtyh ji

ijij ))()()(()( 2 tBotyhtWoFty ki

ikjk i - number of input;

j – number of neuron in the hidden layer;k – number of output neuron;

)(tx i)(tWh ji)(tBh j

NN’s input at time instance t;t

;

1F)(tyh j)(tWo kj

)(tBok

2F)(tyk

- Values oh the hidden layer biases at time instance t;

- Values oh the hidden layer weighting coefficients at time instance t;

- Activation function of the hidden layer neurons

- Outputs of the output layer neurons at time instance t; - Values oh the output layer weighting coefficients at time instance t;- Values oh the output layer biases at time instance t;- Activation function of the output layer neurons; - Outputs of the network at time instance t;

Page 8: Modelleerimine ja Juhtimine Tehisnärvivõrgudega Identification and Control with artificial neural networks (2nd part) Eduard Petlenkov, Automaatikainstituut

Eduard Petlenkov, Automaatikainstituut, 2014

)()()( tytyte etalonerror:

gradients: )()( txtW

Jij

ij

)()( tyhtW

Jjk

kj

),(tj )(tkSignals distributing information about error from output layer to previous layers (that is why the method is called error backpropagation):

2))()(()( Ftytyt dkkk

k

kjkj tWotFt )()()( 1

,1F 2F Are derivatives of the corresponding layers activation functions.

Training of a double-layer perceptron using Gradient descent error backpropagation (2)

Page 9: Modelleerimine ja Juhtimine Tehisnärvivõrgudega Identification and Control with artificial neural networks (2nd part) Eduard Petlenkov, Automaatikainstituut

Eduard Petlenkov, Automaatikainstituut, 2014

Updated weighting coefficients:

)()()()()1( tyhttWoWo

JtWotWo jkkj

kjkjkj

)()()()()1( txttWhWh

JtWhtWh ijji

jijiji

learning rate

)()(1

1

1

1

1)('

1

1)( 2

22 xfxfeee

exf

exf

xxx

x

x

Training of a double-layer perceptron using Gradient descent error backpropagation (3)

Page 10: Modelleerimine ja Juhtimine Tehisnärvivõrgudega Identification and Control with artificial neural networks (2nd part) Eduard Petlenkov, Automaatikainstituut

Gradient Descent (GD) method vs Levenberg-Marquardt (LM) method

NttytuZn ,,1,,

N

t

N

tN te

Ntyty

NZJ

1

2

1

2 ,2

2

1,

,

,1,

1

tete

N

ZJG

N

t

N

- Gradient

N

tT

R

N

t

T

TN te

te

N

tete

N

ZJH

1

2

1

2

,,1,,1,

- Hessian

GD: LM: Gkk 1 kkk 1

kkGkIkR

Eduard Petlenkov, Automaatikainstituut, 2014

Page 11: Modelleerimine ja Juhtimine Tehisnärvivõrgudega Identification and Control with artificial neural networks (2nd part) Eduard Petlenkov, Automaatikainstituut

Näide MATLABis (1)

P1=(rand(1,100)-0.5)*20 % Juhuslikud sisendid. 100 väärtust vahemikus [-10 +10]

P2=(rand(1,100)-0.5)*20

P=[P1;P2] % Närvivõrgu sisendite moodustamine

T=0.3*P1+0.9*P2 % Vastavate väljundite arvutamine

net=newff([-10 10;-10 10],[5 1],{'purelin' 'purelin'},'traingd') % Närvivõrgu genereerimine

esimene sisend[min max]

teinesisend[min max]

neuronite arvud igas kihis

Viimase kihi neuronite arv = väljundite arv

Esimese kihi neuronite aktiveerimisfunktsioon

Teise kihi neuronite aktiveerimisfunktsioon

õppimisalgoritm

net.trainParam.show=1;

net.trainParam.epochs=100;Treenimise parameetrid

Page 12: Modelleerimine ja Juhtimine Tehisnärvivõrgudega Identification and Control with artificial neural networks (2nd part) Eduard Petlenkov, Automaatikainstituut

net=train(net,P,T) % Närvivõrgu treenimine

out=sim(net,[3 -2]) % Närvivõrgu simuleerimine

Esimese sisendi väärtus

Teise sisendi väärtus

W1=net.IW{1,1} % esimese kihi kaalukoefitsientide maatriks

W2=net.LW{2,1} % teise kihi kaalukoefitsientide maatriks

B1=net.b{1} % esimese kihi neuronite nihete vektor

B2=net.b{2} % teise kihi neuronite nihete vektor

Näide MATLABis (2)

Eduard Petlenkov, Automaatikainstituut, 2014