Ejemplo n.º 1
0
        public override XmlElement Save(XmlDocument doc, object o)
        {
            if (o == null)
            {
                return(null);
            }

            if (!(o is Trainer trainer))
            {
                throw new Exception("Codec must be Trainer!");
            }

            var el = GetRootElement(doc);

            XmlStorage.AddChild(el, "Mission", trainer.Mission);
            XmlStorage.AddChild(el, "BatchSize", trainer.BatchSize);
            XmlStorage.AddChild(el, "Epoch", trainer.Epoch);
            XmlStorage.AddChild(el, "RandomBatch", trainer.RandomBatch.ToString());
            XmlStorage.AddChild(el, "PrintSteps", trainer.PrintSteps);
            XmlStorage.AddChild(el, "LastTrainLoss", trainer.LastTrainLoss);
            XmlStorage.AddChild(el, "LastTrainAccuracy", trainer.LastTrainAccuracy);
            XmlStorage.AddChild(el, "LastTestLoss", trainer.LastTestLoss);
            XmlStorage.AddChild(el, "LastTestAccuracy", trainer.LastTestAccuracy);
            XmlStorage.AddObjectChild(el, "PreProcessor", trainer.PreProcessor);
            XmlStorage.AddObjectChild(el, "LabelCodec", trainer.LabelCodec);
            XmlStorage.AddObjectChild(el, "Normalizer", trainer.Normalizer);
            XmlStorage.AddObjectChild(el, "Model", trainer.Model);

            return(el);
        }
Ejemplo n.º 2
0
        public override XmlElement Save(XmlDocument doc, object o)
        {
            if (!(o is GradientDescent gd))
            {
                throw new Exception("object must be GridentDescent");
            }

            var el = GetRootElement(doc);

            XmlStorage.AddChild(el, "LearningRate", gd.LearningRate);

            return(el);
        }
Ejemplo n.º 3
0
        public override XmlElement Save(XmlDocument doc, object o)
        {
            if (!(o is Lasso ridge))
            {
                throw new Exception("object must be Lasso");
            }

            var el = GetRootElement(doc);

            XmlStorage.AddChild(el, "Strength", ridge.Strength);

            return(el);
        }
Ejemplo n.º 4
0
        public override XmlElement Save(XmlDocument doc, object o)
        {
            if (!(o is Adam adam))
            {
                throw new Exception("object must be GridentDescent");
            }

            var el = GetRootElement(doc);

            XmlStorage.AddChild(el, "Alpha", adam.Alpha);
            XmlStorage.AddChild(el, "Beta1", adam.Beta1);
            XmlStorage.AddChild(el, "Beta2", adam.Beta2);

            return(el);
        }
Ejemplo n.º 5
0
        public override XmlElement Save(XmlDocument doc, object o)
        {
            if (o == null)
            {
                return(null);
            }

            if (!(o is ZScoreNorm norm))
            {
                throw new Exception("Codec must be OneHotCodec!");
            }

            var el = GetRootElement(doc);

            XmlStorage.AddChild(el, "Mean", norm.Mean);
            XmlStorage.AddChild(el, "Delta", norm.Delta);

            return(el);
        }