Example #1
0
        /// <summary>
        /// Optionally overridden to return a new type of trainer.
        /// </summary>
        /// <remarks>
        /// Override this method when using the MyCaffeControl that uses the <i>double</i> base type.
        /// </remarks>
        /// <param name="caffe">Specifies the MyCaffeControl used.</param>
        /// <returns>The IxTraininer interface implemented by the new trainer is returned.</returns>
        protected virtual IxTrainerRL create_trainerD(Component caffe)
        {
            MyCaffeControl <double> mycaffe = caffe as MyCaffeControl <double>;

            m_nProjectID = mycaffe.CurrentProject.OriginalID;
            m_dsCi       = mycaffe.DatasetConnectInfo;

            int.TryParse(mycaffe.CurrentProject.GetSolverSetting("max_iter"), out m_nItertions);
            int.TryParse(mycaffe.CurrentProject.GetSolverSetting("snapshot"), out m_nSnapshot);

            switch (m_trainerType)
            {
            case TRAINER_TYPE.PG_SIMPLE:
                return(new pg.simple.TrainerPG <double>(mycaffe, m_properties, m_random, this));

            case TRAINER_TYPE.PG_ST:
                return(new pg.st.TrainerPG <double>(mycaffe, m_properties, m_random, this));

            case TRAINER_TYPE.PG_MT:
                return(new pg.mt.TrainerPG <double>(mycaffe, m_properties, m_random, this));

            default:
                throw new Exception("Unknown trainer type '" + m_trainerType.ToString() + "'!");
            }
        }
        /// <summary>
        /// Optionally overridden to return a new type of trainer.
        /// </summary>
        /// <remarks>
        /// Override this method when using the MyCaffeControl that uses the <i>double</i> base type.
        /// </remarks>
        /// <param name="caffe">Specifies the MyCaffeControl used.</param>
        /// <param name="stage">Specifies the stage under which the trainer is created.</param>
        /// <returns>The IxTraininer interface implemented by the new trainer is returned.</returns>
        protected virtual IxTrainer create_trainerD(Component caffe, Stage stage)
        {
            MyCaffeControl <double> mycaffe = caffe as MyCaffeControl <double>;

            m_nProjectID = mycaffe.CurrentProject.OriginalID;
            m_dsCi       = mycaffe.DatasetConnectInfo;

            int.TryParse(mycaffe.CurrentProject.GetSolverSetting("max_iter"), out m_nIterations);
            int.TryParse(mycaffe.CurrentProject.GetSolverSetting("snapshot"), out m_nSnapshot);

            m_properties.SetProperty("UsePreLoadData", m_bUsePreloadData.ToString());

            if (stage == Stage.RNN)
            {
                switch (m_trainerType)
                {
                case TRAINER_TYPE.RNN_SIMPLE:
                    return(new rnn.simple.TrainerRNN <double>(mycaffe, m_properties, m_random, this, m_rgVocabulary));

                default:
                    throw new Exception("The trainer type '" + m_trainerType.ToString() + "' is not supported in the RNN stage!");
                }
            }
            else
            {
                switch (m_trainerType)
                {
                case TRAINER_TYPE.PG_SIMPLE:
                    return(new pg.simple.TrainerPG <double>(mycaffe, m_properties, m_random, this));

                case TRAINER_TYPE.PG_ST:
                    return(new pg.st.TrainerPG <double>(mycaffe, m_properties, m_random, this));

                case TRAINER_TYPE.PG_MT:
                    return(new pg.mt.TrainerPG <double>(mycaffe, m_properties, m_random, this));

                case TRAINER_TYPE.C51_ST:
                    return(new dqn.c51.st.TrainerC51 <double>(mycaffe, m_properties, m_random, this));

                case TRAINER_TYPE.DQN_ST:
                    return(new dqn.noisy.st.TrainerNoisyDqn <double>(mycaffe, m_properties, m_random, this));

                case TRAINER_TYPE.DQN_SIMPLE:
                    return(new dqn.noisy.simple.TrainerNoisyDqn <double>(mycaffe, m_properties, m_random, this));

                default:
                    throw new Exception("The trainer type '" + m_trainerType.ToString() + "' is not supported in the RL stage!");
                }
            }
        }
Example #3
0
        /// <summary>
        /// Optionally overridden to return a new type of trainer.
        /// </summary>
        /// <remarks>
        /// Override this method when using the MyCaffeControl that uses the <i>double</i> base type.
        /// </remarks>
        /// <param name="caffe">Specifies the MyCaffeControl used.</param>
        /// <returns>The IxTraininer interface implemented by the new trainer is returned.</returns>
        protected virtual IxTrainerRNN create_trainerD(Component caffe)
        {
            MyCaffeControl <double> mycaffe = caffe as MyCaffeControl <double>;

            m_nProjectID = mycaffe.CurrentProject.ID;
            int.TryParse(mycaffe.CurrentProject.GetSolverSetting("max_iter"), out m_nIterations);
            int.TryParse(mycaffe.CurrentProject.GetSolverSetting("snapshot"), out m_nSnapshot);

            switch (m_trainerType)
            {
            case TRAINER_TYPE.RNN_SIMPLE:
                return(new rnn.simple.TrainerRNN <double>(mycaffe, m_properties, m_random, this, m_rgVocabulary, true));

            default:
                throw new Exception("Unknown trainer type '" + m_trainerType.ToString() + "'!");
            }
        }