-6- Each S-unit is connected to some of the A-units(the A-units are the triangles in the diagram above). Here we show A-units connecting to two R-units,but that is just a feature of the way this particular perceptron is "wired".(Not all of the connections are shown,to reduce clutter in the diagram.)As mentioned above,the stimulus is a pattern of I's and 0's in the S-units,and the S-units that have ones in them are said to "fire"into the A-units that they are connected to.That means that the I's are sent from the S-units to the A-units they connect to. The A-units are"threshold"devices.They sum their inputs,and each A-unit whose sum is greater than or equal to a threshold fires into the R-units it connects to So one stimulus might cause some A- units to fire,and another stimulus might cause other A-units to fire.The value transmitted to the connected R-units is the sum times a"weight",and each A-to-R connection has a separate weight. Now we are ready to classify the stimulus.The R-units sum their inputs,and if,say,R-unit 2 has the highest value,then we classify the input as being an example of pattern 2. That's it.To recap: ?The stimulus causes some S-units to fire into A-units. ?A-units whose input exceeds a threshold fire through weighted connections into the R-units. The threshold is the same for all A-units. ?The R-unit with the biggest sum indicates the classification of the stimulus. To program a perceptron,we just need a bunch of arrays to hold the stimulus,connections,and weights.Since this is the array question,we should be ready to go!First we will define some constants that tell us the size of the perceptron and a few other things: #define N SUNITS 16 #define N AUNITS 16 #define N RUNITS #define N S TO A 6 #define N A TO R #define THRESHOLD 4 This perceptron has 16 S-units,16 A-units,and 4 R-units.Each S-unit connects to 6 A-units,and each A-unit connects to 4 R-units.The threshold for A-unit firing is 4.(Note that all this doesn't exactly match the diagram-as mentioned,we didn't want to clutter it with too many lines.) Next we need to store the S-to-A connections.Since each of the 16 S-units connects to 6 A-units, the perfect data structure is a 16 x 6 array,which we will call sA:
– 6 – Each S-unit is connected to some of the A-units (the A-units are the triangles in the diagram above). Here we show A-units connecting to two R-units, but that is just a feature of the way this particular perceptron is "wired". (Not all of the connections are shown, to reduce clutter in the diagram.) As mentioned above, the stimulus is a pattern of 1's and 0's in the S-units, and the S-units that have ones in them are said to "fire" into the A-units that they are connected to. That means that the 1's are sent from the S-units to the A-units they connect to. The A-units are "threshold" devices. They sum their inputs, and each A-unit whose sum is greater than or equal to a threshold fires into the R-units it connects to So one stimulus might cause some Aunits to fire, and another stimulus might cause other A-units to fire. The value transmitted to the connected R-units is the sum times a "weight", and each A-to-R connection has a separate weight. Now we are ready to classify the stimulus. The R-units sum their inputs, and if, say, R-unit 2 has the highest value, then we classify the input as being an example of pattern 2. That's it. To recap: ?? The stimulus causes some S-units to fire into A-units. ?? A-units whose input exceeds a threshold fire through weighted connections into the R-units. The threshold is the same for all A-units. ?? The R-unit with the biggest sum indicates the classification of the stimulus. To program a perceptron, we just need a bunch of arrays to hold the stimulus, connections, and weights. Since this is the array question, we should be ready to go! First we will define some constants that tell us the size of the perceptron and a few other things: #define N_SUNITS 16 #define N_AUNITS 16 #define N_RUNITS 4 #define N_S_TO_A 6 #define N_A_TO_R 4 #define THRESHOLD 4 This perceptron has 16 S-units, 16 A-units, and 4 R-units. Each S-unit connects to 6 A-units, and each A-unit connects to 4 R-units. The threshold for A-unit firing is 4. (Note that all this doesn’t exactly match the diagram—as mentioned, we didn’t want to clutter it with too many lines.) Next we need to store the S-to-A connections. Since each of the 16 S-units connects to 6 A-units, the perfect data structure is a 16 x 6 array, which we will call sA: sA
-7- Let's look at the values that might be stored on one row of this table,for example,row 5: 0 y ny 3 4 5 row 5 3 个 8 11 14 The value at sa[5][2]is 8,which tells us that S-unit 5 connects to A-unit 8.Taken as a whole,this row tells us that S-unit 5 connects to A-units 3,7,8,11,14,and 15.Clearly with a table like this we can specify all of the S-to-A connections. Now we just need another table to specify the connection from the A-units to the R-units.Since these are weighted connections,we will take a slightly different approach.We will use another table, called aR that has as many columns as there are R-units(4 in our case).aR[i]]is the weight of the connection from A-unit i to R-unit j.This table will be 16 x 4 in size,and a row might look like this (the data type is double): 0 2 row 10 1.20.80.0 1.4 Suppose the sum of the inputs to A-unit 10 is x,and x>=THRESHOLD.Then A-unit 10 sends a value of 1.2 x to R-unit 0,0.8 x to R-unit 1,0.o to R-unit 2 (the weight is zero),and 1.4* x to R-unit 3.Note:the weights are allowed to be negative. The processing at the R-units is easy:we just find the one with the largest total,and resolve ties any way we want to. Here is the declaration of the tables and some arrays you will need: int sAIN SUNITS][N S TO A]; double aR[N AUNITS][N RUNITS]; int s[N SUNITS]; int a[N AUNITS]; double r[N RUNITS]; The first two lines declare the connection tables,as described above.The array s is the stimulus, and the arrays a and give you a place to accumulate the sums for the A-units and R-units.Your job is to write three functions that simulate the operation of the perceptron: void FiresToA(int s[],int sA[][N_S_TO A],int a[]); void FireAToR(int a[],double aR[][N RUNITS],double r[]); int classifyPattern(double r[]);
– 7 – Let’s look at the values that might be stored on one row of this table, for example, row 5: The value at sA[5][2] is 8, which tells us that S-unit 5 connects to A-unit 8. Taken as a whole, this row tells us that S-unit 5 connects to A-units 3, 7, 8, 11, 14, and 15. Clearly with a table like this we can specify all of the S-to-A connections. Now we just need another table to specify the connection from the A-units to the R-units. Since these are weighted connections, we will take a slightly different approach. We will use another table, called aR that has as many columns as there are R-units (4 in our case). aR[i][j] is the weight of the connection from A-unit i to R-unit j. This table will be 16 x 4 in size, and a row might look like this (the data type is double): Suppose the sum of the inputs to A-unit 10 is x, and x >= THRESHOLD. Then A-unit 10 sends a value of 1.2 * x to R-unit 0, 0.8 * x to R-unit 1, 0.0 to R-unit 2 (the weight is zero), and 1.4 * x to R-unit 3. Note: the weights are allowed to be negative. The processing at the R-units is easy: we just find the one with the largest total, and resolve ties any way we want to. Here is the declaration of the tables and some arrays you will need: int sA[N_SUNITS][N_S_TO_A]; double aR[N_AUNITS][N_RUNITS]; int s[N_SUNITS]; int a[N_AUNITS]; double r[N_RUNITS]; The first two lines declare the connection tables, as described above. The array s is the stimulus, and the arrays a and r give you a place to accumulate the sums for the A-units and R-units. Your job is to write three functions that simulate the operation of the perceptron: void FireSToA(int s[], int sA[][N_S_TO_A], int a[]); void FireAToR(int a[], double aR[][N_RUNITS], double r[]); int ClassifyPattern(double r[]); 3 7 8 11 14 15 row 5 0 1 2 3 4 5 row 10 1.2 0.8 0.0 1.4 0 1 2 3