getAction
Obtain action from agent, actor, or policy object given environment observations
Since R2020a
Syntax
Description
Agent
Actor
Policy
[
also returns the updated policy as an output argument (any internal state of the policy,
if used, is updated).action
,updatedPolicy
] = getAction(policy
,obs
)
Use Forward
___ = getAction(___,UseForward=
allows you to explicitly call a forward pass when computing gradients.useForward
)
Examples
Input Arguments
Output Arguments
Tips
The function
evaluate
behaves, for actor objects, similarly togetAction
except for the following differences.For an
rlDiscreteCategoricalActor
actor object,evaluate
returns the probability of each possible actions, (instead of a sample action asgetAction
).For an
rlContinuousGaussianActor
actor object,evaluate
returns the mean and standard deviation of the Gaussian distribution, (instead of a sample action asgetAction
).
When the elements of the cell array in
inData
aredlarray
objects, the elements of the cell array returned inoutData
are alsodlarray
objects. This allowsgetAction
to be used with automatic differentiation.Specifically, you can write a custom loss function that directly uses
getAction
anddlgradient
within it, and then usedlfeval
anddlaccelerate
with your custom loss function. For an example, see Train Reinforcement Learning Policy Using Custom Training Loop and Custom Training Loop with Simulink Action Noise.
Version History
Introduced in R2020a