浏览代码

inference seed, increment seed for ModelRunner (#3823)

* inference seed, increment seed for ModelRunner

* changelog
/develop/dockerfile
GitHub 5 年前
当前提交
e33a343c
共有 3 个文件被更改,包括 20 次插入2 次删除
  1. 2
      com.unity.ml-agents/CHANGELOG.md
  2. 19
      com.unity.ml-agents/Runtime/Academy.cs
  3. 1
      com.unity.ml-agents/Tests/Runtime/RuntimeAPITest.cs

2
com.unity.ml-agents/CHANGELOG.md


- Running `mlagents-learn` with the same `--run-id` twice will no longer
overwrite the existing files. (#3705)
- `StackingSensor` was changed from `internal` visibility to `public`
- Academy.InferenceSeed property was added. This is used to initialize the
random number generator in ModelRunner, and is incremented for each ModelRunner. (#3823)
- Updated Barracuda to 0.6.3-preview.
- Model updates can now happen asynchronously with environment steps for better performance. (#3690)
- `num_updates` and `train_interval` for SAC were replaced with `steps_per_update`. (#3690)

19
com.unity.ml-agents/Runtime/Academy.cs


// Flag used to keep track of the first time the Academy is reset.
bool m_HadFirstReset;
// Random seed used for inference.
int m_InferenceSeed;
/// <summary>
/// Set the random seed used for inference. This should be set before any Agents are added
/// to the scene. The seed is passed to the ModelRunner constructor, and incremented each
/// time a new ModelRunner is created.
/// </summary>
public int InferenceSeed
{
set { m_InferenceSeed = value; }
}
// The Academy uses a series of events to communicate with agents
// to facilitate synchronization. More specifically, it ensure
// that all the agents performs their steps in a consistent order (i.e. no

name = "AcademySingleton",
});
UnityEngine.Random.InitState(unityRlInitParameters.seed);
// We might have inference-only Agents, so set the seed for them too.
m_InferenceSeed = unityRlInitParameters.seed;
}
catch
{

var modelRunner = m_ModelRunners.Find(x => x.HasModel(model, inferenceDevice));
if (modelRunner == null)
{
modelRunner = new ModelRunner(
model, brainParameters, inferenceDevice);
modelRunner = new ModelRunner(model, brainParameters, inferenceDevice, m_InferenceSeed);
m_InferenceSeed++;
}
return modelRunner;
}

1
com.unity.ml-agents/Tests/Runtime/RuntimeAPITest.cs


[UnityTest]
public IEnumerator RuntimeApiTestWithEnumeratorPasses()
{
Academy.Instance.InferenceSeed = 1337;
var gameObject = new GameObject();
var behaviorParams = gameObject.AddComponent<BehaviorParameters>();

正在加载...
取消
保存