예제 #1
0
        public unsafe double getRandomAccuracy(IFeedResultNN nn, double level, int sampleSize)
        {
            int incorrectResults = 0;

            //for every training input array
            for (int tp = 0; tp < sampleSize; tp++)
            {
                int index = rand.Next(size);
                //feed inputs through network and backpropagate errors
                var ot = nn.feedResult(inputs[index]);

                //correct pattern flag

                //check all outputs against desired output values
                for (int k = 0; k < ot.Length; k++)
                {
                    //set flag to false if desired and output differ
                    if (ot[k] > outputs[index][k] + level || ot[k] < outputs[index][k] - level)
                    {
                        incorrectResults++;
                        break;
                    }
                }
                //inc training error for a incorrect result
            }            //end for

            //calculate error and return as percentage
            return(1 - incorrectResults / (double)(sampleSize));
        }
예제 #2
0
 static void printAnswer(IFeedResultNN nn)
 {
     double[] first = new double[nI] {
         0.1, -0.7, 0.3, 0.99, -0.2, -0.4, 0.3, 0.1, -0.9, -0.2
     };
     WriteLine(string.Join(" ", nn.feedResult(first).Select(o => o.ToString("N2"))));
 }
예제 #3
0
        public unsafe double getMSE(IFeedResultNN nn)
        {
            double mse = 0;

            double[] ot = new double[0];
            //for every training input array
            for (int tp = 0, l = size; tp < l; tp++)
            {
                //feed inputs through network and backpropagate errors
                ot = nn.feedResult(inputs[tp]);

                //check all outputs against desired output values
                for (int k = 0; k < ot.Length; k++)
                {
                    //sum all the MSEs together
                    mse += Abs(ot[k] - outputs[tp][k]);
                }
            }            //end for

            //calculate error and return as percentage
            return(mse / (ot.Length * size));
        }
예제 #4
0
 public neuralPlayer(IFeedResultNN net, StdSerializers.ISerializer ser) : base((arr) => net.feedResult(arr)[0], ser)
 {
     nn = net;
 }