// Batch Iteration: protected override double ExecuteBatchIteration(VectorFlowBatch<float> batch, double[] resultErrors) { // Begin of batch: beginOfBatch = true; if (Mode == TrainingMode.Unordered) { // Reset backward values, and clear error information: ResetGradientComputingValues(); numberOfIterationsInBatch = 0; } double error = base.ExecuteBatchIteration(batch, resultErrors); Debug.Assert(batch.VectorFlows.Count == resultErrors.Length); Debug.Assert(numberOfIterationsInBatch >= resultErrors.Length); // Batch done, iterate algos: Network.CallErrorBasedBatchLearningAlgorithms(numberOfIterationsInBatch, error); // Batch done. Yeah. return error; }
// Batch: protected override double ExecuteBatch(VectorFlowBatch<double> batch, double[] resultErrors) { EnsureScriptRun(); if (!IsStreamed) { // Begin of batch: isNewBatchState = true; // Reset backward values, and clear error information: ResetBackwardValues(true); } else // Streamed { // Reset backward values, but preserve error information: ResetBackwardValues(false); } double error = base.ExecuteBatch(batch, resultErrors); // Batch done, iterate algos: foreach (var bwa in backwardLearningAlgos) bwa.BackwardIteration(true, error); // Batch done. Yeah. return error; }
// Batch Iterations: protected override BatchExecutionResult LockedDoBatchExcuteIterations(VectorFlowBatch<float> batch, Action<BatchExecutionResult> iterationCallback) { // This is where batch iterations begins EnsureInitialized(); var neuralBatch = batch as NeuralVectorFlowBatch; if (neuralBatch != null && Mode == TrainingMode.Streamed && neuralBatch.ResetSchedule == ResetSchedule.BeforeExecution) { // Streamed reset scheduled: ResetAll(); } var result = base.LockedDoBatchExcuteIterations(batch, iterationCallback); if (neuralBatch != null && Mode == TrainingMode.Streamed && neuralBatch.ResetSchedule == ResetSchedule.AfterExecution) { // Streamed reset scheduled: ResetAll(); } return result; }
protected override BatchExecutionResult BatchExecution(VectorFlowBatch<double> batch, Action<BatchExecutionResult> iterationCallback) { var neuralBatch = batch as NeuralBatch; if (batch != null) { // If completelly new training set execution begins: if (neuralBatch.ResetSchedule == TrainingResetSchedule.BeforeExecution && !Network.IsFeedForward) { ResetForwardValues(); ResetBackwardValues(true); } } var result = base.BatchExecution(batch, iterationCallback); if (batch != null) { // If completelly new training set execution begins: if (neuralBatch.ResetSchedule == TrainingResetSchedule.AfterExecution && !Network.IsFeedForward) { ResetForwardValues(); ResetBackwardValues(true); } } return result; }
// Batch Iteration: protected override double ExecuteBatchIteration(VectorFlowBatch<double> batch, double[] resultErrors) { // Begin of batch: beginOfBatch = true; if (Mode == TrainingMode.Unordered) { // Reset backward values, and clear error information: ResetBackwardValues(); } else // Streamed { // Reset backward values, but preserve error information: ResetBackwardValuesButPreserveErrors(); } double error = base.ExecuteBatchIteration(batch, resultErrors); Debug.Assert(batch.VectorFlows.Count == resultErrors.Length); // Batch done, iterate algos: BackwardBatchAlgoIteration(resultErrors.Length, error); // Batch done. Yeah. return error; }
// Batch Iterations: protected override BatchExecutionResult LockedDoBatchExcuteIterations(VectorFlowBatch<double> batch, Action<BatchExecutionResult> iterationCallback) { EnsureInitizalized(); // This is where batch iterations begins var neuralBatch = batch as NeuralVectorFlowBatch; if (neuralBatch != null) { // Before iterations if (neuralBatch.ResetSchedule == ResetSchedule.BeforeExecution && Network.IsRecurrent) { // Recurrent reset scheduled: ResetAll(); } } var result = base.LockedDoBatchExcuteIterations(batch, iterationCallback); if (neuralBatch != null) { // After iterations if (neuralBatch.ResetSchedule == ResetSchedule.AfterExecution && Network.IsRecurrent) { // Recurrent reset scheduled: ResetAll(); } } return result; }
// Batch Iteration: protected override void ExecuteBatchIteration(VectorComputationContext context, VectorBuffer<float> vectorBuffer, VectorFlowBatch<float> batch) { var ctx = (NeuralComputationContext)context; // Begin of batch: ctx.Training_BeginOfBatch = true; if (Mode == TrainingMode.Unordered) { // Reset backward values, and clear error information: ResetGradientComputingValues(ctx); ctx.Training_NumberOfIterationsInBatch = 0; } base.ExecuteBatchIteration(context, vectorBuffer, batch); // Batch done, iterate algos: Network.CallErrorBasedBatchLearningAlgorithms(ctx, ctx.Training_NumberOfIterationsInBatch, AverageErrorBuffer); }
// Batch Iterations (all repeated): protected override void DoExecuteBatch(VectorComputationContext context, VectorBuffer<float> vectorBuffer, VectorFlowBatch<float> batch) { // This is where batch iterations begins var ctx = (NeuralComputationContext)context; EnsureInitialized(ctx); var neuralBatch = batch as NeuralVectorFlowBatch; if (neuralBatch != null && Mode == TrainingMode.Streamed && neuralBatch.ResetSchedule == ResetSchedule.BeforeExecution) { // Streamed reset scheduled: ResetAll(ctx); } base.DoExecuteBatch(context, vectorBuffer, batch); if (neuralBatch != null && Mode == TrainingMode.Streamed && neuralBatch.ResetSchedule == ResetSchedule.AfterExecution) { // Streamed reset scheduled: ResetAll(ctx); } }