コード例 #1
0
ファイル: Trainer.cs プロジェクト: jerudamaja/Gym.NET
        public void TrainOnMemory(IConcurrentMemory <TData> memory)
        {
            var trainingData = _dataBuilder.BuildDataset(memory);

            if (trainingData == null || trainingData.Count == 0)
            {
                return;
            }

            var clonedInstance = _network.Clone();
            // Train the network
            var result = NetworkManager.TrainNetwork(clonedInstance,
                                                     trainingData,
                                                     TrainingAlgorithms.AdaDelta(),
                                                     _configuration.Epochs, 0.5f,
                                                     TrackBatchProgress,
                                                     TrainingProgress);

            Console.WriteLine("\nTraining session completed, moving to next one");

            var backupName = $"backup-network-{DateTime.Now:yyyyMMdd-HH-mm-ss-fff}.modl";

            _network.Save(File.Create(backupName));
            Console.WriteLine($"Backup model {backupName} saved");
            _network = clonedInstance;
        }
コード例 #2
0
ファイル: Trainer.cs プロジェクト: jerudamaja/Gym.NET
 public void StartAsyncTraining(IConcurrentMemory <TData> memory, CancellationToken ct = default)
 {
     new Thread(() => {
         while (!ct.IsCancellationRequested)
         {
             TrainOnMemory(memory);
         }
     }).Start();
 }