1 / 56

Biologically Inspired Intelligent Systems

Biologically Inspired Intelligent Systems. Lecture 1 4 Dr. Roger S. Gaborski. >> SimpleGA2012 Best score is 9849. Use last population, continue running >> SimpleGA2012 Best score is 10000. All members of population either 10,000 or 9999. Stochastic Optimization.

evita
Download Presentation

Biologically Inspired Intelligent Systems

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Biologically Inspired Intelligent Systems Lecture 14 Dr. Roger S. Gaborski Roger S. Gaborski

  2. >> SimpleGA2012 Best score is 9849 Roger S. Gaborski

  3. Roger S. Gaborski

  4. Use last population, continue running >> SimpleGA2012 Best score is 10000 All members of population either 10,000 or 9999 Roger S. Gaborski

  5. Stochastic Optimization • Algorithms that use some degree of randomness to find optimal, or nearly optimal solutions to difficult problems • Don’t know optimal solution • Don’t know how to find it • Random search is impossible (in a practical sense) because the search space is too large • You know the solution when you find it, so you can test candidate solutions Roger S. Gaborski

  6. Text Creation • A room full of monkeys with typewriters given enough time can write (create) …… (fill in the blank; the bible, a textbook, etc.) • How practical is this approach? • Assume text you want to create is as follows: • TODAY IS TUESDAY • Assume all uppercase characters, ignore spaces: • TODAYISTUESDAY • What is the probability a randomly created string of characters matches the phrase? • The are 14 characters in the phrase Roger S. Gaborski

  7. The first character typed can be any letter in the alphabet. • There is a 1 in 26 chance the first letter typed is a T • There is a 1 in 26 chance the second letter typed is an O • etc. • Probability the correct phase is typed is: p = 1/(26^14) = 1/6.451e19 Roger S. Gaborski

  8. What about the name ‘ROGER’ • Probability = 1/ 26.^5 = 1/11,881,376 • Consider two randomly generated words: • EDGTY • RPHER • The second string is closer than the first • The second string is correct 3 out of 5 characters, in the first string every character is incorrect Roger S. Gaborski

  9. One approach • Create a population of random vectors each containing 5 characters (Length of the phrase) • Compare each vector to the correct phrase (in this case ROGER) • Score each vector • Select the best scoring vector • Create a new population of vectors • For each entry in the new population mutate the previously chosen best scoring vector • Retain the best scoring vector in the population • Select the new best scoring vector and repeat Roger S. Gaborski

  10. Mutation • mutationRate: probability a particular character is mutated • mRadius: The amount an individual character can be incremented or decremented - if mRadius is 2, the character can be increased or decreased by ‘two characters’, for example: • If original character is D and mRadius is 2, the resulting character is either B or F, depending if you increment or decrement the character. The increment/decrement is a random decision Roger S. Gaborski

  11. MATLAB conversions character string to uint8 name = uint8('ROGER') name =82 79 71 69 82 name is of type uint8 name(2) = 79 convert to type double: Q1 = double(name) Q1 =82 79 71 69 82 Convert back to type character: W1 = char(Q1) W1 =ROGER whos Q1 W1 Name Size Bytes Class Attributes Q1 1x5 40 double W1 1x5 10 char Roger S. Gaborski

  12. Q2 = double('ROGER') Q2 =82 79 71 69 82 Q3 = double('DDGER') Q3 =68 68 71 69 82 differ = abs(Q2-Q3) differ =14 11 0 0 0 differ_sum = sum(abs(Q2-Q3)) differ_sum =25 Roger S. Gaborski

  13. Create Random Character Data data1 = floor(rand(1,5)*26)+65 data1 =80 79 68 87 81 Convert to char string cdata =char(data1) cdata =PODWQ display characters: disp(char(data1)) PODWQ Roger S. Gaborski

  14. Best Parent Retained in New Population mutationRate = .25; %Probability an individual character in the phrase will be mutatedmRadius = 3; %Individual character in phrase can increment or decrement by m_radius Objective Phrase (op) is ROGER The original bestParent = VLGDO, with a score of 7 Count = 1 The bestParent = TOGDO, with a score of 2.8 Count = 2 The bestParent = TOGDP, with a score of 1.8 Count = 3 The bestParent = ROGDP, with a score of 1 Count = 4 The bestParent = ROGDQ, with a score of 0.4 Count = 5 The bestParent = ROGDR, with a score of 0.2 Count = 6 The bestParent = ROGDR, with a score of 0.2 Count = 7 The bestParent = ROGER, with a score of 0 Roger S. Gaborski

  15. Keep an original copy of the ‘best parent’ in the mutated list so that the performance is monotonic (error will not go up). Roger S. Gaborski

  16. ‘ROGER’ Roger S. Gaborski

  17. op =PROFESSORROGERGABORSKI Roger S. Gaborski

  18. ‘PROFESSORROGERGABORSKI’ The original bestParent = HQJOAQRPOYKCBVUCGSQEGV, with a score of 42.3182 Count = 1 The bestParent = HQKOAQTMOVKCBVRAGRREGV, with a score of 36.5909 Count = 2 The bestParent = HQIOAQTMPVKCBVQBDRRGGV, with a score of 33.0455 Count = 3 The bestParent = HQILAQTPPVICBVQBDRRGGS, with a score of 28.6364 Count = 4 The bestParent = HSILAQTPSVIDBVOBERRIGP, with a score of 22.4545 Count = 5 The bestParent = KTILFPTPSVLDBVOBERRIGP, with a score of 19.1364 Count = 6 The bestParent = JTILDPTPSVLEBVLCERRLGP, with a score of 15.4545 Count = 7 The bestParent = JTLIDPTPSVLFBVLCEQRLGP, with a score of 12.6364 Count = 8 The bestParent = JTLIDPTPPTLFDVLCCQRLIP, with a score of 10.9545 Count = 9 The bestParent = JTMFDPTPPTLFDVJCCQRLIM, with a score of 8.09091 Count = 10 The bestParent = JQMFDPTPPTOFDVJCCPRMIM, with a score of 6.81818 Count = 11 The bestParent = JPMDDPTPPTOFDVJCCPRPIM, with a score of 5.90909 Count = 12 The bestParent = JPMDDPTPPTOFFTJDCPRPHJ, with a score of 5.13636 Count = 13 The bestParent = MPMDDPTPRTOFFSJDCMRPHJ, with a score of 3.72727 Count = 14 The bestParent = MPMDDPTNRTOFFSJACMRSHJ, with a score of 2.90909 Count = 15 The bestParent = MPMDDPTNTUOFFSGACMRSJJ, with a score of 2.54545 Roger S. Gaborski

  19. Count = 25 The bestParent = NSPFDSSORSOFESGACPSTKI, with a score of 0.636364 Count = 35 The bestParent = PSPFESSOSSNFERGACNQSKH, with a score of 0.454545 Count = 45 The bestParent = PSOFFRSOSRNHFRGACORSKH, with a score of 0.409091 Count = 55 The bestParent = PSOFFTSOSRNHFRGACORSKH, with a score of 0.409091 Count = 65 The bestParent = PRPFFTSOSROHERGACORSJH, with a score of 0.363636 Count = 75 The bestParent = PROFFTSOSRPHFRGABOSSJI, with a score of 0.363636 Count = 85 The bestParent = PROFDTSORRPGERGABOSSLI, with a score of 0.227273 Count = 95 The bestParent = PROFDSSPRROGERGABOSSLI, with a score of 0.181818 Count = 105 The bestParent = PRPFESSORROGERGABORSLI, with a score of 0.0909091 Count = 115 The bestParent = PRPFESSORROGERGABORSLI, with a score of 0.0909091 Count = 125 The bestParent = PRPFESSORROGERGABORSKI, with a score of 0.0454545 Count = 135 The bestParent = PRPFESSORROGERGABORSKI, with a score of 0.0454545 Count = 145 The bestParent = PRPFESSORROGERGABORSKI, with a score of 0.0454545 Count = 155 The bestParent = PRPFESSORROGERGABORSKI, with a score of 0.0454545 Count = 165 The bestParent = PRPFESSORROGERGABORSKI, with a score of 0.0454545 Count = 175 The bestParent = PRPFESSORROGERGABORSKI, with a score of 0.0454545 Count = 185 The bestParent = PRPFESSORROGERGABORSKI, with a score of 0.0454545 Count = 195 The bestParent = PROFESSORROGERGAAORSKI, with a score of 0.0454545 Count = 205 The bestParent = PROFESSORROGERGAAORSKI, with a score of 0.0454545 Count = 215 The bestParent = PROFESSORROGERGAAORSKI, with a score of 0.0454545 Count = 225 The bestParent = PROFESSORROGERGAAORSKI, with a score of 0.0454545 Count = 235 The bestParent = PROEESSORROGERGABORSKI, with a score of 0.0454545 Count = 245 The bestParent = PROFESSORROGERGABOQSKI, with a score of 0.0454545 Count = 255 The bestParent = PROFESSORROGERGABOQSKI, with a score of 0.0454545 Count = 256 The bestParent = PROFESSORROGERGABORSKI, with a score of 0 Roger S. Gaborski

  20. ‘PROFESSORROGERGABORSKI’ Roger S. Gaborski

  21. BestPhrase • mainBestPhrase • function newPop = mutateBestParent(bestParent, mutationRate, mRadius,sizePop, obLength) • function [bestParent, scoreMin] = bestOP(pop1,op_double) Roger S. Gaborski

  22. mainBestPhrase • Define objective phrase • op = ‘ROGER’ • Mutation parameters: • mutationRate:probability an individual character will be mutate • mRadius: selected character can be incremented or decremented by mRadius characters (check that mutated character is in valid range of upper case characters • Set size of population • sizePop • Create initial population • Select best member of initial population • LOOP • Create new population by mutating previously chosen best parent • Score members of population, select best and create new population • Keep track of score of best score and associated member • When either perfect score or end of loop, find best scoring member, display phrase and score Roger S. Gaborski

  23. function newPop = mutateBestParent(bestParent, mutationRate, mRadius,sizePop, obLength) • For sizePop • Determine positions of characters that will be mutated based on mutationRate • For each position chosen, determine mutation value between –mRadius and + mRadius • Modify parent and check that characters in modified parent are within bounds 65-90 • If not within bounds, replace out of bound character with randomly chosen valid character Roger S. Gaborski

  24. function [bestParent, scoreMin] = bestOP(pop1,op_double) • Compare operational phrase (such as ROGER) with each member of population • Calculate score, return bestParent and scoreMin function [bestParent,scoreMin] = bestOP(pop1,op_double) [row,col] = size(pop1); score = zeros([row,1]); for k = 1:row score(k) = (sum((op_double-pop1(k,:)).^2))/col; end scoreMin = min(score); %Find first (incase there are more than 1) individual with best score clear ind ind = find(score==scoreMin,1); %last parameter 1 indicates return first index bestParent = pop1(ind,:);%This is the 'best' parent Roger S. Gaborski

  25. Results for Different Parameters Count = 577 The bestParent = ROCHESTERINSTITUTEOFTECHNOLOGY, with a score of 0 Count = 231 The bestParent = ROCHESTERINSTITUTEOFTECHNOLOGY, with a score of 0 Count = 89 The bestParent = ROCHESTERINSTITUTEOFTECHNOLOGY, with a score of 0 Count = 393 The bestParent = ROCHESTERINSTITUTEOFTECHNOLOGY, with a score of 0 Count = 11148 The bestParent = ROGERGABORSKIDEPARTMENTOF COMPUTERSCIENCEROCHESTERINSTITUTEOFTECHNOLOGY, with a score of 0 Roger S. Gaborski

  26. Discovery of Weights for a Neural Network Roger S. Gaborski

  27. RECALL: Single Neuron Model

  28. Artificial Neurons vk = bk*1 + x1*w1 + x2*w2 + …xn*wn Redefine vk as net and bk as simply b net = b + ∑ xi * wi The activation function, f, can take several forms, including The identity function, binary step function, bipolar step function, sigmoid function or a bipolar sigmoid function

  29. Artificial Neural Networks/Neural Network Basicshttp://en.wikibooks.org/wiki/Artificial_Neural_Networks/Neural_Network_Basics

  30. Feed Forward Operation For OR: w0 = 1, w1 = 1, w2 = 1 net = w0 + ∑ xi * wi (redefine b = w0) Response = fcn(net) net = w0 + x1*w1 + x2*w2 redefine b = w0 net = [ w0 w1 w2 ] * 1 x1 x2 Response = f(net) = f[ w0 w1 w2 ] * 1 x1 x2

  31. Feed Forward Operation net = w0 + x1*w1 + x2*w2 net = [ 1 1 1 ] * +1 -1 -1 Response = sign(net) = sign [ 1 1 1 ] * 1 -1 -1 Response = sign(-1) = -1

  32. Matrix of Data Inputs AND GATE: weights = -1 1 1 >> data = [1 -1 1; 1 -1 -1; 1 1 1; 1 1 -1]' data = 1 1 1 1x0 bias (always 1) -1 -1 1 1x1 value 1 -1 1 -1x2 value Responses = sign(weights*data) = -1 -1 1 -1

  33. Single Neuron • a = x0w0+ x1w1 + x2w2 + … + xnwn • x0 is bias term = 1 • Output = tanh(a) (INSTEAD OF sign) Roger S. Gaborski

  34. 4 Fully Connected Neurons N1 N2 Notation: wto, from W1,2 To neuron 1 From neuron 2 w23 N3 N4 w34 w44 Roger S. Gaborski

  35. 4x4 Weight Matrix w11 w12 w13 w14 w21 w22 w23 w24 w31 w32 w33 w34 w41 w42 w43 w44 w11 is weight between neuron n1 and itself w12 is the weight connection to N1 from N2 Roger S. Gaborski

  36. Outputs of Neurons • x1 is output of neuron 1 • x2 is output of neuron 2 • x3 is output of neuron 3 • x4 is output of neuron 4 Roger S. Gaborski

  37. 4 Fully Connected Neurons with BIAS w10 w20 N1 N2 Notation: wto, from W1,2 To neuron 1 From neuron 2 w23 N3 N4 w34 w44 w30 w40 Roger S. Gaborski

  38. Append Bias Term Column:Column 0 w10 w11 w12 w13 w14 w20 w21 w22 w23 w24 w30 w31 w32 w33 w34 w40 w41 w42 w43 w44 Roger S. Gaborski

  39. Multiply by Neuron Output Column Vector w10 w11 w12 w13 w14 1 w20 w21 w22 w23 w24 * x1 w30 w31 w32 w33 w34 x2 w40 w41 w42 w43 w44 x3 x4 WEIGHT MATRIX STATE VECTOR Roger S. Gaborski

  40. Recall: Single Neuron • a = x0w0+ x1w1 + x2w2 + … + xnwn • x0 is bias term = 1 FOR OUT CURRENT NOTATION: a1 = w10 w11 w12 w13 w14 * 1 x1 x2 x3 x4 Roger S. Gaborski

  41. Include Input Data to Neuron 1 w1in w10 w11 w12 w13 w14 Iin 0 w20 w21 w22 w23 w24 * 1 0 w30 w31 w32 w33 w34 x1 0 w40 w41 w42 w43 w44 x2 x3 x4 Roger S. Gaborski

  42. 4 Fully Connected Neurons with BIAS w10 w20 N1 N2 w1In Notation: wto, from W1,2 To neuron 1 From neuron 2 Iin w23 N3 N4 w34 w44 w30 w40 Roger S. Gaborski

  43. Apply Non-linear Function w1in w10 w11 w12 w13 w14 Iin 0 w20 w21 w22 w23 w24 * 1 0 w30 w31 w32 w33 w34 x1 =x1 0 w40 w41 w42 w43 w44 x2 x2 x3 x3 x4 x4 tanh Where x1, x2, x3 and x4 are update state values of network Roger S. Gaborski

  44. 2 Neuron XOR Network • Two inputs applied to both neurons • Both neurons have bias terms Roger S. Gaborski

  45. 2 Neuron XOR Network with BIAS w10 w20 w22 w11 w12 N1 N2 x2 Notation: wto, from W1,2 To neuron 1 From neuron 2 w21 x1 w1in1 w1in2 w2in2 w2in1 Iin1 Iin2 Roger S. Gaborski

  46. Weight Matrix w1in1 w1in2 w10 w11 w12 Iin1 input1 w2in1 w2in2w20 w21 w22 * Iin2 input2 1 bias x1 output N1 x2 output N2 Roger S. Gaborski

  47. No self connections (w11 , w22 )No recurrent feedback connections (w12) w10 w20 N1 N2 x2 Notation: wto, from W2,1 To neuron 2 From neuron 1 w21 x1 w1in1 w1in2 w2in2 w2in1 Iin1 Iin2 Roger S. Gaborski

  48. Weight Matrix – no self connections (w11 , w22 )no recurrent feedback connections (w12) w1in1 w1in2 w100 0 Iin1 input1 w2in1 w2in2w20 w210 * Iin2 input2 1 bias x1 output N1 x2 output N2 Roger S. Gaborski

  49. Weight Matrix Valuesno self connections (w11 , w22 )no recurrent feedback connections (w12) -2.19 -2.20 .139 0 0 Iin1 -2.81 -2.703.90 -31.8 0 * Iin2 1 x1 x2 ASSUME WE KNOW WEIGHT VALUES Roger S. Gaborski

  50. Non-linear Fuction, State Update -2.19 -2.20 .139 0 0 Iin1 -2.81 -2.703.90 -31.8 0 * Iin2 1 = x1 x1 x2 x2 tanh Roger S. Gaborski

More Related