Neuro-Fuzzy Control Adriano Joaquim de Oliveira Cruz NCE/UFRJ adriano@nce.ufrj.br Neuro-Fuzzy Systems Usual neural networks that simulate fuzzy systems Introducing *@2001 Adriano Cruz fuzziness into neurons *NCE e IM - UFRJ Neuro-Fuzzy ‹#› ANFIS architecture Adaptive Neuro Fuzzy Inference System Neural system that implements a Sugeno Fuzzy model. *@2001 Adriano Cruz *NCE e IM - UFRJ Neuro-Fuzzy ‹#› Sugeno Fuzzy Model A typical fuzzy rule in a Sugeno fuzzy model has the form If x is A and y is B then z = f(x,y) A and B are fuzzy sets in the antecedent. z=f(x,y) is a crisp function in the consequent. Usually z is a polynomial in the input variables x and y. When z is a first-order polynomial the system is called a first-order Sugeno fuzzy model. *@2001 Adriano Cruz *NCE e IM - UFRJ Neuro-Fuzzy ‹#› Sugeno Fuzzy Model z1=p1x+q1y+r1 m m A1 B1 y x m w1 w1 z1 w2 z 2 z w1 w2 m B2 A2 w2 x y z2=p2x+q2y+r2 *@2001 Adriano Cruz *NCE e IM - UFRJ Neuro-Fuzzy ‹#› Sugeno First Order Example If x is small then y = 0.1x + 6.4 If x is median then y = -0.5x + 4 If x is large then y = x – 2 Reference: J.-S. R. Jang, C.-T. Sun and E. Mizutani, Neuro-Fuzzy and Soft Computing *@2001 Adriano Cruz *NCE e IM - UFRJ Neuro-Fuzzy ‹#› Comparing Fuzzy and Crisp small medium (b) Overall I/O Curve for Crisp Rules 8 large 1 6 0.8 0.6 Y Membership Grades (a) Antecedent MFs for Crisp Rules 0.4 2 0.2 0 -10 0 -10 -5 small medium 0 5 10 X (d) Overall I/O Curve for Fuzzy Rules 8 large 0.6 0.4 *@2001 Adriano Cruz 4 2 0.2 0 -10 -5 6 0.8 Y Membership Grades 0 5 10 X (c) Antecedent MFs for Fuzzy Rules 1 4 -5 0 X 5 10 0 -10 *NCE e IM - UFRJ -5 0 X 5 10 Neuro-Fuzzy ‹#› Sugeno Second Order Example If x is small and y is small then z = -x + y +1 If x is small and y is large then z = -y + 3 If x is large and y is small then z = -x + 3 If x is large and y is large then z = x + y + 2 Reference: J.-S. R. Jang, C.-T. Sun and E. Mizutani, Neuro-Fuzzy and Soft Computing *@2001 Adriano Cruz *NCE e IM - UFRJ Neuro-Fuzzy ‹#› Membership Grades Membership Functions Small 0.8 0.6 0.4 0.2 0 -5 Membership Grades Large 1 -4 -3 -2 -1 0 X 1 2 Small 1 3 4 5 4 5 Large 0.8 0.6 0.4 0.2 0 -5 -4 *@2001 Adriano Cruz -3 -2 -1 0 Y 1 *NCE e IM - UFRJ 2 3 Neuro-Fuzzy ‹#› Output Surface *@2001 Adriano Cruz *NCE e IM - UFRJ Neuro-Fuzzy ‹#› ANFIS Architecture Layer 1 Layer 2 Layer 3 A1 x A2 B1 y B2 x w1 O1,2 P N P Layer 4 Layer 5 N w2 y w1 w1 f1 f S w2 w2 f 2 x y Output of the ith node in the l layer is denoted as Ol,i *@2001 Adriano Cruz *NCE e IM - UFRJ Neuro-Fuzzy ‹#› ANFIS Layer 1 Layer 1: Node function is O1,i m Ai ( x), for i 1,2 or O1,i m Bi 2 ( y ) for i 3,4 x and y are inputs. Ai and Bi are labels (e.g. small, large). m(x) can be any parameterised membership function. These nodes are adaptive and the parameters are called premise parameters. *@2001 Adriano Cruz *NCE e IM - UFRJ Neuro-Fuzzy ‹#› ANFIS Layer 2 Every node output in this layer is defined as: O2,i wi m Ai ( x) T m Bi ( y ), for i 1,2 T is T-norm operator. In general, any T-norm that perform fuzzy AND can be used, for instance minimum and product. These are fixed nodes. *@2001 Adriano Cruz *NCE e IM - UFRJ Neuro-Fuzzy ‹#› ANFIS Layer 3 The ith node calculates the ratio of the ith rule’s firing strength to the sum of all rules’ firing strength wi O3,i wi for i 1,2 w1 w2 Outputs of this layer are called normalized firing strengths. These are fixed nodes. *@2001 Adriano Cruz *NCE e IM - UFRJ Neuro-Fuzzy ‹#› ANFIS Layer 4 Every ith node in this layer is an adaptive node with the function O4,i wi f i wi ( pi x qi y ri ) for i 1,2 Outputs of this layer are called normalized firing strengths. pi, qi and ri are the parameter set of this node and they are called consequent parameters. *@2001 Adriano Cruz *NCE e IM - UFRJ Neuro-Fuzzy ‹#› ANFIS Layer 5 The single node in this layer calculates the overall output as a summation of all incoming signals. wi f i O5,1 wi f i i wi i i *@2001 Adriano Cruz *NCE e IM - UFRJ Neuro-Fuzzy ‹#› ANFIS Layer 5 Every ith node in this layer is an adaptive node with the function O4,i wi f i wi ( pi x qi y ri ) for i 1,2 Outputs of this layer are called normalized firing strengths. *@2001 Adriano Cruz *NCE e IM - UFRJ Neuro-Fuzzy ‹#› Alternative Structures The structure is not unique. For instance layers 3 and 4 can be combined or weight normalisation can be performed at the last layer. *@2001 Adriano Cruz *NCE e IM - UFRJ Neuro-Fuzzy ‹#› Alternative Structure cont. Layer 1 Layer 2 Layer 3 A1 x A2 B1 y B2 *@2001 Adriano Cruz w1 O1,2 x y P Layer 4 Layer 5 w1 f1 S w2 f1 P w2 x *NCE e IM - UFRJ y S wi f i f / wi Neuro-Fuzzy ‹#› Training Algorithm The f f function f can be written as w1 w2 f1 f2 w1 w2 w1 w2 w1 ( p1 x q1 y r1 ) w2 ( p2 x q2 y r2 ) There is a hybrid learning algorithm based on the least-squares method and gradient descent. *@2001 Adriano Cruz *NCE e IM - UFRJ Neuro-Fuzzy ‹#› Example Modeling the function sin( x) sin( y) z xy Input range [-10,+10]x[-10,+10] 121 training data pairs 16 rules, with four membership functions assigned to each input. Fitting parameters = 72; 24 premise and 48 consequent parameters. *@2001 Adriano Cruz *NCE e IM - UFRJ Neuro-Fuzzy ‹#› Initial and Final MFs Degree of membership 1 0.8 0.6 0.4 0.2 0 -10 Degree of membership Initial MFs on Y -5 0 5 input1 Final MFs on X 10 1 0.8 0.6 0.4 0.2 0 -10 -5 *@2001 Adriano Cruz 0 input1 5 10 1 0.8 0.6 0.4 0.2 0 -10 Degree of membership Degree of membership Initial MFs on X -5 0 5 input2 Final MFs on Y 10 1 0.8 0.6 0.4 0.2 0 -10 *NCE e IM - UFRJ -5 0 input2 5 10 Neuro-Fuzzy ‹#› Training Data Training data ANFIS Output 1 1 0.5 0.5 0 0 10 10 10 0 -10 -10 Y Y X 0 -10 -10 X step size curve 0.2 0.35 0.3 0.15 step size root mean squared error error curve 0.1 0.05 0 10 0 0 0.25 0.2 0.15 0 50 epoch number *@2001 Adriano Cruz 100 0.1 0 *NCE e IM - UFRJ 50 epoch number 100 Neuro-Fuzzy ‹#›