예제 #1
0
        public string EncodeParameter()
        {
            string res = string.Empty;

            res += InWidth.ToString() + " ";
            res += InHeight.ToString() + " ";
            res += InputChannels.ToString() + " ";
            res += OutWidth.ToString() + " ";
            res += OutHeight.ToString() + " ";
            res += OutputChannels.ToString() + " ";
            EncodeParameterCore(ref res);
            return(res);
        }
예제 #2
0
        public void Save(string location)
        {
            var mloc = new System.IO.DirectoryInfo(location);

            if (mloc.Exists)
            {
                mloc.Delete(true);
            }
            mloc.Create();
            #region ModelBaseFile Create
            string text = this.GetType().ToString() + "\n";
            text += Epoch + " " + Generation + " " + ReverseStartBlock + " " + Error + "\n";
            text += InputChannels.ToString() + " " + InputWidth.ToString() + " " + InputHeight.ToString() + "\n";
            text += "!!!!!!!!!!!!!!!>";
            string[] tmp = new string[LayerCount];
            for (int i = 0; i < LayerCount; i++)
            {
                tmp[i] = Layer[i].Encode();
            }
            foreach (var item in tmp)
            {
                text += item;
            }
            #endregion
            #region ModelParameterFile
            var ploc = new System.IO.DirectoryInfo(location + @"\parameter");
            ploc.Create();
            Tasks.ForParallel(0, LayerCount, i => { Layer[i].Variable.SaveObject(ploc); });
            #endregion
            #region ModelBaseFile Save
            using (var fs = new System.IO.StreamWriter(location + @"\" + "model" + ".mdl", false))
            {
                fs.WriteLine(text);
            }
            #endregion
        }