Esempio n. 1
0
        public override void Save(string path)
        {
            if (TrainedModel == null)
            {
                throw new InvalidOperationException("Must train/load a model before saving");
            }

#if ML_LEGACY
            TrainedModel.WriteAsync(path).Wait();
#else
            // save
            using (var stream = File.Create(path))
            {
                Context.Model.Save(TrainedModel, InputSchema, stream);
            }
#endif
        }
Esempio n. 2
0
        public override void Save(string path)
        {
            if (TrainedModel == null)
            {
                throw new Exception("Must initialize the model before calling");
            }

            lock (TrainedModel)
            {
#if ML_LEGACY
                TrainedModel.WriteAsync(path).Wait();
#else
                // save
                using (var stream = File.Create(path))
                {
                    TrainedModel.SaveTo(Context, stream);
                }
#endif
            }
        }