예제 #1
0
        protected override void OnInitialize()
        {
            Debugger.Console.WriteCommitLine("initializing ... ");

            CultureInfo ci = new CultureInfo("en-GB");

            ci.NumberFormat.NumberDecimalSeparator = ".";
            Thread.CurrentThread.CurrentCulture    = ci;
            Thread.CurrentThread.CurrentUICulture  = ci;

            if (string.IsNullOrWhiteSpace(setting.Brain.ImagesPath))
            {
                setting.Brain.ImagesPath = $"{Name}.nnp";
            }
            if (!setting.Brain.Rebuild && File.Exists(setting.Brain.ImagesPath))
            {
                Debugger.Console.WriteCommitLine("loading brain ... ");
                LearningProcessSerializer.Restore(setting.Brain.ImagesPath);

                // reset stage
                var stage = setting.Process.Stage;
                if (stage.HasValue)
                {
                    Stage = stage.Value;
                    setting.Process.Stage = null;
                }

                // reset offsets
                var offset = setting.Process.Offset;
                if (offset != null)
                {
                    Offset = offset.Value;
                    setting.Process.Offset = null;
                }
            }
            else
            {
                Debugger.Console.WriteCommitLine("new brain ... ");

                if (setting.Brain.Rebuild)
                {
                    setting.Brain.Rebuild = false;
                    Offset = 0;
                }

                var images = BrainInitializer();
                foreach (var image in images)
                {
                    AddRunningProgress(new ChistaNet(image)
                    {
                        LearningFactor  = setting.Brain.LearningFactor,
                        CertaintyFactor = setting.Brain.CertaintyFactor,
                        DropoutFactor   = setting.Brain.DropoutFactor,
                    });
                }
            }
        }
예제 #2
0
        protected override void OnStopped()
        {
            Debugger.Console.WriteCommitLine("storing brain's image ... ");
            if (string.IsNullOrWhiteSpace(setting.Brain.ImagesPath))
            {
                setting.Brain.ImagesPath = $"{Name}.nnp";
            }
            LearningProcessSerializer.Serialize(setting.Brain.ImagesPath, this);

            setting.Save();

            Debugger.Console.WriteCommitLine("finished");
        }