Exemplo n.º 1
0
 public unsafe void UpdateWeights(Trainable v, Tensor g)
 {
     //Console.WriteLine("Updating The Variable with ID " + v.UniqueId); trainable should have uniqueID
     //Console.Write("Updating The Variable with ID " + v.UniqueId);
     //Console.WriteLine(" -> " + g);
     if (g.Shape.EqualShape(v.Weights.Shape))
     {
         float *ptr_v = (float *)v.Weights.Array;
         float *ptr_m = (float *)g.Array;
         VectorizationFloat.ElementWiseAddAVXBetaB(ptr_v, ptr_m, ptr_v, v.Weights.Shape.TotalSize, -v.LearningRateMultiplier * Hyperparameters.LearningRate);
     }
     else
     {
         throw new DimensionIncompability("The shapes of Variable and Gradient are different!");
     }
 }