예제 #1
0
    public void StartTensorboard()
    {
        var args = new List <string>();

        args.Add("--logdir=" + tensorFlowCOnfig.SummariesDirectory);
        CommandLineRunner.StartCommandLine(tensorFlowCOnfig.TensorboardDirectory, "tensorboard", args.ToArray());
    }
    IEnumerator DoTrainingCo()
    {
        Process currentProcess = null;

        configIncrement = StartingConfigIncrement;
        while (configIncrement <= MaxConfigIncrement)
        {
            if (OnStartIncrement != null)
            {
                OnStartIncrement.Invoke();
            }

            for (currentRun = 0; currentRun < RunsPerConfiguration; currentRun++)
            {
                yield return(new WaitForSeconds(PauseBeforeRun));

                UnityEngine.Debug.Log("Starting run " + currentRun + " in config increment " + configIncrement);

                var myArguments = new List <string>(); // Make a copy of the args
                var runId       = RunSetName + "-inc" + configIncrement + "-run" + currentRun;
                myArguments.Add(UnityOutputExeName);
                myArguments.Add("--run-id=" + runId); // Add our own arg
                myArguments.Add("--train");

                if (ContinueFromSaved == true)
                {
                    myArguments.Add("--load");
                    var sourcePath = Path.Combine(tensorFlowConfig.ModelsDirectory, ContinueFromModel);
                    var targetPath = Path.Combine(tensorFlowConfig.ModelsDirectory, runId);
                    Directory.CreateDirectory(targetPath);
                    CopyDirectory(sourcePath, targetPath);
                }

                CommandLineRunner.WorkingDirectory = tensorFlowConfig.MlAgentsRootDirectory;
                currentProcess = CommandLineRunner.StartCommandLine(tensorFlowConfig.MlAgentsRootDirectory, "learn.py", myArguments.ToArray());

                // Coroutine hold until process is complete
                while (currentProcess.HasExited == false)
                {
                    yield return(null);
                }

                if (TbManager != null)
                {
                    yield return(StartCoroutine(TbManager.GetRunStats(runId, currentRun, configIncrement, new Action <RunStatistics>(AddToStats))));
                }
            }
            currentRun = 0;

            if (OnNextIncrement != null)
            {
                OnNextIncrement.Invoke();
            }
        }

        if (OnAllIncrementsComplete != null)
        {
            OnAllIncrementsComplete.Invoke();
        }
    }