Home > Articles > Programming > Java

  • Print
  • + Share This
Like this article? We recommend

Output Computation Method

I will now show you how the neural network is trained and how the output from the neural network is calculated. To train the neural network, we first present the neural network with an input and then observe the output. This output is then compared against the expected output. If there is a difference, the weight matrix of the neural network is adjusted so that the next time the input is presented, you will be more likely to receive the expected output.

The output computation method allows you to present a pattern to the input layer and receive a pattern back from the output layer. Both the input and output patterns are passed using an array of doubles. The signature for the output computation method is shown here:

public double []computeOutputs(double input[])

As you can see, an array of doubles is passed to the output computation method. The size of this array must correspond to the number of input neurons for the neural network. An array will be returned from this method. The array that is returned will have one element that represents the output of each of the output neurons. The following code shows how you would present a simple two-number pattern to the output computation method and display the result.

double input[] = { 0.0, 1.0 };
double output[];

output = neural.computeOutputs(input);

for(int i=0;i<output.length;i++)
{
 System.out.println( output[i] );
}

This code passes the input array to the output computation method and receives the output from the neural network. The output from this method may not match the desired output. To calculate the amount of error in the output of the neural network, you can use the error-calculation methods discussed in the next section.

  • + Share This
  • 🔖 Save To Your Account