示例#1
0
 public static void Training()
 {
     for (int i = 0; i < SaveState; i++)
     {
         List <Network> ntw   = new List <Network>();
         var            tasks = new Task[batchsize];
         for (int j = 0; j < batchsize; j++)
         {
             //B/c ii may change and this code can't let that happen
             int iterator = j;
             double[,] image = Reader.ReadNextImage();
             int correct = Reader.ReadNextLabel();
             ntw.Add(new Network());
             tasks[iterator] = Task.Run(() => ntw[iterator].Backprop(image, correct));
         }
         Task.WaitAll(tasks);
         //Syncronously descend
         foreach (Network nn in ntw)
         {
             nn.Descent();
         }
         //Updating the weights with the avg gradients
         Network.Descent(batchsize);
         UserValidation();
     }
     //Save weights and biases
     NetworkParametersHandler.WriteWeightBias();
 }
示例#2
0
        //Reset (re-initialize) weights and biases of the neural network
        public static void reset()
        {
            Network nn = new Network();

            nn.initialize();
            NetworkParametersHandler.WriteWeightBias();
        }