You are on page 1of 73

Fuzzy-Neural Networks for

Modeling and Intelligent Control

Antonio Moran, Ph.D.


amoran@ieee.org
The Brain
Behaves as a System with
Inputs and Outputs

Outputs
Inputs

Brain
Face Recognition

Mary, Peter
Face Recognition

Mary

Brain Mary
Car Driving

Present Position
Desired Position

Steering Angle
Acceleration
Car Driving
A Control Problem

Desired
Position Handling Present
Position
Driver Car
Accel
Artificial Neural Network Model
A Natural Neural Network

Multilayer Neural Network Model


Neural Networks

x1 y1
x2 y2

y = (x)
Face Recognition

Mary

Brain Mary

y = (x)
Function Estimation
y

x
y = ax + b

x
y = ax2 + bx + c
Function Estimation
y
y = ax + b
x

J = 0.5 (y1-y1)2 + 0.5 (y2-y2)2 + .. + 0.5 (yN-yN)2

Problem: Find a and b that minimize J


Training of Neural Network
v11 w11
Data
x1 y1
x1 x2 y1 y2
y2
* * * * x2
* * * * v23 w32
* * * *

Cost function to be minimized:


J = 0.5 (y(1)-y(1))T(y(1)-y(1)) + .. + 0.5 (y(N)-y(N))T (y(N)-y(N))
y(k) = [ y1(k) y2(k) ]T

Problem: Find vij and wjk that minimize J


Face Recognition

Neural network for


recognizing 10 faces
Neural Network for Face
Recognition
vij wjk

:
Input : Output
:
:

Input: Face
Output: Code for each face
Face Recognition
Reducing the size of images - Pixeling

Monocromatic
40 x 30
Gray Scale
1200 pixels
1826 x 1529
The face occupies the
Full Color most of the image
2808 x 2425
Neural Network for Face Recognition
Image Preprocessing - Pixeling

1213x1013 2644x2106 2854x2370 2446x2016 2507x2190

40x30 40x30 40x30 40x30 40x30


Face Recognition
Network Input

00000000000000000000
00000000011000000000
00000000111100000000
00000011111110000000
: : : : :
Matrix 40x30 : : : : :
00001011111110010000
00001000000000110000
00000000000000000000

The matrix should be transformed


into vector
Face Recognition
Network Input: Converting 40x30 matrix
into 1200x1 vector
0
0
00000000011000000000 0
00000000111100000000 0
00000011111110000000 :
: : : : : 1
0
00001011111110010000 1
00001000000000110000 0
00000000000000000000
:
40x30 1
0
0
0 1200x1
Face Recognition
Network Output
A code assigned to each of the ten faces
(Orthogonal codes)

1000000000

0100000000 0000000010

0010000000 0000000001
Neural Network for Face Recognition

vij wjk

:
1200 : 10
Inputs Outputs
:
:

To generate input-output training data, several faces


of a person could be considered but all of them with
the same output code
Neural Network for Face Recognition

vij wjk
:
1200 10
Inputs
: Outputs
: :

Training: Five faces of the same person


Validation after training: Different faces of each person
Validacin de la Red Neuronal

Cara de Cara de
entrenamiento validacin
0 0.1
0 0.1
1 0.9
0 0.1
0 0.3
0 0.1
0 0.2
0 0.1
0 0.3
0 0.1
Detection of Cardiac Anomalies

Normal

Anomaly 1

Anomaly 2

Anomaly 3
Training of Neural Network

600 samples in a period

1 0 0 0
600 0 1 0 0
Inputs 0 0 1 0
0 0 0 1

4 Outputs
Validation with Noisy Signals
Dynamic Neural Networks
Modeling of Dynamical Systems
Modeling of Dynamical Systems

Static System Dynamic System

xk uk xk+1
uk
System System
xk

xk = (uk)
xk+1 = (xk,uk)

Output becomes input in the


next step
Modeling of Dynamical Systems
Input u vij wjk
u uk
xk+1
xk

t
Desired Ouput x xk+1 = (xk,uk)
x
x0 , u0 x1
x1 , u1 x2
x2 , u2 x3
t
: :
xN , uN xN
Modeling of Dynamical Systems
vij wjk
u(k) x1(k+1)
x2(k) x2(k+1)

xk+1 = (xk,uk)
Modeling of Dynamical Systems
u1 vij
Input u= u wjk
2 uk
u1 u2 xk+1
xk

t t
xk+1 = (xk,uk)
Desired Ouput x = x1
x 2
x1 x2

t t
Training of Dynamical Neural Networks
vij wjk
uk
xk+1

xk

Cost Function to be Minimized

J = 0.5 (x1-x1)2 + 0.5 (x2-x2)2 + .. + 0.5 (xN-xN)2

k=N

S
xk Estado (Salida) de la red
J = 0.5 (x k- xk)2
k=1 xk Salida deseada (data)
Training of Dynamical Neural Networks
vij wjk
uk
xk+1

xk

x1
If x is a vector x= x
2

Cost Function to be Minimized


k=N
J = 0.5 S
k=1
(x k- xk)T (xk - xk)
Training of Dynamical Neural Networks
vij wjk
uk
xk+1

xk

Cost Function to be Minimized


J = 0.5 (x1-x1)2 + 0.5 (x2-x2)2 + .. + 0.5 (xN-xN)2

vij = vij - h J
vij Total partial
derivatives
wjk = wjk - h J
wjk
Training of Dynamical Neural Networks
vij wjk
uk
xk+1

xk

k=N
Cost Function to be Minimized J = 0.5 S
k=1
(x k - x k) T (x - x )
k k

k=N
J
v
= S
k=1
(x k- xk)T xk
v Total partial
k=N derivative of xk
J
w
= S
k=1
(x k - x k) T xk
w
Training of Dynamic Neural Networks
vij wjk
uk
xk+1

xk

Unfolding the Network Along Time


u0 u1 u2
vij u99
wjk vij vij vij
wjk wjk wjk

x0 x1 x2
.
x3 x99 x100
Training of Dynamical Neural Networks
vij = vij - h J
vij Total partial
derivatives
wjk = wjk - h J
wjk

Simple Derivative
z = 3y + 2x
z z
= = 2
y = 4x + 5r x x

r = 2x + 6s Total Derivative
z z z y z y r
= + +
x x y x y r x
Training of Dynamical Neural Networks
Computation of Total Partial Derivatives

Back Propagation Through Time BPTT


Paul Werbos, 1972

Dynamic Back Propagation DBP


Kumpati Narendra, 1989
Dynamic Back Propagation

u0 u1 u2
vij u99
wjk vij vij vij
wjk wjk wjk

x0 x1 x2
.
x3 x99 x100

x1 x1
=
v v

x2 x2 x2 x1
= +
v v x1 v

x3 x3 x3 x2
= +
v v x2 v
Dynamic Back Propagation

u0 u1 u2
vij u99
wjk vij vij vij
wjk wjk wjk

x0 x1 x2
.
x3 x99 x100

xk+1 xk+1 xk+1 xk


= +
v v xk v

Recursive expression for computation


of total partial derivatives
Modeling of Nonlinear Dynamic System
One Input and Two Outputs
Network Training
Output State Variable x1

0.5
Output
Input Signal u 0.4 Signal x1
0.3

0.2
Input Signal u
0.1

1 0
0.8 -0.1
0.6 -0.2
0.4 -0.3
0.2 -0.4
0 -0.5
-0.2
0 1 2 3 4 5 6 7
-0.4 Time [sec]
-0.6

-0.8

-1 Output State Variable x2


1
Output
0 1 2 3 4 5 6 7 0.8
Time [sec]
0.6
Signal x2
0.4

0.2

-0.2

Training Signal -0.4

-0.6

Model Output -0.8

-1
0 1 2 3 4 5 6 7
Time [sec]
Modeling of Nonlinear Dynamic System
Validation: Input-Output Signals

Output State Variable x1


Output
Input Signal u 0.5
Signal x1
0.4

Input Signal u 0.3

0.2
1
0.1
0.8 0
0.6 -0.1
0.4 -0.2

0.2 -0.3

0 -0.4

-0.2 -0.5

-0.4 0 1 2 3 4 5 6 7
Time [sec]
-0.6

-0.8
Output State Variable x2
-1 1

0 1 2 3 4 5 6 7
0.8 Output
Time [sec] 0.6
Signal x2
0.4

0.2

-0.2

Training Signal -0.4

-0.6
Model Output -0.8

-1
0 1 2 3 4 5 6 7
Time [sec]
Modeling of Nonlinear Dynamic System

Matlab Simulation

Dynamical system with 1 input and 3 outputs

uk xk+1 x1
System x= x
xk 2
x3

Nonlinear system
xk = Axk + Buk + Gxkuk
Dynamic Neural Networks
Control of Dynamical Systems
Car Driving
A Control Problem

Desired
Position Handling Present
Position
Driver Car
Accel
Control of Dynamical Sytems

Stabilization
xk uk xk+1
Controller System

uk = W(xk)

Tracking
rk uk xk+1
Controller System
xk
uk = W(xk, rk)
Control of Dynamical Sytems
Stabilization

Controller
xk uk xk+1
System

Controller System
uk = W(xk) xk+1 = (xk,uk)
Represented by:
Neural Network
State Equation
Training of Neuro-Controller

v w v w v w
x0 u0 x1 u1 x2 u2
System System
x3
System

x0 x1 x2

x1
If x is a vector x= x
2

Cost Function to be Minimized


k=N
J = 0.5 S
k=1
(x k- xk)T (xk - xk)
Training of Neuro-Controller

v w v w v w
x0 u0 x1 u1 x2 u2
System System
x3
System

x0 x1 x2

Cost Function to be Minimized

J = 0.5 (x1-x1)2 + 0.5 (x2-x2)2 + .. + 0.5 (xN-xN)2

k=N
xk Estado (Salida)
J = 0.5 S
k=1
(x k - x k) 2
xk Salida deseada
Training of Neuro-Controller

v w v w v w
x0 u0 x1 u1 x2 u2
System System
x3
System

Cost Function to be Minimized


J = 0.5 (x1-x1)2 + 0.5 (x2-x2)2 + .. + 0.5 (xN-xN)2

vij = vij - h J
vij Total partial
derivatives
wjk = wjk - h J
wjk
Training of Neuro-Controller

v w v w v w
x0 u0 x1 u1 x2 u2
System System
x3
System

k=N
Cost Function to be Minimized J = 0.5 S
k=1
(x k- xk)T (xk - xk)
k=N
J
v
= S
k=1
(x k- xk)T xk
v
Total partial
k=N derivative of xk
J
w
= S
k=1
(x k - x k) T xk
w
Dynamic Back Propagation

v w v w v w
x0 u0 x1 u1 x2 u2
System System
x3
System

xk+1
v
=
xk+1
uk
uk
v
+ ( xk+1
xk
+
xk+1
uk
uk
xk
) xk
v

Recursive expression for computation


of total partial derivatives
Dynamic Back Propagation

v w v w v w
x0 u0 x1 u1 x2 u2
System System
x3
System

xk+1
v
=
xk+1
uk
uk
v
+ ( xk+1
xk
+
xk+1
uk
uk
xk
) xk
v

Computed with the Computed with the


system model neural network
Positioning of Mobile Robots
Mobile Robot Following a Road
Control Problem
Y f*
y*

How to compute
steer angle d

yo

xo x* X

xo x* = 50
Initial yo d y* = 100 Desired
Position Position
fo f* = p/2
Robot Model

Front d
Wheels d x
Robot y
f f
L

y
Rear x(k+1) = x(k) + vDt cos(f(k))
Wheels
y(k+1) = y(k) + vDt sen(f(k))
x
f(k+1) = f(k) vDt /L tan(d(k))
Backward motion
Constant speed
No slipping No skidding
Positioning of Mobile Robot
Control Structure

Driver
x*
x
y* d Mobile y
f* Robot f
Positioning of Mobile Robot
Control Structure

Driver
x* x
-+ d Mobile y
f* Robot f
-+

Given problem characteristics,


coordinate y is not used for control
Dynamic Back Propagation

Robot Model
x(k+1) = x(k) + vDt cos(f(k)) x(k)
xk = uk = tan(d(k))
f(k)
f(k+1) = f(k) vDt /L tan(d(k))

xk+1
v
=
xk+1
uk
uk
v
+ ( xk+1
xk
+
xk+1
uk
uk
xk
) xk
v

xk+1 1 -vDt sin(f(k))


=
xk 0 1
Computed with the
system model xk+1 0
=
uk vDt/L
Incremental Learning

Y f* Train the neural network for


y* positions close to x*=0 (four
positions)
x = -2 -2 2 2
f = -p/2 p/2 -p/2 p/2

yo
Train the neural network for
xo x*=0 X
far away positions
x = -4 -4 4 4
f = -p/2 p/2 -p/2 p/2

x = -6 -6 6 6
f = -p/2 p/2 -p/2 p/2
Trajectories of Mobile Robot to Achieve
a Final Desired Position
Trajectories of Mobile Robot to Achieve
a Final Desired Position
Trajectories of Mobile Robot to Follow a Road
Fuzzy Neural Network

Integrates:
Knowledge IF -THEN Rules (Fuzzy)
Data Training (Neural Network)
Experimental Mobile Robot
Control of a Truck-Trailer Mobile Robot

Rear
wheels

Traction
wheels Trailer

Truck
Steering
wheels
Control of a Truck-Trailer Mobile Robot

Obstacle

Initial Position
Initial
Position
Desired
Final
Position

Position

Obstacle
Incremental Learning

Traction
wheels

Close to the desired position Steering


Away from the desired position wheels

Rear
wheels

Traction
wheels

Steering
wheels
Control of a Truck-Trailer Mobile Robot

Trailer (L 2)

q12 q2

q1

Truck (L 1)

X Axis
Control of a Truck-Trailer Mobile Robot

Achieving a Goal Position Following a Straight Line

Initial Desired
Position Position

Initial
Position
Control of a Truck-Trailer Mobile Robot

Following a Curved Path Following a Sinusoidal Path

Initial
Position
Thank you for your
attention!

Antonio Moran, Ph.D.


amoran@ieee.org

You might also like