Ejemplo n.º 1
0
        public void Load()
        {
            ModelContextData tosave = new ModelContextData();
            BinaryFormatter  bf     = new BinaryFormatter();
            FileStream       fs     = new FileStream("Model.bin", FileMode.Open, FileAccess.Read);

            tosave = bf.Deserialize(fs) as ModelContextData;
            fs.Close();
            fs.Dispose();


            this.bd            = tosave.bd;
            this.clipval       = tosave.clipval;
            this.decoder       = tosave.decoder;
            this.Depth         = tosave.Depth;
            this.encoder       = tosave.encoder;
            this.hidden_size   = tosave.hidden_sizes;
            this.learning_rate = tosave.learning_rate;
            this.word_size     = tosave.letter_size;
            this.max_word      = 100;
            this.regc          = tosave.regc;
            this.ReversEncoder = tosave.ReversEncoder;
            this.UseDropout    = tosave.UseDropout;
            this.Whd           = tosave.Whd;
            this.Embedding     = tosave.Wil;
        }
Ejemplo n.º 2
0
        public void Save()
        {
            ModelContextData tosave = new ModelContextData();

            tosave.bd            = this.bd;
            tosave.clipval       = this.clipval;
            tosave.decoder       = this.decoder;
            tosave.Depth         = this.Depth;
            tosave.encoder       = this.encoder;
            tosave.hidden_sizes  = this.hidden_size;
            tosave.learning_rate = this.learning_rate;
            tosave.letter_size   = this.word_size;
            tosave.max_chars_gen = this.max_word;
            tosave.regc          = this.regc;
            tosave.ReversEncoder = this.ReversEncoder;
            tosave.UseDropout    = this.UseDropout;
            tosave.Whd           = this.Whd;
            tosave.Wil           = this.Embedding;

            BinaryFormatter bf = new BinaryFormatter();
            FileStream      fs = new FileStream("Model.bin", FileMode.OpenOrCreate, FileAccess.Write);

            bf.Serialize(fs, tosave);
            fs.Close();
            fs.Dispose();
        }