コード例 #1
0
ファイル: MlpClassifier.cs プロジェクト: liaoheping/OCRonet
        public override void TrainDense(IDataset ds)
        {
            int   nclasses = ds.nClasses();
            float miters   = PGetf("miters");
            int   niters   = (int)(ds.nSamples() * miters);

            niters = Math.Max(1000, Math.Min(10000000, niters));
            double     err    = 0.0;
            Floatarray x      = new Floatarray();
            Floatarray z      = new Floatarray();
            Floatarray target = new Floatarray(nclasses);
            int        count  = 0;

            for (int i = 0; i < niters; i++)
            {
                int row = i % ds.nSamples();
                ds.Output(target, row);
                ds.Input1d(x, row);
                TrainOne(z, target, x, PGetf("eta"));
                err += NarrayUtil.Dist2Squared(z, target);
                count++;
            }
            err /= count;
            Global.Debugf("info", "   {4} n {0} niters={1} eta={2:0.#####} errors={3:0.########}",
                          ds.nSamples(), niters, PGetf("eta"), err, FullName);
        }