Navigation
API > API/Plugins > API/Plugins/LearningAgentsTraining
Inheritance Hierarchy
- UObjectBase
- UObjectBaseUtility
- UObject
- UActorComponent
- ULearningAgentsManagerComponent
- ULearningAgentsTrainer
References
| Module | LearningAgentsTraining |
| Header | /Engine/Plugins/Experimental/LearningAgents/Source/LearningAgentsTraining/Public/LearningAgentsTrainer.h |
| Include | #include "LearningAgentsTrainer.h" |
Syntax
UCLASS&40;Abstract, BlueprintType, Blueprintable&41;
class ULearningAgentsTrainer : public ULearningAgentsManagerComponent
Remarks
The ULearningAgentsTrainer is the core class for reinforcement learning training. It has a few responsibilities: 1) It keeps track of which agents are gathering training data. 2) It defines how those agents' rewards, completions, and resets are implemented. 3) It provides methods for orchestrating the training process.
To use this class, you need to implement the SetupRewards and SetupCompletions functions (as well as their corresponding SetRewards and SetCompletions functions), which will define the rewards and penalties the agent receives and what conditions cause an episode to end. Before you can begin training, you need to call SetupTrainer, which will initialize the underlying data structures, and you need to call AddAgent for each agent you want to gather training data from.
Constructors
| Type | Name | Description | |
|---|---|---|---|
| Setup | |||
ULearningAgentsTrainer
(
FVTableHelper& Helper |
Destructors
| Type | Name | Description | |
|---|---|---|---|
Functions
| Type | Name | Description | |
|---|---|---|---|
| void | AddCompletion
(
TObjectPtr< ULearningAgentsCompletion > Object, |
Used by objects derived from ULearningAgentsCompletion to add themselves to this trainer during their creation. | |
| void | AddReward
(
TObjectPtr< ULearningAgentsReward > Object, |
Used by objects derived from ULearningAgentsReward to add themselves to this trainer during their creation. | |
| void | BeginTraining
(
const FLearningAgentsTrainerTrainingSettings& TrainerTrainingSettings, |
Begins the training process with the provided settings. | |
| void | EndTraining () |
Stops the training process. | |
| void | Call this function when it is time to evaluate the completions for your agents. | ||
| void | Call this function when it is time to evaluate the rewards for your agents. | ||
| float | GetReward
(
const int32 AgentId |
Gets the current reward for an agent according to the critic. | |
| bool | Returns true if the trainer has failed to communicate with the external training process. | ||
| bool | IsCompleted
(
const int32 AgentId, |
Gets if the agent will complete the episode or not according to the given set of completions. | |
| const bool | IsTraining () |
Training Process | |
| void | Call this function at the end of each step of your training loop. | ||
| void | ResetEpisodes
(
const TArray< int32 >& AgentIds |
Resets | |
| void | RunTraining
(
const FLearningAgentsTrainerTrainingSettings& TrainerTrainingSettings, |
Convenience function that runs a basic training loop. | |
| void | SetCompletions
(
const TArray< int32 >& AgentIds |
During this event, all completions should be set for each agent. | |
| void | SetRewards
(
const TArray< int32 >& AgentIds |
During this event, all rewards/penalties should be set for each agent. | |
| void | Completions | ||
| void | SetupRewards () |
Rewards | |
| void | SetupTrainer
(
ULearningAgentsInteractor* InInteractor, |
Initializes this object and runs the setup functions for rewards and completions. |
Overridden from ULearningAgentsManagerComponent
| Type | Name | Description | |
|---|---|---|---|
| void | OnAgentsAdded
(
const TArray< int32 >& AgentIds |
Called whenever agents are added to the parent ALearningAgentsManager object. | |
| void | OnAgentsRemoved
(
const TArray< int32 >& AgentIds |
Called whenever agents are removed from the parent ALearningAgentsManager object. | |
| void | OnAgentsReset
(
const TArray< int32 >& AgentIds |
Called whenever agents are reset on the parent ALearningAgentsManager object. |
Overridden from UActorComponent
| Type | Name | Description | |
|---|---|---|---|
| void | EndPlay
(
const EEndPlayReason::Type EndPlayReason |
Will automatically call EndTraining if training is still in-progress when play is ending. |
See Also
ULearningAgentsInteractor to understand how observations and actions work.