Classification of two types of specimens by single neuron structure Sensor

Source: Internet
Author: User

 

 

1 % Sensor classification problems. X is the input sample, and T is the target vector.
2 Clear
3 % X = [ - 0.5 , - 0.5 , 0.3 , 0.1 , - 0.1 , 0.8 , 0.2 , 0.3 ;
4 % 0.3 , - 0.2 , - 0.6 , 0.1 , - 0.5 , 1.0 , 0.3 , 0.9 ];
5 % T = [ 0 , 0 , 0 , 1 , 0 , 1 , 1 , 1 ]; M = 100 ;
6 % E = [ 0.01 ; 0.01 ; 0.0 ; 0.0 ; 0.01 ; 0.01 ; 0.01 ; 0.01 ];
7
8
9 % Logical or classification instance
10 X = [ 0 , 0 , 1 , 1 ;
11 0 , 1 , 0 , 1 ];
12 T = [ 0 , 1 , 1 , 1 ];
13 M = 100 ;
14 E = [ 0.1   0.1   0.1   0.1 ] ';
15
16 % Classification of two types of specimens by single neuron structure Sensor
17 [R, Q] = Size (X ); % R = 2 ; Q = 8 is the dimension of array X;
18 [S, q] = Size (t ); % S = 1 ; Q = 8 is the dimension of the T array;
19 W = Rands (S, R ); % Generates initial values of random weight array W based on the dimensions of input sample X and target vector T;
20 % W = [ - 0.1   0.2 ];
21 C = Rands (S, 1 ); % Generate initial Random threshold values;
22 Y = W * X + C; % Computing sensor output;
23 F = Zeros ([S q]); % Initialize and allocate memory
24 For J = 1 : M % Cycle start
25 For I = 1 : Q % Classification of sensor output;
26 If Y ( 1 , I) > 0 ; % Evaluate the output after the sensor threshold value is triggered;
27 F ( 1 , I) = 1 ;
28 Else
29 F ( 1 , I) = 0 ;
30 End
31 End
32 If All (F = T) % The weight array and threshold are corrected when the output values of sensor F and target t are not equal;
33 Break
34 End
35 DC = 0.1 * (T -F ) * E; % Threshold Value correction;
36 C = C + DC; % Threshold Value correction;
37 DW = (T -F ) * X '; % Weight increment
38 W = W + DW; % Dynamic Weight
39 Y = W * X + C;
40 End % Loop ends
41 Plotpv (x, t ); % Painting point, drawing classification Mode
42 Plotpc (W, C ); % Draw the dividing line and draw the decision Surface
43 Grid on
44 Xlabel ('x1 '), ylabel ('x2 ');
45 Title (sprintf ('( % F) x1 + ( % F) x2 + ( % F) ', w ( 1 ), W ( 2 ), C ));
46

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.