Example #1
0
        public IEnumerable <TrainingCollection> AsBatches(int batchsize)
        {
            if (batchsize < 1)
            {
                throw new ArgumentException("Attempt to creat batches with < 1 elements each.");
            }

            int count = 0;
            TrainingCollection workingCollection = new TrainingCollection();

            foreach (VectorPair pair in this)
            {
                if (count == batchsize)
                {
                    yield return(workingCollection);

                    workingCollection.Clear();
                    count = 0;
                }

                workingCollection.Add(pair);
                count++;
            }

            yield return(workingCollection);
        }
Example #2
0
 public void Train(TrainingCollection trainingdata)
 {
     _costAccumulator = 0;
     foreach (VectorPair tv in trainingdata)
     {
         _runAndBackPropagate(tv);
     }
     _component.Update(_strategy);
 }
Example #3
0
 public void ParallelTrain(TrainingCollection trainingdata)
 {
     _costAccumulator = 0;
     Parallel.ForEach(
         trainingdata,
         tv =>
     {
         _runAndBackPropagate(tv);
     }
         );
     _component.Update(_strategy);
 }