• Aucun résultat trouvé

3 Fire fl y Algorithm

The Firefly Algorithm (FA) is a recent nature inspired metaheuristic algorithm, developed by Yang [20] that has been used for solving nonlinear optimization problems. It is a population-based algorithm [21] to find the global optima of objective functions based on swarm intelligence, investigating the foraging behavior of fireflies. This algorithm is based on the behavior of social insects (fireflies) [22]. For simplicity three idealized rules are to be followed for imple-mentation of the algorithm: (i) Fireflies are unisex so they are attracted towards other fireflies regardless of their sex. (ii) Attractiveness is directly proportional to brightness, so the less brighterfirefly will be attracted towards the brighterfirefly.

(iii) The brightness or light intensity of afirefly is affected or determined by the landscape of the objective function to be optimized [23]. Thefirefly algorithm has two important issues: the variation of light intensity and formulation of the attractiveness. The attractiveness of thefirefly can be determined by its brightness or light intensity which in turn is associated with the encoded objective function.

Based on the objective function, initially, all the fireflies are randomly dispersed across the search space. The two phases [24,25], offirefly algorithm are as follows:

1. Variation of light intensity: The objective function values are used to find the light intensity. Suppose there exist a swarm of n fireflies and xi represents a solution forfireflyi, whereasf(xi) denotes thefitness value.

Ii¼f xð Þ;i 1in: ð1Þ

2. Movement towards attractive firefly: The attractiveness of a firefly is propor-tional to the light intensity seen by adjacentflies. Eachfirefly has its distinctive attractivenessbwhich describes how strong afirefly attracts other members of

154 M.K. Sahoo et al.

the swarm. But the attractivenessbis relative, it will vary with the distancerij

between twofirefliesiand jlocated atxi andxj, respectively, is given as

rij¼xixj ð2Þ

The attractiveness functionbðrÞof thefirefly is determined by

bð Þ ¼r b0ecr2 ð3Þ whereb0is the attractiveness at r = 0 andcis the light absorption coefficient. The movement of afireflyiat locationxiattracted to a more attractivefireflyjat location xjis given by

xiðtþ1Þ ¼xið Þ þt b0ecr2 xjxi

ð4Þ The Pseudocode of Firefly algorithm has been illustrated as follows.

Evaluate the light intensity of the population Iikwhich is directly proportional to f (xik) Initialize algorithm’s parameters

While(i<=n) While(j<=n)

If(Ij<Ii)

Movefirefly i toward j in d-dimension using Eq. (4) Endif

Attractivenessvaries with distance r via exp[−r2]

Evaluatenew solutions and update light intensity using Eq. (1) j=j+1

Endwhile

Rank the fireflies and find the current best if stopping criteria is satisfied then stop

else i=i+1

The proposed network recognizes characters i.e. uppercase and lowercase English letters, numerals and special case letters. The network is trained usingfirefly based back propagation algorithm and it is observed that mean square error is converged Character Recognition Using Firefly Based Back Propagation 155

in less number of iteration than using only back propagation algorithm. First error is calculated using back propagation algorithm and then this error is feed as input to firefly algorithm. The brighterfirefly is considered having minimum error. Distance between firefly is calculated using Eq. (2), attractiveness amongfireflies is calcu-lated by Eq. (3) and movement of firefly is determined by Eq. (4). Various parameters used in the training algorithms are listed as follows: The neural network is trained by using the following steps:

I = (i1, i2, i3, i4,,in): input training vector $k= error at output unit Mk T = (t1,t2, t3, t4,,tm): output target vector $j= error at output unit Mj b0attractiveness at r = 0 Bj= bias at hidden unit γlight absorption coefcient Bk= bias at output unit Ejsum of square error for each input Mk= output unit k βany constant parameter whose value <l Mj= output at hidden unit Vij, Wjkweights at output layer and hidden layer ppopulation ofrefly

α= learning rate Step 1: Assign small random values to the weights.

Step 2: For j = 1 to n (no. of inputs)

Feed Forward from Input signals to hidden layer can be described as

Minj¼BjþXn

i¼1

iivij ð5Þ

Actual output is calculated by applying activation function

Mj¼fðMinjÞ ð6Þ

which is further propagated to above layer i.e. output units.

Step 3: Each output unit sums its weighted input signals.

For k = 1 to m (no. of inputs)

Mink ¼BkþXm

i¼1

mjwjk ð7Þ

and by applying the activation function to calculate the output signals Mk¼f Mð inkÞ ð8Þ

156 M.K. Sahoo et al.

Step 4: In output layer error can be calculated by using (9)

dk¼ðTkMkÞ½f Mð inkÞ ð1f Mð inkÞÞ ð9Þ Error information term at hidden layer can be calculated by (10)

dj¼ f M inj

1f M inj

X

djwjk ð10Þ This error is thefitness value and is used for calculation of intensity of firefly.

Step 5: Weight and bias correction terms are given by (11) and (12).

DWjk¼adkMj DBk¼adk ð11Þ

Hence,

Wjk newð Þ¼WjkþDWjk and Bk newð Þ¼BkþDBk ð12Þ Each hidden unit also updates its bias and weights.

The weight and bias correction terms are given by (13)

DVij¼adjIj and DBj¼adj ð13Þ Hence,

Vij newð Þ¼VijþDVij and Bj newð Þ¼BjþDBjVij newð Þ ð14Þ Step 6: Sum of square error can be calculated by using (15)

Ej¼Xm

k¼1

TkMk

ð Þ2 ð15Þ

Repeat steps 2 to 6 for p times

Step 7: Mean square error (MSE) can be determined by using (16)

Eav¼1=pXn

j¼1

Ej ð16Þ

Step 8: As the sum of square of error (SSE) is inversely proportional to intensity of illumines offirefly, so each SSE value is considered as onefirefly in the proposed work.

Character Recognition Using Firefly Based Back Propagation 157

Step 9: Determine minimum error from SSE list and assign it to Ej (brighter firefly)

For i = 1 to p For j = 1 to I

If (Ei> Ej)

Movefirefly i towards j by using Eq. (2)

Attractive functionbðrÞis determined by using (3) Movement offirefly is determined by using (4)

Update weight and bias at output layer by using the Eqs. (17) and (18) WjkðnewÞ ¼WjkðnewÞ DEið Þt ð17Þ

Bk newð Þ¼Bk newð ÞDEið Þt ð18Þ

At hidden layer updated weight and biases are given by (19) and (20)

VijðnewÞ ¼VijðnewÞ DEið Þt ð19Þ

BjðnewÞ ¼BjðnewÞ DEið Þt ð20Þ end for j

end for i

Step 10: Repeat steps 2 to 9 until the MSE is converged.

158 M.K. Sahoo et al.

4.1 Pseudocode of the Proposed Approach

Input :Assign all network inputs and output. Initialize all weights with small random numbers[-1,1],learning parameter and light absorption coefficient.

Output: Updated weight and bias ,sum of squared error(SSE),mean square error(MSE) Begin

Repeat

For each layer in the network For each node in the layer

Calculate the sum of the inputs to the node .

Apply activation function to find output value of the node Calculate error signal of the node.

Update weight and bias of each node.

End End

Calculate sum of squared error for each generated output using eq. (15) Each SSE value is considered as one firefly.

Calculate MSE from SSE list using eq. (16)

Determine minimum error from SSE list and assign it to fj(brighter firefly) While k < (length of SSE list)

for i = 1 : n (all n fireflies) for j = 1 : i

Calculate the distance between Eiand Ejusing(9) Move the firefly Eitowards Ejusing eq. (4) Modify corresponding weight and bias value

End if

while ((Iterations(max) < Iteration(specified)) OR (mean square error is converged))

5 Implementation

The proposed firefly based back propagation algorithm for Character recognition has been implemented in MATLAB 9.0. The implementation consists of two phases like training phase and testing phase.

(i) Training Phase: Various English alphabets, numerals, and special characters are taken from the system for training purpose. Imread(‘*.bmp’) is used for reading image from graphics file. A = imread(filename,fmt) reads a gray scale or color image from thefile specified by the stringfilename. We have Character Recognition Using Firefly Based Back Propagation 159

arbitrarily given the size of image pixels as a matrix using a‘1’to represent a pixel that is on and a‘0’to represent a pixel that is off. The pixels are then stored in afile for the experimental purpose.

(ii) Testing Phase: In this phase, the system learned data patterns are compared with the patterns to be recognized. The character is given as input for testing using MS paint tool. The pixels are extracted and are stored in form of a matrix. The matrix pattern, which is equal to that of training pattern, is given as the output. For example‘A’(Fig.2) is given as input using MS paint for testing purpose.