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); }
public void Train(TrainingCollection trainingdata) { _costAccumulator = 0; foreach (VectorPair tv in trainingdata) { _runAndBackPropagate(tv); } _component.Update(_strategy); }
public void ParallelTrain(TrainingCollection trainingdata) { _costAccumulator = 0; Parallel.ForEach( trainingdata, tv => { _runAndBackPropagate(tv); } ); _component.Update(_strategy); }