Exemple #1
0
 /// <summary>
 /// Reads each of the file in _trainngGamesPath Directory
 /// and trains the NeuralNetwork
 /// </summary>
 public AIPredictor()
 {
     foreach (string s in Directory.EnumerateFiles(_trainingGamesPath))
     {
         GameRegister g = new GameRegister();
         g.LoadStates(s);
         NeuralNetwork.Train(g);
     }
     Console.WriteLine("AIPredictor succesfully created...");
 }
Exemple #2
0
        public void Train(GameRegister trainingGame)
        {
            FeaturesState[] states = trainingGame.States;
            for (int i = 0; i < weights.Length; i++)
            {
                double derivativesSum = 0;

                for (int t = 0; t < states.Length - 1; t++)
                {
                    double propagationSum = 0;
                    for (int j = t; j < states.Length - 1; j++)
                    {
                        propagationSum += Math.Pow(propagationRate, j - t) * Variation(states[t], states[t + 1]);
                    }

                    derivativesSum += MathUtilities.SigmoidDerivative(Score(states[t])) * states[t].GetNormalizedVector()[i] * propagationSum;
                }
                weights[i] += learningRate * derivativesSum;
            }
        }