You are on page 1of 6

A Fuzzy Finite State Machine Implementation Based on a Neural Fuzzy System

Fatih A. Una1 Emdad Khan

National Semiconductor, Embedded Systems Division 2900 Semiconductor Dr., Santa Clara, CA, 95051
Abstract - The outputs of a feedforward neural network depend on the present inputs only. Difficulties arise when a solution requires memory in such applications as speech processing, seismic signal processing, language processing, and spatiotemporal signal processing. For such applications, the outputs are not only the functions of the present inputs but the present states (or the past inputs and the outputs) as well. The fuzzy finite state machines can be effectively used in these applications. The aim of this study is to show that a fuzzy finite state machine can be realized using our neural fuzzy system. In a fuzzy finite state machine, the output and the next state depend on the input and the present state which in turn is a function of the previous inputs. To accommodate the memory requirement, the feedfonvard structure of the neural fuzzy system is changed to a recurrent architecture by adding a feedback loop from the output layer to the input layer during the recall mode. The validity of the approach is verified with a temporal pattern matching experiment.
1. Introduction

and govem the transitions of the FFSM between the fuzzy states. The fuzzification of FSM results in data reduction (less memory to implement the FFSM) as well as more robust operation (less susceptible to system parameter changes or to noise) as stated in [5].
Also, with this approach, writing a new program is not required since the ANN of NeuFuz is trained with the state transition table and implementation of a new FFSM is achieved directly with the training data. This increases the reliability. Furthermore, the suggested approach facilitates the design and implementation of a FFSM using a microcontroller.

The FFSM concept is introduced in the next section. In Section 3, a brief description of NeuFuz is given. An illustrative temporal pattem matching experiment is carried out in Section 4 to verify the validity of our approach. Section 5 contains the conclusions.
2. A Fuzzy Finite State Machine

In our previous works, it has been shown that the artificial neural networks (ANN) can be combined with fuzzy logic systems to achieve high performance and low cost solutions [ll-[3]. In this work, the feedfonvard structure of our neural fuzzy system (NeuFuz) is changed to a recurrent architecture by adding a feedback loop from the output layer to the input layer during the recall mode. With this modification, we demonstrate that NeuFuz can be used to implement a Fuzzy Finite State Machine (FFSM).
A FFSM is an extension of a conventional FSM. The difference is that the inputs, the present states and the next states are represented using fuzzy sets in contrast with the crisp inputs and the states of a traditional crisp FSM. The output function and the state transition function of the FSM are replaced by the recurrent fuzzy rules which determine the outputs

A FFSM is a synchronous sequential machine and it can be defined as a quintuple following the crisp FSM definition in [4]:

where I, 0, and S are finite, nonempty sets of fuzzy inputs, fuzzy outputs, and fuzzy states respectively, and f: I X S + S is the state transition function, g is the output function such that g: I X S + 0. The Cartesian product I X S contains all pairs of fuzzy elements (u(t), x(t)). The state transition function f maps each fuzzy pair (u(t), x(t)) onto a fuzzy next state x(t+l) in S, and the output function g maps each fuzzy pair (u(t), x(t)) onto a fuzzy output y(t) in 0 in accordance with

0-7803-1896-X/94 $4.00 01994 IEEE

1749

and

where x(t) is the fuzzy present state, u(t) is the fuzzy input, and x(t+l) is the fuzzy next state. The FFSM is defined only at discrete times t = 0, 1, 2, ... in this work. A Moore type of FFSM is employed in this study since it is more convenient to use it with our neural fuzzy system (NeuFuz has one output at this time). The output of a Moore machine is a function of present state only

Note that, in a Mealy machine, the output is a function of both present state and the input. For both machine types, the next state depends on both the input and the present state as seen in equation (2). In general, the state transition function f, and the output function g (given in equations (2) and (3) respectively) can be represented using fuzzy rules in the following format

membership function generator (FRMFG), a fuzzy rule verifier and optimizer (FXVO) and an automatic code converter (ACC). A supervised learning is employed to train the ANN. A modified backpropagation algorithm is used to learn the input output relationship for a given system. The ANN has four inputs, one output and five hidden layers. The architecture of the ANN explicitly maps to the fuzzy logic structure, and the connection Structure along with the weights directly define the fuzzy rules and the membership functions. The FRMFG extracts the fuzzy rules and the membership functions when the ANN converges to a minimum energy state. The validity of the solution can be verified by the FRVO and the solution can be optimized by eliminating the fuzzy rules that do not contribute to the result significantly. This way the output error can be controlled and kept at tolerable levels which is not a trivial task when an ANN is not utilized to obtain the fuzzy system. Finally, the ACC generates a program which corresponds to the fuzzy system. During the training phase, one input of the ANN is used for the external input U(t), and another input is used for the present state X(t). The output of the ANN is used for the next state X(t+l) as shown in Figure 1. There is no need to use separate outputs for the next state X(t+l) and the external output Y(t) of the FSM, since a Moore type of FFSM is implemented. The output X(t+l) is fed back to the present state input X(t) through a unit delay D, once the training is completed. Thus, the architecture of the neural fuzzy system is changed from a feedforward structure to a recurrent architecture during the recall mode as depicted in Figure 2. There is a comparator at the output to determine whether the system is at the final

If Input = U t ) and Presentstate = x ( t ) then Next tate = x( t + 1)

(5)

If Input = u(t) and Presentstate = x ( t ) then Output = y ( t )

(6)

and the membership functions , px(t) pgt+l) , are defined for the fuzzy input u(t), fuzzy present and the next states x(t) and x(t+l) respectively as usual. Note that the derivation of the fuzzy rules (given in equation (5) and (6)) and the associated membership functions is not trivial. The task is to transform the crisp FSM into the corresponding FFSM. This requires the partitioning of the crisp states and the crisp inputs into the clusters (fuzzy sets) and generate the associated membership functions using the state transition table that corresponds to the crisp FSM. This is achieved by means of the ANN in NeuFuz.
3. N d u z Neural Fuzzy System

A detailed description of our neural fuzzy system can be found in [l] - [3]. Here, a brief description will be given. The neural fuzzy system consists of four components: A feedforward ANN, a fuzzy rules and

Legend U(t): Input, X(t): Present State, X(t+l): Next State Figure 1: NeuFuz in training mode

1750

I I7

Legend: D: Unit Delay Figure 2: NeuFuz in recall mode

0
state. Note that the output y(t) is zero in all states except the final state. The defuzzification in NeuFuz can be summarized as INPUTS
U(t>

5
t

Figure 3: A temporal pattem

PRESENT STATE X(t)

WO)
Else where M is the total number of fuzzy rules, pu , pX([) , px([+1) are the membership functions for the fuzzy input u(t), fuzzy present state x(t) and the fuzzy next state x(t+l) respectively. The capital U, X(t) and X(t+l) represent the crisp values. In this work, singletons are used for the next state. The addition and multiplication are used for the disjunction and conjunction operations as shown in equation (7).
4. Experimental Results

1 I I I

so so I

NEXT STATE X(t+l)

s1 so s1

To show the validity of the proposed approach, a Moore type of FFSM is implemented to recognize a temporal pattern shown in Figure 3. First, a state transition diagram (depicted in Figure 4), and a corresponding state transition table (tabulated in Table 1) are derived to recognize the given temporal pattern. The FFSM changes from a fuzzy state to another fuzzy state depending on the temporal pattern sample values arriving at discrete instances. There is an initial state S at which the system waits for the specified temporal O pattern. The initial state is resumed each time the correct temporal sequence is broken. The final state S6 is reached when the entire temporal pattern is received. The FFSM stays in S6 indefinetely until it is reset.

Else U(0) U(2) . , Else U(0) U(3) Else U(0) U(4) Else U(0) U(5) Else All

s2 s2 s2 s3

I I

so
SI
s3

so
s1 s4

s3 s3
s4 s4 s4 s5 s5 s5
S6

so
SI s5

so
s1 S6 S6

so

Table 2: A Procedure to Generate the Training Data 1. Devise the state diagram 2. Generate the state transition table from the state diagram 3. Assign numerical values to the states 4. Generate the Else inputs within the input range along with the corresponding states

1751

Figure 4: State transition diagram to recognize the temporal pattern in Figure 3. The next step is the training of the ANN in NeuFuz. Table 2 contains the procedure to generate the training data set. Following the procedure, the numerical values are assigned to the states as listed in Table 3. The numerical assignments can be arbitrary. However, to facilitate the convergence of the ANN in NeuFuz, the assignment in Table 3 is chosen to minimize the variations between the next state values Table 3: Numerical state assignments

X(t+l) corresponding to the consecutive next states and inputs as can be seen in Table 4. The parameters shown in Table 5 are used for the training. It takes 109,286 iterations for the ANN to converge with these parameters. The generated membership functions for the input u(t) and the present state x(t), and the fuzzy rules are given in matrix format in Figure 5a, 5b and Table 6 respectively. The NeuFuz generates an assembler program code automatically. The required amount of memofy to implement this FFSM is 894 bytes (in Nationals COP8 Microcontroller ). The recognition rate of FFSM is 100 % when the input sample values are within the specified error range (E = 0.01). A detailed analysis of recognition performance is not carried out as the major focus is to show the feasibility of implementing the FFSM using NeuFuz.

S6

1752

Table 5: Training Mode Parameters Legend: E: Tolerated error, LR: Learning rate, I>F:Learning factor, MF: input, x(t): Fuzzy present state

# MFu

MF x(t)
# Rules
49

Table 6: Fuzzy Rules Legend: U: Fuzzy input, x(t): Fuzzy present state, singleton values are for next state x(t+l), VLM: Very Low Match, LM: Low Match, MLM: Medium Low Match, MM: Medium Match, MHM: Medium High Match, HM: High Match, VHM: Very High Match. The numerical values are truncated to two digits after the decimal point.

1753

signal detection subsystem. Furthermore, the suggested approach facilitates the design and implementation of a FFSM using a microcontroller and provides more robust response (less susceptible to system parameter changes or to noise) as stated in [5]. The results obtained encourage us to apply our method to the automotive problems such as airbag deployment and antilock braking system as well as other spatiotemporal signal processing applications. Further studies are underway to determine the applicability of this approach to speech processing. Figure 5a: Membership Functions pu(U(t)) for the Fuzzy Input u(t)
1.o

References

0.8

0.6
0.4

E. Khan and P. Venkatapuram, "NeuFuz: Neural Network Based Fuzzy Logic Design Algorithms," FUZZ-IEE93 Proceedings, vol. 1, pp. 647-654, San Francisco, California, March 28 - April 1, 1993.
E. Khan, "Neural Network Based Algorithms For Rule Evaluation & Defuzzification in Fuzzy Logic Design," WCNN93 Proceedings, vol. 2, pp. 3138, July 11-15, 1993.

0.2
0.0

1.o

4.0

7.0

Figure 5b: Membership Functions pqt) (X(t)) for the fuzzy present state x(t)
5. Conclusions

E. Khan, "NeuFuz: An Intelligent Combination of Fuzzy Logic with Neural Nets," IJCN"93 Proceedings, vol. 3, pp. 2945-2950, Nagoya, Japan, October 25-29,1993.
2. Kohavi, Switching and Finite Automata

The main objective of this work is to show that a FFSM can be implemented using a neural fuzzy system, namely, NeuFuz. The experimental results show that the proposed approach can be effectively used especially when the cost is a primary concem. The main advantage of this approach is that the f fuzzification o the states and the input result in the reduction of memory size that is required to implement the FFSM in a microcontroller. Besides, there is no need to write a program (or design hardware) to implement the FFSM.The training data corresponding to the state transition table can be used to implement the FFSM directly. This ensures the reliability of the operation. Also, additional flexibility (to control the transitions between the states) can be achieved by modifying the training set (adding, deleting and changing training data). For instance, changing noise characteristics can be considered to update the training data set when a FFSM is employed as an adaptive

Theory. New York, NY:McGraw-Hill Publishing Company, 1978.

E. H. Mamdani, "Twenty years of Fuzzy Control: Experiences Gained and Lessons Learnt," FUZZIEEE93 Proceedings, vol. 1, pp. 339-344, San Francisco, California, March 28 - April 1,1993.

1754

11-1

You might also like