1

Character Recognition Phase of a Neural Network

Even though it is a very important (if not the most important) phase in the operation of a neural net, the recognition phase is a rather simple phase.

As we have noted earlier, recognition is done in the following steps:

  1. The input neurons receive the pixel data from the image.
  2. Each input neuron calculates its output.
  3. This output is fed directly to the neurons in the hidden layer.
  4. The neurons in the hidden layer calculate their output.
  5. This output is fed to the neurons in the output layer.
  6. The neurons in the output layer calculate their output.
  7. The output of the output layer is our result. We interpret it the way we want.

Let us go through the source code again:

// file: neuralNetwork.cpp  
	 
	char neuralNetwork::Recognize(int  * Input_Array){  
		Find_Output_InputLayer(Input_Array);  
		Find_Output_HiddenLayer();  
		Find_Output_OutputLayer();  
		return Output();  
	}

	void neuralNetwork::Find_Output_InputLayer(int * Input_Array){  
		// The intput is  fed directly to the output  
		for(int i=0; i<NO_INPUT; i++){  
			Output_Of_InputLayer[i] = (double)Input_Array[i];  
		}  
	}  
	  
	void neuralNetwork::Find_Output_HiddenLayer(){  
		for(int i=0; i<NO_HIDDEN; i++){  
			Output_Of_HiddenLayer[i] =   
					hiddenNeurons[i].Output(Output_Of_InputLayer, NO_INPUT);
		}  
	}  
	  
	void neuralNetwork::Find_Output_OutputLayer(){  
		for(int i=0;i<NO_OUTPUT;i++){  
			Output_Of_OutputLayer[i] =   
					outputNeurons[i].Output(Output_Of_HiddenLayer, NO_HIDDEN);  
		}  
	}  
	  
	// Returns an index to the array: "ABCDEFGHIJKLMNOPQRSTUVWXYZ"  
	int neuralNetwork::Output(){  
		int index = 0;  
		int i,j=1;  
		for(i = 0; i < NO_OUTPUT; i++,j *=2){  
			index += j * (Output_Of_OutputLayer[NO_OUTPUT-(i+1)] > 0.5 ? 1 : 0);  
		}  
		return  index;  
	}

We can see that in the Recognize() method each layer starting from the input layer calculate it's output. When the output layer calculates it's output, the array Output_Of_OutputLayer[4 decimal numbers] contains the result of the neural net operation. What we mean by a layer calculating it's output is that each neuron in the layer calculates:

  1. The product of each input signal and weight assigned to the input node: Wi * Xi
  2. The sum of all products calculated in the first step: sum(Wi * Xi)
  3. Applies the sigmoid function to find the value of the output to be given.