Пример #1
0
        public NeuralAgentTrainer(NeuralAgentTrainerConfiguration configuration)
        {
            NetworkName = $"Auto-R{configuration.ViewRadius}-{string.Join("_", configuration.LayersSizes)}";
            InitialiseNetwork(NetworkName, configuration);
            TrainingPluginConfiguration          = configuration.TrainingPluginConfiguration;
            TrainingSimulationConfiguration      = configuration.TrainingSimulationConfiguration;
            TrainingProgressTrackerConfiguration = configuration.TrainingProgressTrackerConfiguration;
            TestingSimulationConfiguration       = configuration.TrainingProgressSimulationConfiguration;
            SpaceTemplateFactory   = Workspace.Instance.Spaces.GetByName(configuration.Space);
            TrainingOuputDirectory = Workspace.Instance.NeuralTrainingsDirectory.Ensure().CreateSubdirectory($"{NetworkName}-{DateTime.Now:yyyy_MM_dd-HH_mm}");
            WriteLine("Training Plugin Configuration");
            WriteLine("-----------------------------");
            WriteLine(TrainingPluginConfiguration.ConvertToJson());
            WriteLine("");
            WriteLine("Training Simulation Configuration");
            WriteLine("---------------------------------");
            WriteLine(TrainingSimulationConfiguration.ConvertToJson());
            WriteLine("");
            WriteLine("Training Progress Tracker Configuration");
            WriteLine("---------------------------------------");

            WriteLine(TrainingProgressTrackerConfiguration.ConvertToJson());
            WriteLine("");
            WriteLine("Training Simulation Configuration");
            WriteLine("---------------------------------");
            WriteLine(TestingSimulationConfiguration.ConvertToJson());
            WriteLine("");
        }
Пример #2
0
 public NeuralSimulationPlugin(FileInfo networkFile, AgentNetworkTrainingConfiguration trainingConfiguration, int trainingSeed) : base(new NeuralAgentFactory())
 {
     TrainingRandom        = new Random(trainingSeed);
     NetworkFile           = networkFile;
     Network               = new AgentNetwork(networkFile);
     TrainingConfiguration = trainingConfiguration;
 }
Пример #3
0
        public void Fit(IEnumerable <MarkovHistoryItem> batch, AgentNetworkTrainingConfiguration configuration, Random random)
        {
            var optimizer = new SGDMomentum(Network, configuration.LearningRate, configuration.Momentum);
            var trainer   = new Trainer(optimizer, random);
            var nextQ     = batch.Select(item => new Projection(item.Input, new double[] { item.Reward + configuration.Gamma * Predict(item.State).Value })).ToArray();

            trainer.Train(nextQ, configuration.EpochesPerIteration, configuration.BatchSize);
        }
Пример #4
0
 public NeuralSimulationPluginFactory(string name, string network, int trainingSeed)
 {
     Name                  = name;
     Network               = network;
     TrainingSeed          = trainingSeed;
     TrainingConfiguration = new AgentNetworkTrainingConfiguration();
     TrainingProgressTrackerConfiguration = new TrainingProgressTrackerConfiguration();
 }
Пример #5
0
 public NeuralAgentTrainerConfiguration()
 {
     TrainingPluginConfiguration             = new AgentNetworkTrainingConfiguration();
     TrainingSimulationConfiguration         = new SimulationModelConfiguration();
     TrainingProgressTrackerConfiguration    = new TrainingProgressTrackerConfiguration();
     TrainingProgressSimulationConfiguration = new SimulationModelConfiguration();
     TrainingSimulationConfiguration.AgentDestructionModel.RemoveDestoryed = true;
     TrainingSimulationConfiguration.IterationLimit = 50000;
     TrainingProgressSimulationConfiguration.AgentDestructionModel.RemoveDestoryed = true;
 }