Exemplo n.º 1
0
        /// <summary>
        /// The OnGetStatus callback fires on each iteration within the Train method.
        /// </summary>
        public void OnUpdateStatus(GetStatusArgs e)
        {
            if (m_icallback != null)
            {
                m_dfLoss      = e.Loss;
                m_nIteration  = e.Frames;
                m_nIterations = e.MaxFrames;
                m_dfAccuracy  = e.Reward;

                Dictionary <string, double> rgValues = new Dictionary <string, double>();
                rgValues.Add("GlobalIteration", e.Frames);
                rgValues.Add("GlobalLoss", e.Loss);
                rgValues.Add("LearningRate", e.LearningRate);
                rgValues.Add("GlobalAccuracy", e.Reward);
                m_icallback.Update(TrainingCategory, rgValues);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// The OnGetStatus callback fires on each iteration within the Train method.
        /// </summary>
        public void OnUpdateStatus(GetStatusArgs e)
        {
            m_nIteration             = e.Iteration;
            m_dfAccuracy             = e.TotalReward;
            m_nIterations            = e.MaxFrames;
            m_dfImmediateRewards     = e.Reward;
            m_dfGlobalRewards        = e.TotalReward;
            m_dfGlobalRewardsMax     = Math.Max(m_dfGlobalRewardsMax, e.TotalReward);
            m_dfGlobalRewardsAve     = (1.0 / (double)m_nThreads) * e.TotalReward + ((m_nThreads - 1) / (double)m_nThreads) * m_dfGlobalRewardsAve;
            m_dfExplorationRate      = e.ExplorationRate;
            m_dfOptimalSelectionRate = e.OptimalSelectionCoefficient;

            if (m_nThreads > 1)
            {
                m_nGlobalEpisodeCount++;
            }
            else
            {
                m_nGlobalEpisodeCount = e.Frames;
            }

            m_nGlobalEpisodeMax = e.MaxFrames;
            m_dfLoss            = e.Loss;

            if (m_icallback != null)
            {
                Dictionary <string, double> rgValues = new Dictionary <string, double>();
                rgValues.Add("GlobalIteration", GlobalEpisodeCount);
                rgValues.Add("GlobalLoss", GlobalLoss);
                rgValues.Add("LearningRate", e.LearningRate);
                rgValues.Add("GlobalAccuracy", GlobalRewards);
                rgValues.Add("Threads", m_nThreads);

                m_icallback.Update(TrainingCategory, rgValues);
            }

            e.NewFrameCount = m_nGlobalEpisodeCount;

            if (e.Index == 0 && m_nSnapshot > 0 && m_nGlobalEpisodeCount > 0 && (m_nGlobalEpisodeCount % m_nSnapshot) == 0)
            {
                m_bSnapshot = true;
            }
        }