• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# mlptrainer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中mlptrainer的典型用法代码示例。如果您正苦于以下问题:C# mlptrainer类的具体用法?C# mlptrainer怎么用?C# mlptrainer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



mlptrainer类属于命名空间,在下文中一共展示了mlptrainer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: dataset

        /*************************************************************************
        This function trains neural network passed to this function, using current
        dataset (one which was passed to MLPSetDataset() or MLPSetSparseDataset())
        and current training settings. Training  from  NRestarts  random  starting
        positions is performed, best network is chosen.

        Training is performed using current training algorithm.

        INPUT PARAMETERS:
            S           -   trainer object;
            Network     -   neural network. It must have same number of inputs and
                            output/classes as was specified during creation of the
                            trainer object;
            TNetwork    -   the training neural network.
                            User  may  look  weights  in  parameter Network  while
                            continue training process.
                            It has architecture like Network. You have to  copy or 
                            create new network with architecture like Network.
            State       -   created LBFGS optimizer;
            NRestarts   -   number of restarts, >=0:
                            * NRestarts>0 means that specified  number  of  random
                              restarts are performed, best network is chosen after
                              training
                            * NRestarts=0 means that current state of the  network
                              is used for training.
            TrnSubset   -   some subset from training set(it stores row's numbers),
                            used as trainig set;
           TrnSubsetSize-   size of subset(if TrnSubsetSize<0 - used full dataset);
                            when TrnSubsetSize=0, network is filled by zero value,
                            and ValSubset parameter is IGNORED;
            ValSubset   -   some subset from training set(it stores row's numbers),
                            used as validation set;
           ValSubsetSize-   size of subset(if ValSubsetSize<0 - used full dataset);
                            when  ValSubsetSize<>0  this  mean  that is used early
                            stopping training algorithm;
            BufWBest    -   buffer for storing interim resuls (BufWBest[0:WCOunt-1]
                            it has be allocated by user);
            BufWFinal   -   buffer for storing interim resuls(BufWFinal[0:WCOunt-1]
                            it has be allocated by user).

        OUTPUT PARAMETERS:
            Network     -   trained network;
            Rep         -   training report.

        NOTE: when no dataset was specified with MLPSetDataset/SetSparseDataset(),
              network  is  filled  by zero  values.  Same  behavior  for functions
              MLPStartTraining and MLPContinueTraining.

        NOTE: this method uses sum-of-squares error function for training.

          -- ALGLIB --
             Copyright 13.08.2012 by Bochkanov Sergey
        *************************************************************************/
        private static void mlptrainnetworkx(mlptrainer s,
            mlpbase.multilayerperceptron network,
            mlpbase.multilayerperceptron tnetwork,
            minlbfgs.minlbfgsstate state,
            int nrestarts,
            int[] trnsubset,
            int trnsubsetsize,
            int[] valsubset,
            int valsubsetsize,
            double[] bufwbest,
            double[] bufwfinal,
            mlpreport rep)
        {
            mlpbase.modelerrors modrep = new mlpbase.modelerrors();
            double eval = 0;
            double v = 0;
            double ebestcur = 0;
            double efinal = 0;
            int ngradbatch = 0;
            int nin = 0;
            int nout = 0;
            int wcount = 0;
            int twcount = 0;
            int itbest = 0;
            int itcnt = 0;
            int ntype = 0;
            int ttype = 0;
            bool rndstart = new bool();
            int pass = 0;
            int i = 0;
            int i_ = 0;

            alglib.ap.assert(s.npoints>=0, "MLPTrainNetworkX: internal error - parameter S is not initialized or is spoiled(S.NPoints<0)");
            if( s.rcpar )
            {
                ttype = 0;
            }
            else
            {
                ttype = 1;
            }
            if( !mlpbase.mlpissoftmax(network) )
            {
                ntype = 0;
            }
            else
            {
//.........这里部分代码省略.........
开发者ID:thunder176,项目名称:HeuristicLab,代码行数:101,代码来源:dataanalysis.cs


示例2: initmlptrnsession

        /*************************************************************************
        This function initializes temporaries needed for training session.


          -- ALGLIB --
             Copyright 01.07.2013 by Bochkanov Sergey
        *************************************************************************/
        private static void initmlptrnsession(mlpbase.multilayerperceptron networktrained,
            bool randomizenetwork,
            mlptrainer trainer,
            smlptrnsession session)
        {
            int nin = 0;
            int nout = 0;
            int wcount = 0;
            int pcount = 0;
            int[] dummysubset = new int[0];

            
            //
            // Prepare network:
            // * copy input network to Session.Network
            // * re-initialize preprocessor and weights if RandomizeNetwork=True
            //
            mlpbase.mlpcopy(networktrained, session.network);
            if( randomizenetwork )
            {
                alglib.ap.assert(trainer.datatype==0 || trainer.datatype==1, "InitTemporaries: unexpected Trainer.DataType");
                if( trainer.datatype==0 )
                {
                    mlpbase.mlpinitpreprocessorsubset(session.network, trainer.densexy, trainer.npoints, dummysubset, -1);
                }
                if( trainer.datatype==1 )
                {
                    mlpbase.mlpinitpreprocessorsparsesubset(session.network, trainer.sparsexy, trainer.npoints, dummysubset, -1);
                }
                mlpbase.mlprandomize(session.network);
                session.randomizenetwork = true;
            }
            else
            {
                session.randomizenetwork = false;
            }
            
            //
            // Determine network geometry and initialize optimizer 
            //
            mlpbase.mlpproperties(session.network, ref nin, ref nout, ref wcount);
            minlbfgs.minlbfgscreate(wcount, Math.Min(wcount, trainer.lbfgsfactor), session.network.weights, session.optimizer);
            minlbfgs.minlbfgssetxrep(session.optimizer, true);
            
            //
            // Create buffers
            //
            session.wbuf0 = new double[wcount];
            session.wbuf1 = new double[wcount];
            
            //
            // Initialize session result
            //
            mlpbase.mlpexporttunableparameters(session.network, ref session.bestparameters, ref pcount);
            session.bestrmserror = math.maxrealnumber;
        }
开发者ID:Kerbas-ad-astra,项目名称:MechJeb2,代码行数:63,代码来源:dataanalysis.cs


示例3: initmlpetrnsession

        /*************************************************************************
        This function initializes temporaries needed for ensemble training.

        *************************************************************************/
        private static void initmlpetrnsession(mlpbase.multilayerperceptron individualnetwork,
            mlptrainer trainer,
            mlpetrnsession session)
        {
            int[] dummysubset = new int[0];

            
            //
            // Prepare network:
            // * copy input network to Session.Network
            // * re-initialize preprocessor and weights if RandomizeNetwork=True
            //
            mlpbase.mlpcopy(individualnetwork, session.network);
            initmlptrnsessions(individualnetwork, true, trainer, session.mlpsessions);
            apserv.ivectorsetlengthatleast(ref session.trnsubset, trainer.npoints);
            apserv.ivectorsetlengthatleast(ref session.valsubset, trainer.npoints);
        }
开发者ID:Kerbas-ad-astra,项目名称:MechJeb2,代码行数:21,代码来源:dataanalysis.cs


示例4: dataset

        /*************************************************************************
        This function trains neural network passed to this function, using current
        dataset (one which was passed to MLPSetDataset() or MLPSetSparseDataset())
        and current training settings. Training  from  NRestarts  random  starting
        positions is performed, best network is chosen.

        This function is inteded to be used internally. It may be used in  several
        settings:
        * training with ValSubsetSize=0, corresponds  to  "normal"  training  with
          termination  criteria  based on S.MaxIts (steps count) and S.WStep (step
          size). Training sample is given by TrnSubset/TrnSubsetSize.
        * training with ValSubsetSize>0, corresponds to  early  stopping  training
          with additional MaxIts/WStep stopping criteria. Training sample is given
          by TrnSubset/TrnSubsetSize, validation sample  is  given  by  ValSubset/
          ValSubsetSize.

          -- ALGLIB --
             Copyright 13.08.2012 by Bochkanov Sergey
        *************************************************************************/
        private static void mlptrainnetworkx(mlptrainer s,
            int nrestarts,
            int algokind,
            int[] trnsubset,
            int trnsubsetsize,
            int[] valsubset,
            int valsubsetsize,
            mlpbase.multilayerperceptron network,
            mlpreport rep,
            bool isrootcall,
            alglib.smp.shared_pool sessions)
        {
            mlpbase.modelerrors modrep = new mlpbase.modelerrors();
            double eval = 0;
            double ebest = 0;
            int ngradbatch = 0;
            int nin = 0;
            int nout = 0;
            int wcount = 0;
            int pcount = 0;
            int itbest = 0;
            int itcnt = 0;
            int ntype = 0;
            int ttype = 0;
            bool rndstart = new bool();
            int i = 0;
            int nr0 = 0;
            int nr1 = 0;
            mlpreport rep0 = new mlpreport();
            mlpreport rep1 = new mlpreport();
            bool randomizenetwork = new bool();
            double bestrmserror = 0;
            smlptrnsession psession = null;
            int i_ = 0;

            mlpbase.mlpproperties(network, ref nin, ref nout, ref wcount);
            
            //
            // Process root call
            //
            if( isrootcall )
            {
                
                //
                // Check correctness of parameters
                //
                alglib.ap.assert(algokind==0 || algokind==-1, "MLPTrainNetworkX: unexpected AlgoKind");
                alglib.ap.assert(s.npoints>=0, "MLPTrainNetworkX: internal error - parameter S is not initialized or is spoiled(S.NPoints<0)");
                if( s.rcpar )
                {
                    ttype = 0;
                }
                else
                {
                    ttype = 1;
                }
                if( !mlpbase.mlpissoftmax(network) )
                {
                    ntype = 0;
                }
                else
                {
                    ntype = 1;
                }
                alglib.ap.assert(ntype==ttype, "MLPTrainNetworkX: internal error - type of the training network is not similar to network type in trainer object");
                alglib.ap.assert(s.nin==nin, "MLPTrainNetworkX: internal error - number of inputs in trainer is not equal to number of inputs in the training network.");
                alglib.ap.assert(s.nout==nout, "MLPTrainNetworkX: internal error - number of outputs in trainer is not equal to number of outputs in the training network.");
                alglib.ap.assert(nrestarts>=0, "MLPTrainNetworkX: internal error - NRestarts<0.");
                alglib.ap.assert(alglib.ap.len(trnsubset)>=trnsubsetsize, "MLPTrainNetworkX: internal error - parameter TrnSubsetSize more than input subset size(Length(TrnSubset)<TrnSubsetSize)");
                for(i=0; i<=trnsubsetsize-1; i++)
                {
                    alglib.ap.assert(trnsubset[i]>=0 && trnsubset[i]<=s.npoints-1, "MLPTrainNetworkX: internal error - parameter TrnSubset contains incorrect index(TrnSubset[I]<0 or TrnSubset[I]>S.NPoints-1)");
                }
                alglib.ap.assert(alglib.ap.len(valsubset)>=valsubsetsize, "MLPTrainNetworkX: internal error - parameter ValSubsetSize more than input subset size(Length(ValSubset)<ValSubsetSize)");
                for(i=0; i<=valsubsetsize-1; i++)
                {
                    alglib.ap.assert(valsubset[i]>=0 && valsubset[i]<=s.npoints-1, "MLPTrainNetworkX: internal error - parameter ValSubset contains incorrect index(ValSubset[I]<0 or ValSubset[I]>S.NPoints-1)");
                }
                
                //
                // Train
//.........这里部分代码省略.........
开发者ID:Kerbas-ad-astra,项目名称:MechJeb2,代码行数:101,代码来源:dataanalysis.cs


示例5: MLPContinueTraining

        /*************************************************************************
        This function performs step-by-step training of the neural  network.  Here
        "step-by-step" means that training  starts  with  MLPStartTrainingX  call,
        and then user subsequently calls MLPContinueTrainingX  to perform one more
        iteration of the training.

        After call to this function trainer object remembers network and  is ready
        to  train  it.  However,  no  training  is  performed  until first call to 
        MLPContinueTraining() function. Subsequent calls  to MLPContinueTraining()
        will advance traing progress one iteration further.


          -- ALGLIB --
             Copyright 13.08.2012 by Bochkanov Sergey
        *************************************************************************/
        private static void mlpstarttrainingx(mlptrainer s,
            bool randomstart,
            int algokind,
            int[] subset,
            int subsetsize,
            smlptrnsession session)
        {
            int nin = 0;
            int nout = 0;
            int wcount = 0;
            int ntype = 0;
            int ttype = 0;
            int i = 0;

            
            //
            // Check parameters
            //
            alglib.ap.assert(s.npoints>=0, "MLPStartTrainingX: internal error - parameter S is not initialized or is spoiled(S.NPoints<0)");
            alglib.ap.assert(algokind==0 || algokind==-1, "MLPStartTrainingX: unexpected AlgoKind");
            if( s.rcpar )
            {
                ttype = 0;
            }
            else
            {
                ttype = 1;
            }
            if( !mlpbase.mlpissoftmax(session.network) )
            {
                ntype = 0;
            }
            else
            {
                ntype = 1;
            }
            alglib.ap.assert(ntype==ttype, "MLPStartTrainingX: internal error - type of the resulting network is not similar to network type in trainer object");
            mlpbase.mlpproperties(session.network, ref nin, ref nout, ref wcount);
            alglib.ap.assert(s.nin==nin, "MLPStartTrainingX: number of inputs in trainer is not equal to number of inputs in the network.");
            alglib.ap.assert(s.nout==nout, "MLPStartTrainingX: number of outputs in trainer is not equal to number of outputs in the network.");
            alglib.ap.assert(alglib.ap.len(subset)>=subsetsize, "MLPStartTrainingX: internal error - parameter SubsetSize more than input subset size(Length(Subset)<SubsetSize)");
            for(i=0; i<=subsetsize-1; i++)
            {
                alglib.ap.assert(subset[i]>=0 && subset[i]<=s.npoints-1, "MLPStartTrainingX: internal error - parameter Subset contains incorrect index(Subset[I]<0 or Subset[I]>S.NPoints-1)");
            }
            
            //
            // Prepare session
            //
            minlbfgs.minlbfgssetcond(session.optimizer, 0.0, 0.0, s.wstep, s.maxits);
            if( s.npoints>0 && subsetsize!=0 )
            {
                if( randomstart )
                {
                    mlpbase.mlprandomize(session.network);
                }
                minlbfgs.minlbfgsrestartfrom(session.optimizer, session.network.weights);
            }
            else
            {
                for(i=0; i<=wcount-1; i++)
                {
                    session.network.weights[i] = 0;
                }
            }
            if( algokind==-1 )
            {
                session.algoused = s.algokind;
                if( s.algokind==1 )
                {
                    session.minibatchsize = s.minibatchsize;
                }
            }
            else
            {
                session.algoused = 0;
            }
            hqrnd.hqrndrandomize(session.generator);
            session.rstate.ia = new int[15+1];
            session.rstate.ra = new double[1+1];
            session.rstate.stage = -1;
        }
开发者ID:Kerbas-ad-astra,项目名称:MechJeb2,代码行数:97,代码来源:dataanalysis.cs


示例6: _pexec_mlpcontinuetraining

 /*************************************************************************
 Single-threaded stub. HPC ALGLIB replaces it by multithreaded code.
 *************************************************************************/
 public static bool _pexec_mlpcontinuetraining(mlptrainer s,
     mlpbase.multilayerperceptron network)
 {
     return mlpcontinuetraining(s,network);
 }
开发者ID:Kerbas-ad-astra,项目名称:MechJeb2,代码行数:8,代码来源:dataanalysis.cs


示例7: _pexec_mlptrainensemblees

 /*************************************************************************
 Single-threaded stub. HPC ALGLIB replaces it by multithreaded code.
 *************************************************************************/
 public static void _pexec_mlptrainensemblees(mlptrainer s,
     mlpe.mlpensemble ensemble,
     int nrestarts,
     mlpreport rep)
 {
     mlptrainensemblees(s,ensemble,nrestarts,rep);
 }
开发者ID:Kerbas-ad-astra,项目名称:MechJeb2,代码行数:10,代码来源:dataanalysis.cs


示例8: mlpcreatetrainer

        /*************************************************************************
        Creation of the network trainer object for regression networks

        INPUT PARAMETERS:
            NIn         -   number of inputs, NIn>=1
            NOut        -   number of outputs, NOut>=1

        OUTPUT PARAMETERS:
            S           -   neural network trainer object.
                            This structure can be used to train any regression
                            network with NIn inputs and NOut outputs.

          -- ALGLIB --
             Copyright 23.07.2012 by Bochkanov Sergey
        *************************************************************************/
        public static void mlpcreatetrainer(int nin,
            int nout,
            mlptrainer s)
        {
            alglib.ap.assert(nin>=1, "MLPCreateTrainer: NIn<1.");
            alglib.ap.assert(nout>=1, "MLPCreateTrainer: NOut<1.");
            s.nin = nin;
            s.nout = nout;
            s.rcpar = true;
            s.lbfgsfactor = defaultlbfgsfactor;
            s.decay = 1.0E-6;
            mlpsetcond(s, 0, 0);
            s.datatype = 0;
            s.npoints = 0;
            mlpsetalgobatch(s);
        }
开发者ID:Kerbas-ad-astra,项目名称:MechJeb2,代码行数:31,代码来源:dataanalysis.cs


示例9: mlpcreatetrainercls

        /*************************************************************************
        Creation of the network trainer object for classification networks

        INPUT PARAMETERS:
            NIn         -   number of inputs, NIn>=1
            NClasses    -   number of classes, NClasses>=2

        OUTPUT PARAMETERS:
            S           -   neural network trainer object.
                            This structure can be used to train any classification
                            network with NIn inputs and NOut outputs.

          -- ALGLIB --
             Copyright 23.07.2012 by Bochkanov Sergey
        *************************************************************************/
        public static void mlpcreatetrainercls(int nin,
            int nclasses,
            mlptrainer s)
        {
            alglib.ap.assert(nin>=1, "MLPCreateTrainerCls: NIn<1.");
            alglib.ap.assert(nclasses>=2, "MLPCreateTrainerCls: NClasses<2.");
            s.nin = nin;
            s.nout = nclasses;
            s.rcpar = false;
            s.lbfgsfactor = defaultlbfgsfactor;
            s.decay = 1.0E-6;
            mlpsetcond(s, 0, 0);
            s.datatype = 0;
            s.npoints = 0;
            mlpsetalgobatch(s);
        }
开发者ID:Kerbas-ad-astra,项目名称:MechJeb2,代码行数:31,代码来源:dataanalysis.cs


示例10: support

        /*************************************************************************
        This function estimates generalization error using cross-validation on the
        current dataset with current training settings.

        FOR USERS OF COMMERCIAL EDITION:

          ! Commercial version of ALGLIB includes two  important  improvements  of
          ! this function:
          ! * multicore support (C++ and C# computational cores)
          ! * SSE support (C++ computational core)
          !
          ! Second improvement gives constant  speedup (2-3X).  First  improvement
          ! gives  close-to-linear  speedup  on   multicore   systems.   Following
          ! operations can be executed in parallel:
          ! * FoldsCount cross-validation rounds (always)
          ! * NRestarts training sessions performed within each of
          !   cross-validation rounds (if NRestarts>1)
          ! * gradient calculation over large dataset (if dataset is large enough)
          !
          ! In order to use multicore features you have to:
          ! * use commercial version of ALGLIB
          ! * call  this  function  with  "smp_"  prefix,  which  indicates  that
          !   multicore code will be used (for multicore support)
          !
          ! In order to use SSE features you have to:
          ! * use commercial version of ALGLIB on Intel processors
          ! * use C++ computational core
          !
          ! This note is given for users of commercial edition; if  you  use  GPL
          ! edition, you still will be able to call smp-version of this function,
          ! but all computations will be done serially.
          !
          ! We recommend you to carefully read ALGLIB Reference  Manual,  section
          ! called 'SMP support', before using parallel version of this function.

        INPUT PARAMETERS:
            S           -   trainer object
            Network     -   neural network. It must have same number of inputs and
                            output/classes as was specified during creation of the
                            trainer object. Network is not changed  during  cross-
                            validation and is not trained - it  is  used  only  as
                            representative of its architecture. I.e., we  estimate
                            generalization properties of  ARCHITECTURE,  not  some
                            specific network.
            NRestarts   -   number of restarts, >=0:
                            * NRestarts>0  means  that  for  each cross-validation
                              round   specified  number   of  random  restarts  is
                              performed,  with  best  network  being  chosen after
                              training.
                            * NRestarts=0 is same as NRestarts=1
            FoldsCount  -   number of folds in k-fold cross-validation:
                            * 2<=FoldsCount<=size of dataset
                            * recommended value: 10.
                            * values larger than dataset size will be silently
                              truncated down to dataset size

        OUTPUT PARAMETERS:
            Rep         -   structure which contains cross-validation estimates:
                            * Rep.RelCLSError - fraction of misclassified cases.
                            * Rep.AvgCE - acerage cross-entropy
                            * Rep.RMSError - root-mean-square error
                            * Rep.AvgError - average error
                            * Rep.AvgRelError - average relative error
                            
        NOTE: when no dataset was specified with MLPSetDataset/SetSparseDataset(),
              or subset with only one point  was  given,  zeros  are  returned  as
              estimates.

        NOTE: this method performs FoldsCount cross-validation  rounds,  each  one
              with NRestarts random starts.  Thus,  FoldsCount*NRestarts  networks
              are trained in total.

        NOTE: Rep.RelCLSError/Rep.AvgCE are zero on regression problems.

        NOTE: on classification problems Rep.RMSError/Rep.AvgError/Rep.AvgRelError
              contain errors in prediction of posterior probabilities.
                
          -- ALGLIB --
             Copyright 23.07.2012 by Bochkanov Sergey
        *************************************************************************/
        public static void mlpkfoldcv(mlptrainer s,
            mlpbase.multilayerperceptron network,
            int nrestarts,
            int foldscount,
            mlpreport rep)
        {
            alglib.smp.shared_pool pooldatacv = new alglib.smp.shared_pool();
            mlpparallelizationcv datacv = new mlpparallelizationcv();
            mlpparallelizationcv sdatacv = null;
            double[,] cvy = new double[0,0];
            int[] folds = new int[0];
            double[] buf = new double[0];
            double[] dy = new double[0];
            int nin = 0;
            int nout = 0;
            int wcount = 0;
            int rowsize = 0;
            int ntype = 0;
            int ttype = 0;
            int i = 0;
//.........这里部分代码省略.........
开发者ID:Kerbas-ad-astra,项目名称:MechJeb2,代码行数:101,代码来源:dataanalysis.cs


示例11: _pexec_mlpkfoldcv

 /*************************************************************************
 Single-threaded stub. HPC ALGLIB replaces it by multithreaded code.
 *************************************************************************/
 public static void _pexec_mlpkfoldcv(mlptrainer s,
     mlpbase.multilayerperceptron network,
     int nrestarts,
     int foldscount,
     mlpreport rep)
 {
     mlpkfoldcv(s,network,nrestarts,foldscount,rep);
 }
开发者ID:Kerbas-ad-astra,项目名称:MechJeb2,代码行数:11,代码来源:dataanalysis.cs


示例12: make_copy

 public override alglib.apobject make_copy()
 {
     mlptrainer _result = new mlptrainer();
     _result.nin = nin;
     _result.nout = nout;
     _result.rcpar = rcpar;
     _result.lbfgsfactor = lbfgsfactor;
     _result.decay = decay;
     _result.wstep = wstep;
     _result.maxits = maxits;
     _result.datatype = datatype;
     _result.npoints = npoints;
     _result.densexy = (double[,])densexy.Clone();
     _result.sparsexy = (sparse.sparsematrix)sparsexy.make_copy();
     _result.session = (smlptrnsession)session.make_copy();
     _result.ngradbatch = ngradbatch;
     _result.subset = (int[])subset.Clone();
     _result.subsetsize = subsetsize;
     _result.valsubset = (int[])valsubset.Clone();
     _result.valsubsetsize = valsubsetsize;
     _result.algokind = algokind;
     _result.minibatchsize = minibatchsize;
     return _result;
 }
开发者ID:Kerbas-ad-astra,项目名称:MechJeb2,代码行数:24,代码来源:dataanalysis.cs


示例13: True

        /*************************************************************************
        This function performs step-by-step training of the neural  network.  Here
        "step-by-step" means  that training starts  with  MLPStartTrainingX  call,
        and then user subsequently calls MLPContinueTrainingX  to perform one more
        iteration of the training.

        This  function  performs  one  more  iteration of the training and returns
        either True (training continues) or False (training stopped). In case True
        was returned, Network weights are updated according to the  current  state
        of the optimization progress. In case False was  returned,  no  additional
        updates is performed (previous update of  the  network weights moved us to
        the final point, and no additional updates is needed).

        EXAMPLE:
            >
            > [initialize network and trainer object]
            >
            > MLPStartTraining(Trainer, Network, True)
            > while MLPContinueTraining(Trainer, Network) do
            >     [visualize training progress]
            >

        INPUT PARAMETERS:
            S           -   trainer object
            Network     -   neural network which receives A  COPY  of  the  actual
                            network which is trained by the algorithm. After  each
                            training roung state of the network being  trained  is
                            copied to this variable.
                            It must have same number of inputs and  output/classes
                            as was specified during creation of the trainer object
                            and  it  must  have  exactly  same architecture as the
                            second network (TNetwork).
            TNetwork    -   neural network being trained.
            State       -   LBFGS  optimizer,  already  initialized,   number   of
                            dimensions  must  be equal to number of weights in the
                            networks.
            Subset      -   some subset from training set(it stores row's numbers);
            SubsetSize  -   size of subset(if SubsetSize<0 - used full dataset).
            NGradBatch  -   number  of calls  MLPGradBatch function.  Initial value
                            is zero;
            
        OUTPUT PARAMETERS:
            Network     -   weights of the neural network  are  rewritten  by  the
                            current approximation;
            NGradBatch  -   number  of calls  MLPGradBatch function after training.

        NOTE: this method uses sum-of-squares error function for training.

        NOTE: it is expected that trainer object settings are NOT  changed  during
              step-by-step training, i.e. no  one  changes  stopping  criteria  or
              training set during training. It is possible and there is no defense
              against  such  actions,  but  algorithm  behavior  in  such cases is
              undefined and can be unpredictable.
              
        NOTE: It  is  expected that Network is the same one which  was  passed  to
              MLPStartTraining() function.  However,  THIS  function  checks  only
              following:
              * that number of network inputs is consistent with trainer object
                settings
              * that number of network outputs/classes is consistent with  trainer
                object settings
              * that number of network weights is the same as number of weights in
                the network passed to MLPStartTraining() function
              Exception is thrown when these conditions are violated.
              
              It is also expected that you do not change state of the  network  on
              your own - the only party who has right to change network during its
              training is a trainer object. Any attempt to interfere with  trainer
              may lead to unpredictable results.
              

          -- ALGLIB --
             Copyright 13.08.2012 by Bochkanov Sergey
        *************************************************************************/
        private static bool mlpcontinuetrainingx(mlptrainer s,
            mlpbase.multilayerperceptron network,
            mlpbase.multilayerperceptron tnetwork,
            minlbfgs.minlbfgsstate state,
            int[] subset,
            int subsetsize,
            ref int ngradbatch)
        {
            bool result = new bool();
            int nin = 0;
            int nout = 0;
            int wcount = 0;
            int twcount = 0;
            int ntype = 0;
            int ttype = 0;
            double decay = 0;
            double v = 0;
            int i = 0;
            int i_ = 0;

            alglib.ap.assert(s.npoints>=0, "MLPContinueTrainingX: internal error - parameter S is not initialized or is spoiled(S.NPoints<0).");
            if( s.rcpar )
            {
                ttype = 0;
            }
            else
//.........这里部分代码省略.........
开发者ID:thunder176,项目名称:HeuristicLab,代码行数:101,代码来源:dataanalysis.cs


示例14: MLPContinueTraining

        /*************************************************************************
        This function performs step-by-step training of the neural  network.  Here
        "step-by-step" means that training  starts  with  MLPStartTrainingX  call,
        and then user subsequently calls MLPContinueTrainingX  to perform one more
        iteration of the training.

        After call to this function trainer object remembers network and  is ready
        to  train  it.  However,  no  training  is  performed  until first call to 
        MLPContinueTraining() function. Subsequent calls  to MLPContinueTraining()
        will advance traing progress one iteration further.

        EXAMPLE:
            >
            > ...initialize network and trainer object....
            >
            > MLPStartTraining(Trainer, Network, True)
            > while MLPContinueTraining(Trainer, Network) do
            >     ...visualize training progress...
            >

        INPUT PARAMETERS:
            S           -   trainer object;
            Network     -   neural network which receives A  COPY  of  the  actual
                            network which is trained by the algorithm. After  each
                            training roung state of the network being  trained  is
                            copied to this variable.
                            It must have same number of inputs and  output/classes
                            as was specified during creation of the trainer object
                            and  it  must  have  exactly  same architecture as the
                            second network (TNetwork).
            TNetwork    -   neural network being trained.
            State       -   LBFGS  optimizer,  already  initialized,   number   of
                            dimensions  must  be equal to number of weights in the
                            networks.
            RandomStart -   randomize network before training or not:
                            * True  means  that  network  is  randomized  and  its
                              initial state (one which was passed to  the  trainer
                              object) is lost;
                            * False  means  that  training  is  started  from  the
                              current state of the network.
            Subset      -   some subset from training set(it stores row's numbers);
            SubsetSize  -   size of subset(if SubsetSize<0 - used full dataset).
                            
        OUTPUT PARAMETERS:
            Network     -   neural network which is ready to training (weights are
                            initialized, preprocessor is initialized using current
                            training set)

        NOTE: this method uses sum-of-squares error function for training.

        NOTE: it is expected that trainer object settings are NOT  changed  during
              step-by-step training, i.e. no  one  changes  stopping  criteria  or
              training set during training. It is possible and there is no defense
              against  such  actions,  but  algorithm  behavior  in  such cases is
              undefined and can be unpredictable.

          -- ALGLIB --
             Copyright 13.08.2012 by Bochkanov Sergey
        *************************************************************************/
        private static void mlpstarttrainingx(mlptrainer s,
            mlpbase.multilayerperceptron network,
            mlpbase.multilayerperceptron tnetwork,
            minlbfgs.minlbfgsstate state,
            bool randomstart,
            int[] subset,
            int subsetsize)
        {
            int nin = 0;
            int nout = 0;
            int wcount = 0;
            int twcount = 0;
            int ntype = 0;
            int ttype = 0;
            int i = 0;
            int i_ = 0;

            alglib.ap.assert(s.npoints>=0, "MLPStartTrainingX: internal error - parameter S is not initialized or is spoiled(S.NPoints<0)");
            if( s.rcpar )
            {
                ttype = 0;
            }
            else
            {
                ttype = 1;
            }
            if( !mlpbase.mlpissoftmax(network) )
            {
                ntype = 0;
            }
            else
            {
                ntype = 1;
            }
            alglib.ap.assert(ntype==ttype, "MLPStartTrainingX: internal error - type of the resulting network is not similar to network type in trainer object");
            if( !mlpbase.mlpissoftmax(tnetwork) )
            {
                ntype = 0;
            }
            else
            {
//.........这里部分代码省略.........
开发者ID:thunder176,项目名称:HeuristicLab,代码行数:101,代码来源:dataanalysis.cs


示例15: MLPTrain

        /*************************************************************************
        IMPORTANT: this is an "expert" version of the MLPTrain() function.  We  do
                   not recommend you to use it unless you are pretty sure that you
                   need ability to monitor training progress.

        This function performs step-by-step training of the neural  network.  Here
        "step-by-step" means that training  starts  with  MLPStartTraining() call,
        and then user subsequently calls MLPContinueTraining() to perform one more
        iteration of the training.

        After call to this function trainer object remembers network and  is ready
        to  train  it.  However,  no  training  is  performed  until first call to 
        MLPContinueTraining() function. Subsequent calls  to MLPContinueTraining()
        will advance training progress one iteration further.

        EXAMPLE:
            >
            > ...initialize network and trainer object....
            >
            > MLPStartTraining(Trainer, Network, True)
            > while MLPContinueTraining(Trainer, Network) do
            >     ...visualize training progress...
            >

        INPUT PARAMETERS:
            S           -   trainer object
            Network     -   neural network. It must have same number of inputs and
                            output/classes as was specified during creation of the
                            trainer object.
            RandomStart -   randomize network before training or not:
                            * True  means  that  network  is  randomized  and  its
                              initial state (one which was passed to  the  trainer
                              object) is lost.
                            * False  means  that  training  is  started  from  the
                              current state of the network
                            
        OUTPUT PARAMETERS:
            Network     -   neural network which is ready to training (weights are
                            initialized, preprocessor is initialized using current
                            training set)

        NOTE: this method uses sum-of-squares error function for training.

        NOTE: it is expected that trainer object settings are NOT  changed  during
              step-by-step training, i.e. no  one  changes  stopping  criteria  or
              training set during training. It is possible and there is no defense
              against  such  actions,  but  algorithm  behavior  in  such cases is
              undefined and can be unpredictable.

          -- ALGLIB --
             Copyright 23.07.2012 by Bochkanov Sergey
        *************************************************************************/
        public static void mlpstarttraining(mlptrainer s,
            mlpbase.multilayerperceptron network,
            bool randomstart)
        {
            int nin = 0;
            int nout = 0;
            int wcount = 0;
            int ntype = 0;
            int ttype = 0;

            alglib.ap.assert(s.npoints>=0, "MLPStartTraining: parameter S is not initialized or is spoiled(S.NPoints<0)");
            if( !mlpbase.mlpissoftmax(network) )
            {
                ntype = 0;
            }
            else
            {
                ntype = 1;
            }
            if( s.rcpar )
            {
                ttype = 0;
            }
            else
            {
                ttype = 1;
            }
            alglib.ap.assert(ntype==ttype, "MLPStartTraining: type of input network is not similar to network type in trainer object");
            mlpbase.mlpproperties(network, ref nin, ref nout, ref wcount);
            alglib.ap.assert(s.nin==nin, "MLPStartTraining: number of inputs in trainer is not equal to number of inputs in the network.");
            alglib.ap.assert(s.nout==nout, "MLPStartTraining: number of outputs in trainer is not equal to number of outputs in the network.");
            
            //
            // Initialize temporaries
            //
            initmlptrnsession(network, randomstart, s, s.session);
            
            //
            // Train network
            //
            mlpstarttrainingx(s, randomstart, -1, s.subset, -1, s.session);
            
            //
            // Update network
            //
            mlpbase.mlpcopytunableparameters(s.session.network, network);
        }
开发者ID:Kerbas-ad-astra,项目名称:MechJeb2,代码行数:99,代码来源:dataanalysis.cs


示例16: user

        /*************************************************************************
        This function sets "current dataset" of the trainer object to  one  passed
        by user (sparse matrix is used to store dataset).

     

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# model类代码示例发布时间:2022-05-24
下一篇:
C# mlpreport类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap