Step 3:  

Each image will be of size nxm, but we'll reduce them to a small size of 5x5 pixels. This should be enough to distinguish the 5 images as different patterns.  We will write this program so that the input matrix (X) will be 3 dimensional with the third dimension corresponding to different animals.  So the matrix X will be a 5x5x5, with the first two numbers designating a 5x5 image, and the third 5 corresponding the the five animals (each page of the 3rd dimension contains data for one animal; 5 pages for 5 animals).





We'll create a variable x (lower case) in which we'll store the info for each animal.  We will then reshape the 5x5 matrix to a 25x1 vector so that we could input the data to the network.  The network will therefore have 25 input nodes.  We will also create a variable d to hold the correct answer for each of the 5 animals.


function [W1, W2] = MultiClass(W1, W2, X, D);

alpha =0.9;
 
for k=1:5    %because we have 5 animals

    x=reshape(X(:,:,k),25,1);  %take a 5x5 matrix and make it a 25x1 matrix
    d= D(k,:)'; %note the transpose symbol '


end;  % for k=1:5