예제 #1
0
        private void runBatch(ClassifiedSample <double[][, ]> sampleBatch)
        {
            // loop over batch
            if (m_UseBatchParallelization)
            {
                Parallel.ForEach(sampleBatch, pdata => m_BatchContext.Push(pdata.Key, pdata.Value));
            }
            else
            {
                foreach (var pdata in sampleBatch)
                {
                    runIteration(pdata.Key, pdata.Value);
                }
            }

            // optimize and apply updates
            m_Optimizer.Push(Net.Weights, m_Gradient, m_LearningRate);

            // update batch stats
            m_Iteration += m_BatchSize;
            m_Batch++;
            m_Step2         = m_Optimizer.Step2;
            m_PrevLossValue = m_LossValue;
            m_LossValue     = m_IterLossValue;
            m_LossDelta     = m_LossValue - m_PrevLossValue;
            m_IterLossValue = 0.0D;

            if (BatchEndedEvent != null)
            {
                BatchEndedEvent(this, EventArgs.Empty);
            }
        }