7/22/2019 Materi Anfis
1/33
7/22/2019 Materi Anfis
2/33
Summary
Introduction
ANFIS Architecture Hybrid Learning Algorithm
ANFIS as a Universal Approximatior
Simulation Examples
Lo ica Nebulosa . 2/
7/22/2019 Materi Anfis
3/33
Introduction
ANFIS: Artificial Neuro-Fuzzy Inference Systems
ANFIS are a class of adaptive networks that arefuncionally equivalent to fuzzy inference systems.
ANFIS represent Sugeno e Tsukamoto fuzzy
models. ANFIS uses a hybrid learning algorithm
Lo ica Nebulosa . 3/
7/22/2019 Materi Anfis
4/33
Sugeno Model
Assume that the fuzzy inference system has two
inputs xandy and one output z. A first-order Sugeno fuzzy model has rules as the
following:
Rule1:If xis A1 andy is B1, then f1=p1x+q1y+r1
Rule2:
If xis A2 andy is B2, then f2=p2x+q2y+r2
Lo ica Nebulosa . 4/
7/22/2019 Materi Anfis
5/33
Sugeno Model - I
x
X
A1
A2
y
X
B1
B2
W1
W2
f1=p1x+q1y+r1 f2=p2x+q2y+r2 f=w1.f1+w2.f2
w1+w2
Y
Y
Lo ica Nebulosa . 5/
7/22/2019 Materi Anfis
6/33
ANFIS Architecture
A1
A2
x
y
B1
B2
Prod
Prod
Norm
Norm
Layer1 Layer2 Layer3
W1
W2
x y
x y
Sum
W1f1
W1f2
f
Layer4 Layer5
Lo ica Nebulosa . 6/
7/22/2019 Materi Anfis
7/33
Layer 1 - I
Ol,i is the output of the ith node of the layer l.
Every node iin this layer is an adaptive node witha node functionO1,i=Ai(x)fori= 1, 2,or
O1,i=Bi2(x)fori= 3, 4 x(ory) is the input node iandAi (or Bi2) is a
linguistic label associated with this node
Therefore O1,i is the membership grade of a fuzzyset(A1, A2, B1, B2).
Lo ica Nebulosa . 7/
7/22/2019 Materi Anfis
8/33
Layer 1 - II
Typical membership function:
A(x) = 1
1 +|xciai |2bi
ai, bi, ci is the parameter set. Parameters are referred to as premise parameters.
Lo ica Nebulosa . 8/
7/22/2019 Materi Anfis
9/33
Layer 2
Every node in this layer is a fixed node labeled
Prod. The output is the product of all the incoming
signals.
O2,i=wi=Ai(x)Bi(y), i= 1, 2 Each node represents the fire strength of the rule
Any other T-norm operator that perform the AN Doperator can be used
Lo ica Nebulosa . 9/
7/22/2019 Materi Anfis
10/33
Layer 3
Every node in this layer is a fixed node labeled
Norm. Theith node calculates the ratio of the ith rulets
firing strenght to the sum of all rulets firing
strengths. O3,i=wi =
wiw1+w2
, i= 1, 2
Outputs are called normalized firing strengths.
Lo ica Nebulosa . 10/
7/22/2019 Materi Anfis
11/33
Layer 4
Every node iin this layer is an adaptive node with
a node function:O4,1=wifi=wi(px+qiy+ri)
wi is the normalized firing strenght from layer 3. {pi, qi, ri}is the parameter set of this node.
These are referred to as consequent parameters.
Lo ica Nebulosa . 11/
7/22/2019 Materi Anfis
12/33
Layer 5
The single node in this layer is a fixed node
labeledsum, which computes the overall output asthe summation of all incoming signals:
overall output=O5,1=
iwifi=
iwifiiwi
Lo ica Nebulosa . 12/
7/22/2019 Materi Anfis
13/33
Alternative Structures
There are other structures
A1
A2
x
y
B1
B2
Prod
Prod
Layer1 Layer2 Layer3
W1
W2
x y
x y
Sum
W1f1
W1f2
f
Layer4 Layer5
W1f1+W2f2
/
Sum
Lo ica Nebulosa . 13/
7/22/2019 Materi Anfis
14/33
Learning Algorithm
Lo ica Nebulosa . 14/
7/22/2019 Materi Anfis
15/33
Hybrid Learning Algorithm - I
The ANFIS can be trained by a hybrid learning
algorithm presented by Jang in the chapter 8 ofthe book.
In the forward pass the algorithm uses
least-squares method to identify the consequentparameters on the layer 4.
In the backward pass the errors are propagated
backward and the premise parameters areupdated by gradient descent.
Lo ica Nebulosa . 15/
7/22/2019 Materi Anfis
16/33
Hybrid Learning Algorithm - II
Forward Pass Backward PassPremise Parameters Fixed Gradient Descent
Consequent Parameters Least-squares estimator Fixed
Signals Node outputs Error signals
Two passes in the hybrid learning algorithm for ANFIS.
Lo ica Nebulosa . 16/
7/22/2019 Materi Anfis
17/33
Universal Aproximator
Lo ica Nebulosa . 17/
7/22/2019 Materi Anfis
18/33
ANFIS is a Universal Aproximator
When the number of rules is not restricted, a
zero-order Sugeno model has unlimitedapproximation power for matching any nonlinearfunction arbitrarily well on a compact set.
This can be proved using the Stone-Weierstrasstheorem.
LetDbe a compact space of Ndimensions, andlet Fbe a set of continuous real-valued functionsonDsatisfying the following criteria:
Lo ica Nebulosa . 18/
7/22/2019 Materi Anfis
19/33
Stone-Weierstrauss theorem - I
LetDbe a compact space of Ndimensions, and
let Fbe a set of continuous real-valued functionsonDsatisfying the following criteria:
Indentity function: The constant f(x) = 1is in F.
Separability: For any two points x1=x2 inD, there is anf inFsuch that f(x1)=f(x2).
Algebraic closure: Iffandg are any two functions in F,then f g andaf+bg are in Ffor any two realnumbers aandb.
Lo ica Nebulosa . 19/
7/22/2019 Materi Anfis
20/33
Stone-Weierstrauss theorem - II
Then Fis dense on C(D), the set of continuous
real-valued functions onD. For any >0and any function g inC(D), there is a
function f inFsuch that|g(x)f(x)|< for allx
D.
The ANFIS satisfies all these requirements.
Lo ica Nebulosa . 20/
7/22/2019 Materi Anfis
21/33
Anfis and Matlab
Lo ica Nebulosa . 21/
7/22/2019 Materi Anfis
22/33
Matlab
It is possible to use a graphics user interface
Command anfisedit.
It is possible to use the command line interface orm-file programs.
There are functions to generate, train, test and use
these systems.
Lo ica Nebulosa . 22/
7/22/2019 Materi Anfis
23/33
ANFIS gui
Lo ica Nebulosa . 23/
7/22/2019 Materi Anfis
24/33
Applying
Initializing
Training Testing
Using
Lo ica Nebulosa . 24/
7/22/2019 Materi Anfis
25/33
Initializing - GENFIS1 - 1
FIS = GENFIS1(DATA)generates asingle-output Sugeno-type fuzzy inference system(FIS) using a grid partition on the data (noclustering).
FISis used to provide initial conditions forposterior ANFIS training.
DATAis a matrix with N+1 columns where the firstN columns contain data for each FISinput, andthe last column contains the output data.
Lo ica Nebulosa . 25/
7/22/2019 Materi Anfis
26/33
Initializing - GENFIS1 - 2
By default GENFIS1uses two gbellmftypemembership functions for each input.
Each rule generated has one output membershipfunction, which is of type linear by default.
It is possible to define these parameters usingFIS = GENFIS1(DATA, NUMMFS, INPUTMF,
OUTPUTMF)
fis = genfis1(data, [3 7],char(pimf, trimf));
Lo ica Nebulosa . 26/
7/22/2019 Materi Anfis
27/33
Initializing - GENFIS1 - 3
data = [rand(10,1) 10*rand(10,1)-5 rand(10,1)];
fis = genfis1(data, [3 7], char(pimf,trimf));
[x,mf] = plotmf(fis,input,1);
subplot(2,1,1), plot(x,mf);
xlabel(input 1 (pimf));
[x,mf] = plotmf(fis,input,2);subplot(2,1,2), plot(x,mf);
xlabel(input 2 (trimf));
Lo ica Nebulosa . 27/
7/22/2019 Materi Anfis
28/33
Initializing - GENFIS1 - 4
0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10
0.2
0.4
0.6
0.8
1
input 1 (pimf)
2 1 0 1 2 3 40
0.2
0.4
0.6
0.8
1
input 2 (trimf)
Lo ica Nebulosa . 28/
7/22/2019 Materi Anfis
29/33
Initializing - GENFIS2
GENFIS2generates a Sugeno-type FIS usingsubtractive clustering.
GENFIS2extracts a set of rules that models thedata behavior.
The rule extraction method first determines thenumber of rules and antecedent membershipfunctions and then uses linear least squaresestimation to determine each rules consequentequations.
Lo ica Nebulosa . 29/
7/22/2019 Materi Anfis
30/33
Training
ANFISuses a hybrid learning algorithm to identifythe membership function parameters ofsingle-output, Sugeno type fuzzy inferencesystems (FIS).
There are many ways of using this function.
Some examples: [FIS,ERROR] = ANFIS(TRNDATA)
[FIS,ERROR] =ANFIS(TRNDATA,INITFIS)
Lo ica Nebulosa . 30/
7/22/2019 Materi Anfis
31/33
Using
EVALFISevaluates a fuzzy inference system.
Y = EVALFIS(U,FIS)simulates the FuzzyInference System FIS for the input data U andreturns the output data Y.
Lo ica Nebulosa . 31/
7/22/2019 Materi Anfis
32/33
Example
run exemplo06_03.m
Lo ica Nebulosa . 32/
7/22/2019 Materi Anfis
33/33
The End
Lo ica Nebulosa . 33/