Esempio n. 1
0
 public WeightVector RunIterations(WeightVector weightVector, int iterationCount)
 {
     for (int iter = 0; iter < iterationCount; iter++)
     {
         Console.WriteLine(DateTime.Now + " running iteration " + iter);
         var newWeightVector = new WeightVector(weightVector.FeatureKDictionary);
         SetForwardBackwordAlgo(weightVector);
         //for (var k = 0; k < weightVector.FeatureKDictionary.Count; k++)
         for (var k = weightVector.FeatureKDictionary.Count-1; k >= 0; k--)
         {
             if (k%100 == 0)
             {
                 Console.WriteLine(DateTime.Now + " running iteration for k " + k);
             }
             var wk = Compute(k, weightVector);
             wk = weightVector.Get(k) + _lambda*wk;
             newWeightVector.SetKey(k, wk);
         }
         weightVector = newWeightVector;
     }
     _weightVector = weightVector;
     return weightVector;
 }
 public void ComputeRange(int start, int end, WeightVector newWeightVector, int threadIndex = 0)
 {
     for (var k = start; k < end; k++)
     {
         if (k % 100 == 0)
         {
             Console.WriteLine(DateTime.Now + "threadIndex: " + threadIndex +
                 " running iteration for k " + k);
         }
         var wk = Compute(k);
         if (double.IsNaN(wk) || double.IsInfinity(wk))
         {
             Console.WriteLine("k: "+ k + "wk is infiity of nana"+ wk);
             //Logger.Flush(false);
         }
         newWeightVector.SetKey(k, wk);
     }
 }