Искусственные нейронные сети Лабораторный практикум

  • Published on
    08-Dec-2016

  • View
    224

  • Download
    5

Embed Size (px)

Transcript

<ul><li><p>. . , . . , . . </p><p> 2004 </p></li><li><p> 2</p><p> 681.3 34 </p><p> : - </p><p> , </p><p> . . . </p><p> . . 34 , . . []: . -</p><p> / . . , . . , . . . : - . . -, 2004. 136 .: 8 ., . 10 . </p><p> , , - MATLAB 6 - Neural Networks Toolbox (NNT). </p><p> - 220400 220100 -, . </p><p> 681.3 </p><p> , 2004 . ., . ., . ., 2004 </p></li><li><p> 3</p><p> -</p><p> , (1011) , - . 1015. </p><p> - , . (-) -. - : - ; ; ; ; -, . . , , -. Neural Networks Toolbox (NNT) MATLAB 6 Math Works. </p><p> NNT - , -</p></li><li><p> 4</p><p> . , , - . 15 . - - , , , , , , -, . - Real Time Workshop, MATLAB 6. </p><p> , , NNT MATLAB 6 , - . - MATLAB - . - - , , . - , - NNT. </p></li><li><p> 5</p><p> 1 </p><p> MATLAB : - -</p><p> MATLAB, - , , , , , -, -- . </p><p> MATLAB -, , , , , - ( Simulink) . - , . </p><p> MATLAB - . . - -. , , *.m -, -. - - , - . - . </p></li><li><p> 6</p><p> MATLAB : -</p><p> ( ) -. </p><p> - . . </p><p> , . MATLAB . </p><p> MATLAB m, . </p><p> - , -. MATLAB -: , ; -; ; . </p><p> MATLAB -: </p><p>1) : double, numeric, char, cell, array; 2) : 25, pi, eps, Hello, ans, m, n; 3) , : +,-,*; 4) : help, clear, plot, sin, cos; 5) : func, map, draw, paint, neuron; 6) : if, for, while, switch, try, catch, end; 7) : realmin, realmax, Inf, Nan; 8) : NNT, Simulink. </p></li><li><p> 7</p><p>M- M- MATLAB : -, ; -, . - Script- -</p><p>. , . . , - . - - MATLAB . </p><p>- : % () % ( ) , -</p><p> . </p><p>lookfor help _. help _, . </p><p>- - , , - . -- -, , - . </p><p>- : function var=f_name (___ -</p><p>) % () % (-</p><p>) </p></li><li><p> 8</p><p> , - . </p><p>var= var= , -</p><p>, . - , - : </p><p> Function[var1,var2,...]=f_name(___</p><p>) % () % (-</p><p>) , -</p><p> . var1= var2= ... var, var1, var2, ... </p><p> -. </p><p> , </p><p> , MATLAB -, . - : </p><p> 1. : input (); 2. : if ... elsif ... else... end; 3. for...end: for _ _ end; </p></li><li><p> 9</p><p>4. while...end: while _ _ end; </p><p>5. : switch Exp case B1 case b2 otherwise end; </p><p>6. try...catch...end: try _try catch _catch end; </p><p>7. : pause, pause (...), pause on, pause off. </p><p>input disp. input : = input() , </p><p> -. Enter, - . </p><p> disp : </p><p>disp ( ) </p><p> if -: </p><p>if __If elseif __Elsif else __Else end </p></li><li><p> 10</p><p> for...end - . : </p><p>for var=, _ end </p><p> s:d:e, s - var, d - e , - . d 1. </p><p> while...end , -</p><p> : while _ end -</p><p> break continue. ( ) -</p><p> switch: switch switch_ case case_ _ case </p><p>{case_1,case_2,case_3,...} _ ... otherwise, _ end </p></li><li><p> 11</p><p>Case_ , , , . case , strcmp(, ) . </p><p> try...catch...end - : </p><p> try _ catch _ end . -</p><p> catch , - , lasterr . catch . </p><p> , , , , , . . </p><p> pause. - : </p><p>1) pause ; 2) pause(N) N ; 3) pause on ; 4) pause off . </p></li><li><p> 12</p><p> 1. - </p><p> [xmin, xmax]. </p><p>1. m- : %Plot with color red % % [xmin, xmax] x=xmin:0.1:xmax; plot(x,sin(x),'r') grid on </p><p>2. pcr.m. 3. MATLAB : &gt;&gt; help pcr Ha , -</p><p> : </p><p> Plot with color red [xmin, xmax] </p><p>&gt;&gt; </p><p>4. : &gt;&gt; pcr ??? Undefined function or variable 'xmin'. </p><p>Error in ==&gt; C:\MATLAB6p1\work\pcr.m On line 4 ==&gt; x=xmin:0.1:xmax; </p></li><li><p> 13</p><p> , - , . - -: </p><p> 5. xmin xmax &gt;&gt; xmin=-10; &gt;&gt; xmax = 10; 6. &gt;&gt; pcr 2. - </p><p>, : 1. m- : %Plot with color red % % [xmin, xmax] function x=fun(xmin,xmax) x=xmin:0.1:xmax; plot(x,sin(x),'r') grid on 2. fun.m. 3. MATLAB : fun(-10,10); , xmin xmax -</p><p> . </p></li><li><p> 14</p><p> 3. - , : </p><p> 1. m- : %Plot with color red % % [xmin, xmax] disp(' xmin xmax '); xmin=input('xmin = '); xmax=input('xmax = '); x=xmin:0.1:xmax; plot(x,sin(x),'r') grid on 2. pcrdialog.m. 3. MATLAB : &gt;&gt; pcrdialog , xmin xmax </p><p>, . </p></li><li><p> 15</p><p> 2 , , MATLAB </p><p> : , -, MATLAB, - . </p><p> , </p><p> MATLAB : (), () - . </p><p> MATLAB - . - , : </p><p>1. : ones, zeros, rand; 2. : cat (dim, , ), cat (dim, A1, A2, A3, ...); 3. : fliplr, flipud, perms; 4. : prod, cumprod, </p><p>sum; 5. : rot 90(A), rot 90(A,k); 6. : tril (x), tril (x,k), triu ; 7. : compan; 8. : cand, det, rank, norm; 9. : +, -, *, .*, /, ./, ^, .^ . , </p><p>MATLAB 11, - . . </p></li><li><p> 16</p><p> , - . , - . </p><p> , </p><p> . . </p><p>MATLAB - : </p><p>struct </p><p>fieldnames </p><p>getfield </p><p>setfield </p><p>rmfield </p><p>isfield , </p><p>isstruct , </p><p> , -</p><p> - . </p><p> , -</p><p> ; : , , . </p><p> : ) ; </p></li><li><p> 17</p><p>) struct. </p><p>11, . - MATLAB -. </p><p> struct : str_array=struct(','','','</p><p>',...). , </p><p> . - . - , (.) , - . </p><p> , , - . fieldnames -, setfield getfield. </p><p> getfield - : </p><p> f = getfield(array, {array_index}, 'field', {field_index}) </p><p> array_index field_index - ; 11. getfield </p><p> f = array(array_index).field(field_index); </p><p> setfield -</p><p>, : </p></li><li><p> 18</p><p>f = setfield(array, {array_index}, 'field', {field_index}, value) </p><p> . . </p><p> . - - , , . </p><p> MATLAB , </p><p> , , . - : </p><p>cell </p><p>celldisp </p><p>cellplot </p><p>num2cell </p><p>deal </p><p>cell2struct </p><p>struct2cell </p><p>iscell , </p><p> , - . </p><p> , , -</p><p> , </p></li><li><p> 19</p><p>. - . </p><p> : ) ; ) cell, </p><p> , . , </p><p>. MATLAB . . </p><p>, . - { }. </p><p> , </p><p> , -. </p><p> , - : </p><p>) -; </p><p>) . </p><p> ( -) </p><p> - , - . -</p></li><li><p> 20</p><p> , . - . , , . </p><p> ( -) </p><p> , . - , . </p><p> , -</p><p>, . , : </p><p>A(j : k ) = [ ] , </p><p> . reshape </p><p> , ; reshape , . </p><p> : ) ; ) ; ) ; ) . </p></li><li><p> 21</p><p> - , MATLAB - . </p><p> -</p><p> . , -. . </p><p> - MATLAB, -, - . -, , - MATLAB, -, , , . - - . </p><p> MATLAB . , A = zeros(10, 10) 1010, double. - s = 'Hello world' char. </p><p> . . - . </p><p> -, </p><p> , @. </p><p> -, -</p><p> . - @. </p></li><li><p> 22</p><p> , (-) . </p><p> isa class. , . </p><p> isa(a, 'class_name') , a . </p><p> class - . </p><p> class(a) , a. </p><p> . </p><p>b = class_name(a), a , class_name. MATLAB class_name - a. - . class_name, MATLAB - , . </p><p> double char. double - MATLAB, - . char . </p><p> MATLAB , - . , , , MATLAB , . . : </p><p>1. , , , . , . </p></li><li><p> 23</p><p>2. , , , , . . </p><p>3. , : </p><p>) , -; </p><p>) , - ; </p><p>) , - ; </p><p>) . . -</p><p> . , , , , - . , , . . , private, @class_name. </p><p> MATLAB, . - . - - . </p><p> . - MATLAB . - - - . </p><p> . -, . - , MATLAB -</p></li><li><p> 24</p><p> , . </p><p> 1. , </p><p>, . 1. -</p><p> : &gt;&gt; A(1,1)={[1 4 3; 0 5 8; 7 2 9]}; &gt;&gt; A(1,2)={'Anne Smith'}; &gt;&gt; A(2,1)={3+7i}; &gt;&gt; A(2,2)={-pi:pi/10:pi}; &gt;&gt; A A = [3x3 double] 'Anne Smith' [3.0000+ 7.0000i] [1x21 double] 2. -</p><p> : &gt;&gt; A{1, 1} = [1 4 3; 0 5 8; 7 2 9]; &gt;&gt; A{1, 2} = 'Anne Smith'; &gt;&gt; A{2, 1} = 3+7i; &gt;&gt; A{2, 2} = -pi:pi/10:pi A = [3x3 double] 'Anne Smith' [3.0000+ 7.0000i] [1x21 double] 3. </p><p>celldisp: &gt;&gt; celldisp(A) A{1,1} = </p></li><li><p> 25</p><p> 1 4 3 0 5 8 7 2 9 A{2,1} = 3.0000 + 7.0000i A{1,2} = Anne Smith A{2,2} = Columns 1 through 9 -3.1416 -2.8274 -2.5133 -2.1991 -1.8850 -1.5708 -1.2566 </p><p>-0.9425 -0.6283 Columns 10 through 18 -0.3142 0 0.3142 0.6283 0.9425 1.2566 1.5708 1.8850 </p><p>2.1991 Columns 19 through 21 2.5133 2.8274 3.1416 2. , , </p><p> . 1. : &gt;&gt; S.name = 'Ed'; &gt;&gt; S.fam = 'Plum'; &gt;&gt; S.year = 1979 S = name: 'Ed' fam: 'Plum' year: 1979 &gt;&gt; S(2).name = 'Tony'; </p></li><li><p> 26</p><p>&gt;&gt; S(2).fam = 'Miller'; &gt;&gt; S(2).year = 1980 S = 1x2 struct array with fields: name fam year &gt;&gt; S(3) = struct('name','Jerry','fam','Garcia','year',1981) S = 1x3 struct array with fields: name fam year 3. - </p><p> . 1. m- : % S % : % name, fam year disp(' '); S.name=input('name = '); S.fam=input('fam = '); S.year=input('year = '); disp(S) 2. strdialog.m. 3. MATLAB : &gt;&gt; strdialog </p></li><li><p> 27</p><p> , xmin xmax . </p><p> 4. , </p><p> MATLAB, - Neural Network Toolbox (NNT, ) - network, - , , , - . - - . </p><p> 5. </p><p>network, , - network . </p><p> 6. network, -</p><p> net = network, , </p><p> celldis. 7. network, -</p><p> net = network(2,3,[1;0;0], [11;00;00], ... [000;100;010], [001], [001], , </p><p> celldis. </p><p> 8. gensim(net), , network. , . </p></li><li><p> 28</p><p> 3 </p><p> : -, , , - Simulink - MATLAB. </p><p> . . 3.1,. </p><p>. 3.1. </p><p> w, w*p , - . </p><p>, . 3.1,, - b. w*p - b. </p></li><li><p> 29</p><p> , , 1. n - - b. - f; . w b -. , - . - , -; , -, . </p><p> a = f(w*p+b*l). , b -</p><p> , , 1, , - </p><p>[ ] </p><p>=1p</p><p>bwa . </p><p> ( ) </p><p> . f, , n - . </p><p> -. </p><p>hardlim. = hardlim(n) = 1(n) . 3.2. 0, n &lt; 0, 1, n &gt;= 0. </p></li><li><p> 30</p><p> . 3.2. hardlim </p><p> Neural Network Toolbox - hardlim, - . </p><p> purelin. - = purelin(n) = n . 3.3. </p><p> . 3.3. purelin </p></li><li><p> 31</p><p> logsig. -</p><p> = logsig(n) = 1/(1 + (-n)) - . 3.4. -, + , 0 1. Neural Network Toolbox - logsig. - - . </p><p>. 3.4. logsig </p><p> . . </p><p> Neural Network Toolbox . MATLAB, . </p><p> R Rppp ,,, 21 K </p><p> . 3.5. Rwww 11211 ,,, K </p></li><li><p> 32</p><p> . - W . </p><p> . 3.5. </p><p> b, . n </p><p>bpwpwpwn RR ++++= 1212111 K f. MATLAB : </p><p>n = W*p + b. , . 3.5, -</p><p> . , , (. 3.6). </p><p> , R. - Rxl. - W R. , 1 , - b. n - b W*p. -</p></li><li><p> 33</p><p> f, - , . - , . 3.6, . W, b, - W*p, f. - . </p><p> . 3.6. </p><p> , , - . - . </p><p> - ; - . 3.7, ; -; . </p></li><li><p> 34</p><p> . 3.7. </p><p> 1. -</p><p> hardlim dhardlim, - : </p></li><li><p> 35</p><p>plot (n,da,c) % ; </p><p>3. dA_dN N, : </p><p>N=[-0,7; 0,1; 0,8]; A=hardlim(N) % ; dA_dN= dhardlim(N,A) % . 4. </p><p> - hardlimfile. 2. -</p><p> hardlims dhardlims, </p></li><li><p> 36</p><p> 4. poslin dposlin, </p><p> 0, </p><p> , - , - hardlimfile. sat-linfile. </p><p> 6. satlins </p><p> dsatlins, - </p><p> -1, n &lt; -1; </p><p>satlins(n) = n, -1 n 1; 1, n &gt; 1, </p></li><li><p> 37</p><p> 0, n &lt; -1; </p><p>dsatlins(n) = 1, -1 n 1 0, n &gt; 1, </p><p> , - , - hardlimfile. sat-linsfile. </p><p> 7. radbas dradbas, </p><p>radbas = e-2n, dradbas = -2ne-2n, </p><p> , - , - hardlimfile. radbasfile. </p><p> 8. tribas - dtribas, </p><p> 0, n &lt; -1; tribas(n) = 1-abs(n), -1 n 1; 0, n &gt; 1, </p><p> 0, n &lt; -1; dtribas(n) = 1, -1 n 0 </p><p> -1, 0 &lt; n 1 0, n &gt; 1, </p><p> , - , - hardlimfile. tri-basfile. </p><p> 9. logsig - dlogsig </p></li><li><p> 38</p><p>logsig(n) = 1 / (1 + e-n); dlogsig(n) = e-n / (1 + e-n)2, </p><p> , - hardlimfile. logsigfile. </p><p> 10. -</p><p> tansig dtansig - </p><p>tansig(n) = 2 / (1 + e-2n) 1; dtansig(n) = 1 tansig2(n), </p><p> , - , - hardlimfile. tan-sigfile. </p><p> 11. compet -</p><p> : </p><p>1. : </p><p> Name = compet(name) % cometitive; Dname = compet(driv) % ; Inrange = compet(active) % -in : inf; Outrange = compet(outrut) % 0 1. 2. </p><p> , : N = [0; 1; - 0.5; 0.5]; A = compet(n); </p></li><li><p> 39</p><p>subplot(2, 1, 1), % 21; 1-; bar(n), % ; ylabet(n) % ; subplot(2, 1, 2), bar(a), ylabet(a) % 2- . </p><p>3. - competlile. </p><p> 12. 11- -</p><p> softmax, - softmaxfile. </p><p> 13. </p><p> hardlim W b , - , . . , . </p><p> 14. 1 2 </p><p> hardlim , - . </p><p> 15. 1 2 </p><p> hardlim W11 W12 b , - : </p><p>) {00, 01} , {10, 11} ; ) {11} , {00, 01, 10} ; ) {00, 11} , {01, 10} ; ) {00, 11} , {01, 10} . </p></li><li><p> 40</p><p> 16. 1 2 hardlim , </p><p>W11p1 + W12p2 + b = 0, , W11 W12 b . , 1 2 , . </p><p> 17. -</p><p> Simulink MATLAB ( - , ) 1 16 , - Simulink. </p></li><li><p> 41</p><p> 4 </p><p> : , - - network, , -, , , Neural Network Toolbox MATLAB. </p><p> , , , , , , () . </p><p> , . - , . . , , , , - , . , , , -. , . </p></li><li><p> 42</p><p>, , . , , . . . </p><p> - , , , - , , - . , . . - . , - (FF-net). </p><p> . - , , . -. </p><p> - , , Neural Network Toolbox - MATLAB Simulink . , . , -, MATLAB. - , , , (- ) , , ( ) . - - gensim. </p></li><li><p> 43</p><p> , . </p><p> , - , network, - , , -, , . Net-work , - - , , - . - - . </p><p> 1. </p><p> , , </p><p> Net = network (numInputs, numLayers, biasConnect, imputConnect, </p><p>layerConnect, outputConnect, tartegtConnect). , -</p><p> , . , . </p><p> : </p><p> numImputs=2 ; numLayers=3 ; biasConnect=[1; 0; 0] -</p><p> numLayers * 1; </p></li><li><p> 44</p><p>inputConnect=[1 1; 0 0; 0 0] numLayers * numImputs; </p><p>layerConnect=[0 0 0;1 0 0 0 ; 0 1 0] - numLayers * numLayers; </p><p>outputConnect=[0 0 1] - 1* numLayers; </p><p>targetConnect=[0 0 1] 1 * numLayers. </p><p> : 1. , net = network (2, 3, [1; 0; 0], [1 1; 0 0 ; 0 0], . , [0 0 0 ; 1 0 0 ; 0 1 0], [0 0 1]) 2. </p><p> net . 3. , -</p><p>numOutputs = 1 ; numTargets = 1 ; numInputDelays = 0 </p><p> . numLayersDelays = 0 </p><p> . </p><p>, - . , . . numInputDelays NumLayerDelays - . </p></li><li><p> 45</p><p>4. , - gensim(net) - . NNT : </p><p>) Neural Network - p{1}, p{2}, y{1}; </p><p>) Input1 , p{1} Input2 , p{2}; ) y{1}; ) L...</p></li></ul>

Recommended

View more >