• 沒有找到結果。

The Discrete Hopfield Neural Network

CHAPTER 2 The Hopfield Neural Network

2.4 The Discrete Hopfield Neural Network

The continuous mode of Hopfield neural network is based on an additive model, as previously discussed. If the nonlinear activation function

ϕ ( )

⋅ in Figure 2-2 is replaced by the following sgn function [1, 14]:

Figure 2-6. The sgn function

Thus we can basically have a discrete Hopfield neural network, like Figure 2-7. The discrete Hopfield neural network eliminates the self-loop feedback as shown in Figure 2-1. In the continuous mode, the nonlinear activation sigmoid function is the hyperbolic tangent function ((2-1)). The gain parameter

a

j in (2-2) is the slope of the hyperbolic tangent function. If we let

a

j

→ ∞

, then the input-output relation in a neuron of discrete mode becomes

1 for 0 1 for 0

j j

j

x v

v

+ >

= ⎨−⎧⎩ < (2-14)

( )

0

ϕ

j = (2-15) 0

Figure 2-7. The discrete Hopfield neural network without self-loop feedback

The energy function

E t ( )

for discrete Hopfield neural network can be derived from that in

(2-6), i.e., the for continuous Hopfield neural network. In discrete case, the gain (2-3) and Figure 2-4). There is also no bias current

I

j in discrete case. Thus, the energy function

E t ( )

of discrete Hopfield neural network becomes:

1 1 The most important application of the discrete model is working as a content-addressable memory (CAM) [14]. In this application, a content-addressable memory is error-correcting in the sense to retrieve a stored pattern, given a reasonable subset of the information content of that pattern. However, the synaptic weighting factors of the network that produce the desired fixed points are unknown, and the problem is how to determine them. There are two phases to the operation of the discrete Hopfield network as a CAM, namely the storage phase and the retrieval phase. Now we introduce the process of the discrete Hopfield model as CAM:

1. Storage phase:

There are

M

N-dimensional vectors called fundamental memories denoted by

,1 ,2

....

,N ,

μ μ μ μ

ξ

= ⎣ ⎡

ξ ξ ξ

⎤⎦

μ

= 1, 2,..., M

. And each ξ is a binary code, it means μ,i

that ξμ,i

= + 1

or . The fundamental memories are the stable states to be stored and memorized by the network. Then we use the following Hebb’s learning rule to define the weighting matrix of the discrete Hopfield network[14]:

− 1

discrete model doesn’t have self-loop feedback. We also find that the weighting matrix is

symmetric, i.e., . The following theorem will explain why the weighting matrix in discrete Hopfield neural network be decided by (2-17).

W

T

= W

will minimize the energy function

E t of discrete Hopfield neural network when the state ( )

X

is the fundamental memory ξ . μ

Proof:

We use the vector and matrix form to express the energy function in (2-16).

1 2

E = − X WX

T (2-18) where

X

is a N dimensional column vector. We use the definition of weighting matrix in (2-17) to rewrite (2-18).

1

The reason for using Hebb’s learning rule to decide the weighting matrix is right here. When

the state

X

is equal to the fundamental memory ξ , μ

( ξ

μT

X )

2 will reach the maximum. It means that the energy function

E

would reach the minimum if we choose the weighting matrix as (2-17).

2. Retrieval phase:

Now we start the algorithm to stabilize the system and retrieve the pattern. We get a initial wrong state

x ( )

0 called “probe”, which is a noisy version of the correct stable state ξ . μ The initial probe has elements equal to

± 1

. Then we use the following formula to update

x n : ( )

state if it is already there. Similarly, if

+ 1

transformed to one of the stable states ξ . Let us use an example to verify this process. μ

Example: ξ1

= [ 1 − 1 1 ]

and ξ2

= − [ 1 1 1 ]

are the two stable states (fundamental

memories). Only the two states will be stable, the other unstable states will converge to the two stable states after some iteration. Then we compute the weighting matrix by (2-17):

Figure 2-8. Example of the discrete Hopfield model

In Figure 2-7, the left upper corner ξ1

= [ 1 1 1 ]

and the right down corner are the two fundamental memories. The nearby unstable wrong states like or

[

will converge to the two stable states.

[

2

1 1 1

ξ

= − − ]

]

[ 1 1 1 ′ ] 1 1 1 ′

CHAPTER 3

Training Algorithm of Continuous Hopfield Neural Network for Control Applications

We have discussed how to find the weighting factors of discrete Hopfield neural network (NN) in Chapter 2. In this chapter, the training algorithm to find the weighting factors of continuous Hopfield NN will be proposed. The back-propagation skill is mainly adopted for this problem.

Further the optimal training algorithm is also proposed to accelerate the learning speed. We assume the following unity feedback Single Input Single Output (SISO) control system using Hopfield NN as a controller:

Hopfield NN

Figure 3-1. The Hopfield NN as a real-time SISO controller

The control goal is to design a Hopfield NN as a controller so that the output

y

will follow the input . The design process will include the training of weighting factors in Hopfield NN.

Note that it can be shown in Figure 3-1 that the output

d

x

j of the Hopfield NN is the control input to the system plant and there is a switch placed between the error signal and

the input

e

j

= − y d

x

j of Hopfield NN. This implies that {

x

j

( )

0 =

e

j

( )

0 ,

x

i

( )

0 = for i0 }. The reason for this initial arrangement is that Hopfield NN will need non-zero initializations for

j

all

x to serve as a real-time controller. This will be explained in more details in later

i section.

3.1 Back-propagation of continuous Hopfield neural network

The back-propagation learning algorithm is one of the most important historical developments in neural networks [14, 15]. The back-propagation learning algorithm is originally applied to multilayer feed-forward networks consisting of processing elements with continuous differentiable activation functions. Given a training set of input-output pairs {

d n ( ) ( )

,

y n },

the algorithm provides a procedure for the finding of weighting factors in back-propagation network. Now, we use the popular back-propagation algorithm in the continuous Hopfield NN to find the way for the training weighting factors. Let the output of neuron j (i.e.,

x

j) be the control input to the plant (see Figure 3-1). We define the error signal of the output neuron The error signal can be used to decide the cost function. The cost function is a measure of learning performance which can be defined as

j

( )

To minimize the cost function , the update of the weighting factors can be obtained from the following rule:

The parameter η is the learning rate or step size of our continuous Hopfield NN back-propagation algorithm. In (3-3) and (3-4), we can find that the back-propagation algorithm applies a correction Δ

w

ji

( ) n

to the synaptic weighting factor , which is proportional to the partial derivative

( )

∂ . Thus, we have the following update rule:

(

1

) ( )

According to the chain rule, we can get the gradient of

ji

Then (3-5) can be further expressed as

(

1

) ( )

This implies that (3-7) can be further expressed as

( 1 ) ( )

j j In (3-9),

x

j is the continuous Hopfield NN output, and it is also the control signal to control the system plant. The signal

y

is just the system plant output due to the control signal

x

j. Because the system plant is uncertain, the first part

j

( ) ( )

From (3-12), it is obvious that

( ) ( )

in (3-9), we may obtain some hints from (3-13), which is the continuous Hopfield NN dynamic equation. From (3-12), we can rewrite (3-13) as:

( )

The above (3-15) is a nonlinear differential equation, which describes the relationship between

v

j and

w

ji. Thus j

However, the basic theme of all training algorithms is to force the system state to have minimum energy. Theorem 1 in Chapter 2 shows the weighting vector to get the minimum energy of a discrete Hopfield NN. This minimum energy weighting vector is then applied for the training of discrete Hopfield NN. The same philosophy can also be applied in the training of continuous Hopfield NN. From Chapter 2, we have the derivate of energy function

E t ( )

for continuous Hopfield NN as

1

For minimum energy, we must let

dE 0

dt =

. From (3-16), it is obvious that if

dv

j 0

dt

= for

N

; then

dE 0

Therefore we can have

( )

Form (3-12), we can further express (3-19) as a more complete form:

( ) ( )

Now the three terms

j in the following form:

( ) ( )

Finally we can find the

ji

Therefore the final step to perform the back-propagation algorithm of the continuous Hopfield NN is to combine all the above equations to get

( ) ( ) ( )

The complete back propagation equation for the training of continuous Hopfield NN is therefore

Up to this stage, we still need to find the

v

j for next iteration. This can be easily obtained from (3-18) (repeated here for convenience, as (3-25)), as we assume minimum energy requirement. The following algorithm summarizes the above steps to complete the training process.

Algorithm 3-1: Back-propagation learning for continuous Hopfield neural network

Step 0: Given training pair {

d n ( ) ( )

, ,

y n n = 0,1,..., N

}, with the following initial conditions:

1.

a

j: The slope of hyperbolic tangent function

2.

x

j

( )

0 : Initial value of continuous Hopfield NN

3.

w

ji

( )

0 : Initial synaptic weighting factors of the continuous Hopfield NN.

Step 1: Define the error signal as (3-1).

Step 3: Decide the back-propagation update rule in (3-5).

(

1

) ( )

Step 4: Separate the partial derivative

ji

Step 6: Separate the partial derivative term

ji

Step 7: Get the approximation form of

Step 11: Complete the back-propagation in (3-24).

( )

Step 12: Solve the differential equation with minimum energy condition:

( ) ( ) (

3.2 Optimum learning rate for the training of continuous Hopfield NN

In Section 3.1, we have developed the back-propagation algorithm for the training of weighting factors in continuous Hopfield NN. The back-propagation algorithm will train the continuous Hopfield NN to generate the control signal to control the plant such that the output signal of the plant will be as close as possible to the desired input signal. But the training speed is very slow in Algorithm 3.1 with a arbitrary fixed learning rate. It is better if we can find a better dynamic learning rate in each iteration so that the convergent speed can be increased [12, 13].

It is very important to choose an appropriate learning rate (or step size) in the training process.

If the learning rate is too large, the learning process will jump to the next iteration in a larger step and this may cause divergence in the training process. If the learning is too small, the learning process will be slow, and yet the convergence is not guaranteed. Thus, how to choose a suitable learning rate is important. With the concept of dynamic optimal training in [12, 13], we will develop a similar optimal training algorithm for the training of Hopfield NN. This process is to decide the learning rate

η

in each iteration so that the error energy will be reduced as much as possible. This will not yield a stable training process, but the convergence speed is also the fastest. The error energy function (cost function) at step has been defined in (3-2) and is listed here as (3-32):

linear transfer function, a nonlinear differential equation, or even a look-up table. Thus we can get the following equation:

( ) ( )

we may rewrite the update of weighting factors in Step 10 of Algorithm 3-1 as follows:

( )

Where

η

opt is the dynamical optimal learning rate to be decided. Thus, we have the uncertain correction Δ

w

ji

( ) n

with an uncertain learning rate η . According to (3-24), we also get the opt uncertain new weighting factors

w

ji

( n

+ . As we have discussed, 1

) J n (

+ −1

) ( ) J n

is a

function of the uncertain weighting factors

w

ji

( n

+ . Combine all the above relations, we 1

)

may express

J n (

+ −1

) ( J n )

as a function of the uncertain variable η . It means that what opt

is maximized. Now, we know that is a function of uncertain variable

(

1

) (

J n

+ −

J n

η . opt

( 1 ) ( ) ( )

opt

J n + − J n = H

η (3-30)

In other neural networks, the function

H ( )

⋅ may be a simple parabolic curve, thus we can find η easily. But in this continuous Hopfield NN optimum learning rate algorithm, the opt

function

H ( )

is very complicated, we can apply the Matlab routine fminbnd

[13] to find

the optimal learning rate η from opt

J n (

+ −1

) ( ) J n

. After using Matlab routine to find η , opt we have finished the process of optimum learning rate. At the end of this section, we combine the important result in Section 3.1 and 3.2 to perform the training algorithm in continuous Hopfield NN.

Algorithm 3-2: Back-propagation learning of continuous Hopfield network with optimal learning rate

Step 0: Given training pair {

d n ( ) ( )

, ,

y n n = 0,1,..., N

}, with the following initial conditions:

1.

a

j: The slope of hyperbolic tangent function

2.

x

j

( )

0 : Initial value of continuous Hopfield NN

3.

w

ji

( )

0 : Initial synaptic weighting factors of the continuous Hopfield NN.

Step 1: Use the hyperbolic tangent function

( ) ( ( ) ) ( ( ) )

Matlab routine fminbnd to find the optimal learning rate η . opt Step 4: Use the Algorithm 3-1 to get the new weighting factors:

( ) ( )

Step 5: Use the new weighting factors to get the solution of the Hopfield NN differential equation with minimum energy requirement:

( ) ( ) (

3.3 Hopfield NN as a Real-Time Controller

The above mentioned back propagation training for Hopfield NN can only be performed in a batch off-line processing. Once the training process is completed, the Hopfield must be connected in a real-time environment to serve as a real-time controller. However, we know that the Hopfield NN is a recurrent dynamic system. It has dynamic response from initial excitations. The Hopfield NN dynamic equation is in (3-13) (repeated here for convenience as (3-31)), that Hopfield NN will not have any response at all for . Therefore we need to set a non-zero initial condition for the control configuration in Figure 3-1. In Figure 3-1,

0

t

>

x

j is connected to

e

j at

t

=0, and disconnected for

t

>0, where

x

j is also the control input to

the plant. This implies that {

x

j

( )

0 =

e

j

( )

0 ,

x

i

( )

0 = for i j0 ≠ }.To see the effect of this initial configuration, we have the following Theorem 2.

Theorem 2:

If

w

jj is negative, then the initial excitation to the Hopfield NN in Figure 3-1 will have a stable response in terms of the maximum decay of

v t with respect to

j

( ) e

j

( )

0 .

Proof:

The following (3-32) is the solution of (3-31):

( )

1

Since the output of Hopfield NN controller is a particular neuron output

x

j. Thus, we can rewrite (3-33) as:

The first term

1t

e

RC

in (3-36) is always positive, and the second term

w

jj is the self-feedback of Hopfield neural network. In order for the function

v

j to decay with increasing

e

j,

w

jj needs to be a negative number. Thus, if

w

jj is a negative number, then

v

j in (3-35) is a decreasing function of

e

j. It means that we should choose a large

e

j to get the fastest response of

v

j. Ii is obvious that the initial value

e

j =

e

j

( )

0 is the largest, since the initial output is always zero.

Q.E.D.

CHAPTER 4 Experimental Results

In this chapter, we use the algorithm introduced in Chapter 3 to control the inverted pendulum system in Section 4.1, and the aircraft attitude control in Section 4.2.

4.1 Example 1: The Inverted Pendulum System (IPS)

Inverted pendulum is a nonlinear and unstable system, and it is the most popular benchmark for new control algorithms to verify their advantages [16].

m

mc u

θ l

Figure 4-1. The inverted pendulum system

According to Figure 4-1, we let the angle

θ

which is between the pendulum and the vertical line be equal to the first state

θ

1, and the angular speed θ



be the second state

θ

2. Then we can get the following state equation:

1 2

1

The constant of acceleration of gravity The mass attached to the pendulum The mass of based car

The length of pendulum arm

Angle between pendulum and vertical line Angular speed

In our example, the parameters of the inverted pendulum are defined in the following values:

9.8 / sec ;2 0.1

Thus, we can further express (4-1) as

1 2

The control objective is to stabilize the inverted pendulum with initial angle between

10

and . Note that the state equations in (4-2) are only used for simulation purpose. It is by no means used to design the Hopfield NN controller. For training data set, we generate 6 data set which correspond to six initial angles, i.e., {10°, 7°, 3°, -3°, -7°, -10°}. The six data sets are shown in Figure 4-2.

°

10

°

0 1 2 3 4 5 6 7 8 9 10 -15

-10 -5 0 5 10 15

Training data of inverted pendulum system

Angle (Degrees)

Time (Second)

Figure 4-2. The six training curves for the control of IPS using Hopfield NN

The overall real control architecture of Hopfield NN controller is shown in Figure 4-3. The Hopfield NN in this application has two neurons and the first neuron output

x

1 is the control signal.

Figure 4-3. Real-time SISO control architecture of Hopfield NN controller

After training by the Algorithm 3-2 developed in Chapter 3, the trained weighting factors in Hopfield NN can be used to generate control signal. The values of capacitor and resistance are

10 uF and 1K Ohms respectively. The final four weighting factors in this application are shown in the following Table 4-1. Table 4-1 also shows the resistance values for the weighting factors.

Weighting factor

w

11

w

12

w

21

w

22 Trained value -3.4275 -0.012878 -2.1702 0.2845

| Resistance | 0.2918Ω 77.6518Ω 0.4608Ω 3.5149Ω Table 4-1. Trained weighting factors of IPS

The first weighting factor

w

11 is negative. It is the fact from Theorem 2 discussed in Chapter 3. Three cases with different initial angles and different initial angular speed will be adopted to test the Hopfield NN controller. There are two figures in each of those cases. The first one is about the final angle output

θ

1 in actual real time control case, which is a stable situation in this inverted pendulum system. The second figure is the control signal generated from the trained Hopfield NN.

Case 1. Initial angle

θ

1

( )

0 =10°, initial angular speed θ2

( ) 0 = 0 (

°

/ sec )

0 1 2 3 4 5 6 7 8 9 10

-15 -10 -5 0 5 10 15

Actual running case stable situation

Angle (Degrees)

Time (Second)

Figure 4-4. The actual running stable situation for Case 1

0 0.5 1 1.5 2 2.5

-5 -4 -3 -2 -1 0 1

The control signal generated from Hopfield neural network

Force (Newton)

Time (Second)

Figure 4-5. The control signal of the inverted pendulum system for Case 1

Case 2. Initial angle

θ

1

( )

0 = −8°, initial angular speed θ2

( ) 0 = 4 (

°

/ sec )

0 1 2 3 4 5 6 7 8 9 10

-15 -10 -5 0 5 10 15

Actual running case stable situation

Angle (Degrees)

Time (Second)

Figure 4-6. The actual running stable situation for Case 2

0 0.5 1 1.5 2 2.5

-1 0 1 2 3 4 5

The control signal generated from Hopfield neural network

Force (Newton)

Time (Second)

Figure 4-7. The control signal of the inverted pendulum system for Case 2.

Case 3. Initial angle

θ

1

( )

0 = −5°, initial angular speed θ2

( ) 0 = − 3 (

°

/ sec )

0 1 2 3 4 5 6 7 8 9 10

-15 -10 -5 0 5 10 15

Actual running case stable situation

Angle (Degrees)

Time (Second)

Figure 4-8. The actual running stable situation for Case 3

0 0.5 1 1.5 2 2.5

-1 0 1 2 3 4 5

The control signal generated from Hopfield neural network

Force (Newton)

Time (Second)

Figure 4-9. The control signal of the inverted pendulum system for Case 3

In above three cases, we can find that the system output angles

θ

will be stable in our desired range. It means that the algorithm discussed in Chapter 3 is useful to control the nonlinear inverted pendulum system.

4.2 Example 2: The aircraft attitude control system

The aircraft attitude control system is different from the inverted pendulum system. It is a simplified linear system [17]. The control surfaces of modern aircraft are controlled by electric actuators with electronics controls. Figure 4-10 illustrates the control block diagram of one axis of such a position control system.

Figure 4-10. Block diagram of an attitude-control system of an aircraft

The objective of the system is to have the output of the system,

θ

y

( ) t

, follow the unit step input

θ

r

( ) t

. The transfer function is defined as

( ) ( )

( ) (

4500361.2

)

y

r

s K

G s s s s

θ

=

θ

=

+ (4-3) Where K is gain parameter of preamplifier. When we have introduced the aircraft attitude control system, we must set the specifications as follows:

1. Steady state error due to unit ramp input ≤ 0.000443 2. Maximum overshoot ≤ 5 percent

3. Rise time ≤ 0.005 sec

4. Settling time ≤ 0.007 sec

Now, we will design the Hopfield NN controller for this problem so that the above specifications can be satisfied. The first specification is different from the other specification, so we discuss it first. It is the specification about steady state error due to unit ramp input. It must be satisfied by using preamplifier

K

. The system transfer function in (4-3) has a term in denominator, so it is a type 1 system. For type 1 system, the steady state error due to unit step input is zero, but it is a constant for unit ramp input. Thus we must choose a proper gain of preamplifier

s

K

to reach the first specification. Now, we compute the velocity error constant

k

v of transfer function in (4-3): As we get the velocity error constant , we can compute the steady state error due to unit ramp input According to the first specification, we should let the result of (4-5) be smaller than 0.000443.

Thus we calculate the minimum value of gain of preamplifier K:

0.08026 1 0.000443 K 181.17

K ≤ ⇒ ≥

(4-6) In order to reach the first specification, we choose the gain of preamplifier

K

equal to 181.17. Thus the transfer function

G s becomes to ( )

( ) (

815265361.2

)

G s

=

s s

+ (4-7) Now we hope the output of the system can reach the specifications in actual real time control case. The overall real control architecture of Hopfield NN controller is shown in Figure 4-3.

The Hopfield NN in this application has two neurons and the first neuron output

x

1 is the control signal.

Figure 4-11. Real control architecture of Hopfield NN controller

For training data set, we can generate time response curve as shown in Figure 4-12 so that the above 2, 3, 4 specifications. That is, maximum overshoot = 0.91 percent, rise time = 0.00284 sec and settling time = 0.00424 sec in Figure 4-12.

0 0.005 0.01 0.015 0.02 0.025 0.03 0.035 0.04

0 0.2 0.4 0.6 0.8 1 1.2 1.4

Time

Magnitude

Training data of aircraft control system

Figure 4-12. The training data of the aircraft control system

After training by Algorithm 3-2 developed in Chapter 3, the trained weighting factors in

相關文件