Class Academy
The Academy singleton manages agent training and decision making.
Namespace: Unity.MLAgents
Syntax
public class Academy : IDisposable
Remarks
Access the Academy singleton through the Instance property. The Academy instance is initialized the first time it is accessed (which will typically be by the first Agent initialized in a scene).
At initialization, the Academy attempts to connect to the Python training process through the external communicator. If successful, the training process can train Agent instances. When you set an agent's BehaviorType setting to Default, the agent exchanges data with the training process to make decisions. If no training process is available, agents with the default behavior fall back to inference or heuristic decisions. (You can also set agents to always use inference or heuristics.)
Properties
AutomaticSteppingEnabled
Determines whether or not the Academy is automatically stepped during the FixedUpdate phase.
Declaration
public bool AutomaticSteppingEnabled { get; set; }
Property Value
Type | Description |
---|---|
Boolean | Set |
EnvironmentParameters
Returns the EnvironmentParameters instance. If training features such as Curriculum Learning or Environment Parameter Randomization are used, then the values of the parameters generated from the training process can be retrieved here.
Declaration
public EnvironmentParameters EnvironmentParameters { get; }
Property Value
Type | Description |
---|---|
EnvironmentParameters |
EpisodeCount
The current episode count.
Declaration
public int EpisodeCount { get; }
Property Value
Type | Description |
---|---|
Int32 | Current episode number. |
InferenceSeed
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.
Declaration
public int InferenceSeed { set; }
Property Value
Type | Description |
---|---|
Int32 |
Instance
The singleton Academy object.
Declaration
public static Academy Instance { get; }
Property Value
Type | Description |
---|---|
Academy | Getting the instance initializes the Academy, if necessary. |
IsCommunicatorOn
Reports whether or not the communicator is on.
Declaration
public bool IsCommunicatorOn { get; }
Property Value
Type | Description |
---|---|
Boolean |
|
See Also
IsInitialized
Reports whether the Academy has been initialized yet.
Declaration
public static bool IsInitialized { get; }
Property Value
Type | Description |
---|---|
Boolean |
|
StatsRecorder
Returns the StatsRecorder instance. This instance can be used to record any statistics from the Unity environment.
Declaration
public StatsRecorder StatsRecorder { get; }
Property Value
Type | Description |
---|---|
StatsRecorder |
StepCount
The current step count (within the current episode).
Declaration
public int StepCount { get; }
Property Value
Type | Description |
---|---|
Int32 | Current step count. |
TotalStepCount
Returns the total step count.
Declaration
public int TotalStepCount { get; }
Property Value
Type | Description |
---|---|
Int32 | Total step count. |
Methods
Dispose()
Shut down the Academy.
Declaration
public void Dispose()
EnvironmentStep()
Performs a single environment update of the Academy and Agent objects within the environment.
Declaration
public void EnvironmentStep()
Events
AgentPreStep
Signals to all of the Agents that their step is about to begin. This is a good time for an Agent to decide if it would like to call RequestDecision() or RequestAction() for this step. Any other pre-step setup could be done during this even as well.
Declaration
public event Action<int> AgentPreStep
Event Type
Type | Description |
---|---|
Action<Int32> |
OnEnvironmentReset
Signals that the Academy has been reset by the training process.
Declaration
public event Action OnEnvironmentReset
Event Type
Type | Description |
---|---|
Action |