示例#1
0
        // Constructor
        public NeuralNet(int width, int height, string log_dir, string log_ext, string model_dir, string model_ext, string config_ext)
        {
            this.width      = width;
            this.height     = height;
            this.log_dir    = log_dir;
            this.log_ext    = log_ext;
            this.model_dir  = model_dir;
            this.model_ext  = model_ext;
            this.config_ext = config_ext;

            // Attempt to reset the invoked library
            //np.arange(1);
            //PythonEngine.BeginAllowThreads();
            K.DisableEager();
            K.ClearSession();
            K.ResetUids();
        }
示例#2
0
        // Neural model loading and saving routines

        public void LoadModel(string stime)
        {
            K.DisableEager();
            K.ClearSession();
            K.ResetUids();

            string filename = Utils.GetFileWithoutExtension(model_dir, stime);

            config = (Config)FileIO.DeSerializeXml(typeof(Config), filename + config_ext);

            if (config == null || string.IsNullOrEmpty(config.Model))
            {
                throw new Exception("Invalid config file");
            }

            model_loaded = BaseModel.ModelFromJson(config.Model);
            model_loaded.LoadWeight(filename + model_ext);
            model_loaded.Summary();
            starttime = config.StartTime;
        }