// A Flow: protected override double LockedExecuteVectorFlow(VectorFlow<float> vectorFlow) { if (Mode == TrainingMode.Unordered) { // Reset forward values: ResetNetworkValues(); // Reset backward errors and gradients: // If beginOfBatch == true, // backward errors and gradients already reseted by a ResetBackwardValues() call if (!beginOfBatch) { ResetPartialGradientComputingValues(); } } // Begin of recurrent flow: bpttEllapsedForwardIterationCount = 0; var result = base.LockedExecuteVectorFlow(vectorFlow); beginOfBatch = false; return result; }
// A Flow: protected override double LockedExecuteVectorFlow(VectorFlow<double> vectorFlow) { // Do forward iteration first: ForwardAlgoIteration(beginOfBatch); if (Mode == TrainingMode.Unordered) { // Reset forward values: ResetForwardValues(); // Reset backward errors and gradients: // If beginOfBatch == true, // backward errors and gradients already reseted by a ResetBackwardValues() call if (!beginOfBatch) { ResetBackwardErrorsAndGradients(); } } beginOfBatch = false; // Begin of recurrent flow: recurrentIterations = 0; return base.LockedExecuteVectorFlow(vectorFlow); }
// An entry: protected override double Excute(VectorFlow<double> vectorFlow) { // Do forward iteration first: foreach (var fwa in forwardLearningAlgos) fwa.ForwardIteration(isNewBatchState); if (!IsStreamed) { // Reset forward values: ResetForwardValues(); // Reset backward errors: if (!isNewBatchState) { ResetBackwardErrors(); } isNewBatchState = false; } // Track count to 0: infoTrackCountSoFar = 0; return base.Excute(vectorFlow); }
// A Flow: protected override void DoExecuteVectorFlow(VectorComputationContext context, VectorBuffer<float> vectorBuffer, VectorFlow<float> vectorFlow) { var ctx = (NeuralComputationContext)context; if (Mode == TrainingMode.Unordered) { // Reset forward values: ResetNetworkValues(ctx); // Reset backward errors and gradients: // If beginOfBatch == true, // backward errors and gradients already reseted by a ResetBackwardValues() call if (!ctx.Training_BeginOfBatch) { ResetPartialGradientComputingValues(ctx); } } // Begin of recurrent flow: ctx.Training_BPTTEllapsedForwardIterationCount = 0; base.DoExecuteVectorFlow(context, vectorBuffer, vectorFlow); ctx.Training_BeginOfBatch = false; }