Esempio n. 1
0
        /// <summary>
        /// Run the network using the run technique implemented by this trainer.
        /// </summary>
        /// <param name="mycaffe">Specifies an instance to the MyCaffeControl component.</param>
        /// <param name="nN">Specifies the number of samples to run.</param>
        /// <param name="type">Specifies the output data type returned as a raw byte stream.</param>
        /// <returns>The run results are returned in the same native type as that of the CustomQuery used.</returns>
        byte[] IXMyCaffeCustomTrainerRNN.Run(Component mycaffe, int nN, out string type)
        {
            if (m_itrainer == null)
            {
                m_itrainer = createTrainer(mycaffe, Stage.RNN);
            }

            IxTrainerRNN itrainer = m_itrainer as IxTrainerRNN;

            if (itrainer == null)
            {
                throw new Exception("The trainer must be set to to 'RNN.SIMPLE' to run in recurrent learning mode.");
            }

            string strRunProperties = null;
            IXMyCaffeCustomTrainerCallbackRNN icallback = m_icallback as IXMyCaffeCustomTrainerCallbackRNN;

            if (icallback != null)
            {
                strRunProperties = icallback.GetRunProperties();
            }

            byte[] rgResults = itrainer.Run(nN, strRunProperties, out type);
            m_itrainer.Shutdown(0);
            m_itrainer = null;

            return(rgResults);
        }
Esempio n. 2
0
        /// <summary>
        /// Run the network using the run technique implemented by this trainer.
        /// </summary>
        /// <param name="mycaffe">Specifies an instance to the MyCaffeControl component.</param>
        /// <param name="nN">Specifies the number of samples to run.</param>
        /// <param name="type">Specifies the output data type returned as a raw byte stream.</param>
        /// <returns>The run results are returned in the same native type as that of the CustomQuery used.</returns>
        public byte[] Run(Component mycaffe, int nN, out string type)
        {
            if (m_itrainer == null)
            {
                m_itrainer = createTrainer(mycaffe, Stage.RL);
            }

            string strRunProperties = null;
            IXMyCaffeCustomTrainerCallbackRNN icallback = m_icallback as IXMyCaffeCustomTrainerCallbackRNN;

            if (icallback != null)
            {
                strRunProperties = icallback.GetRunProperties();
            }

            IxTrainerRL itrainer = m_itrainer as IxTrainerRL;

            if (itrainer == null)
            {
                throw new Exception("The IxTrainerRL interface must be implemented.");
            }

            byte[] rgResults = itrainer.Run(nN, strRunProperties, out type);
            m_itrainer.Shutdown(0);
            m_itrainer = null;

            return(rgResults);
        }
        /// <summary>
        /// Create a new trainer and use it to run a single run cycle.
        /// </summary>
        /// <param name="mycaffe">Specifies the MyCaffeControl to use.</param>
        /// <param name="nN">Specifies the number of samples to run.</param>
        /// <returns>The results of the run are returned.</returns>
        float[] IXMyCaffeCustomTrainerRNN.Run(Component mycaffe, int nN)
        {
            if (m_itrainer == null)
            {
                m_itrainer = createTrainer(mycaffe, Stage.RNN);
            }

            IxTrainerRNN itrainer = m_itrainer as IxTrainerRNN;

            if (itrainer == null)
            {
                throw new Exception("The trainer must be set to to 'RNN.SIMPLE' to run in recurrent learning mode.");
            }

            PropertySet runProp = null;
            IXMyCaffeCustomTrainerCallbackRNN icallback = m_icallback as IXMyCaffeCustomTrainerCallbackRNN;

            if (icallback != null)
            {
                runProp = icallback.GetRunProperties();
            }

            float[] rgResults = itrainer.Run(nN, runProp);
            cleanup(0, false);

            return(rgResults);
        }
Esempio n. 4
0
        /// <summary>
        /// Run the network using the run technique implemented by this trainer.
        /// </summary>
        /// <param name="mycaffe">Specifies an instance to the MyCaffeControl component.</param>
        /// <param name="nN">Specifies the number of samples to run.</param>
        /// <param name="type">Specifies the output data type returned as a raw byte stream.</param>
        /// <returns>The run results are returned in the same native type as that of the CustomQuery used.</returns>
        public byte[] Run(Component mycaffe, int nN, out string type)
        {
            if (m_itrainer == null)
            {
                m_itrainer = createTrainer(mycaffe);
            }

            string strRunProperties = null;
            IXMyCaffeCustomTrainerCallbackRNN icallback = m_icallback as IXMyCaffeCustomTrainerCallbackRNN;

            if (icallback != null)
            {
                strRunProperties = icallback.GetRunProperties();
            }

            byte[] rgResults = m_itrainer.Run(nN, strRunProperties, out type);
            cleanup(0);

            return(rgResults);
        }
        /// <summary>
        /// Create a new trainer and use it to run a single run cycle.
        /// </summary>
        /// <param name="mycaffe">Specifies the MyCaffeControl to use.</param>
        /// <param name="nN">Specifies the number of samples to run.</param>
        /// <returns>The results of the run are returned.</returns>
        public float[] Run(Component mycaffe, int nN)
        {
            if (m_itrainer == null)
            {
                m_itrainer = createTrainer(mycaffe);
            }

            PropertySet runProp = null;
            IXMyCaffeCustomTrainerCallbackRNN icallback = m_icallback as IXMyCaffeCustomTrainerCallbackRNN;

            if (icallback != null)
            {
                runProp = icallback.GetRunProperties();
            }

            float[] rgResults = m_itrainer.Run(nN, runProp);
            cleanup(0);

            return(rgResults);
        }
Esempio n. 6
0
        /// <summary>
        /// Create a new trainer and use it to run a single run cycle.
        /// </summary>
        /// <param name="mycaffe">Specifies the MyCaffeControl to use.</param>
        /// <param name="nN">Specifies the number of samples to run.</param>
        /// <returns>The results of the run are returned.</returns>
        public float[] Run(Component mycaffe, int nN)
        {
            if (m_itrainer == null)
            {
                m_itrainer = createTrainer(mycaffe);
            }

            string strRunProperties = null;
            IXMyCaffeCustomTrainerCallbackRNN icallback = m_icallback as IXMyCaffeCustomTrainerCallbackRNN;

            if (icallback != null)
            {
                strRunProperties = icallback.GetRunProperties();
            }

            float[] rgResults = m_itrainer.Run(nN, strRunProperties);
            m_itrainer.Shutdown(0);
            m_itrainer = null;

            return(rgResults);
        }