コード例 #1
0
 /// <summary>
 /// Induces the layer of this perceptron from the specified set of examples
 /// </summary>
 /// <param name="innds">a set of training examples for constructing the layer of this perceptron.</param>
 /// <param name="numberofEpochs">the number of training epochs to be used.</param>
 public void TrainOn(NeuralNetworkDataSet innds, int numberofEpochs)
 {
     for (int i = 0; i < numberofEpochs; ++i)
     {
         innds.RefreshDataset();
         while (innds.HasMoreExamples())
         {
             NeuralNetworkExample nne = innds.GetExampleAtRandom();
             ProcessInput(nne.GetInput());
             Vector error = layer.ErrorVectorFrom(nne.GetTarget());
             ProcessError(error);
         }
     }
 }
コード例 #2
0
 /// <summary>
 /// Returns the accuracy of the hypothesis on the specified set of examples
 /// </summary>
 /// <param name="nnds">the neural network data set to be tested on.</param>
 /// <returns>the accuracy of the hypothesis on the specified set of examples</returns>
 public int[] TestOnDataSet(NeuralNetworkDataSet nnds)
 {
     int[] result = new int[] { 0, 0 };
     nnds.RefreshDataset();
     while (nnds.HasMoreExamples())
     {
         NeuralNetworkExample nne = nnds.GetExampleAtRandom();
         Vector prediction        = Predict(nne);
         if (nne.IsCorrect(prediction))
         {
             result[0] = result[0] + 1;
         }
         else
         {
             result[1] = result[1] + 1;
         }
     }
     return(result);
 }