getAction
Obtain action from agent, actor, or policy object given environment observations
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
evaluatebehaves, for actor objects, similarly togetActionexcept for the following differences.For an
rlDiscreteCategoricalActoractor object,evaluatereturns the probability of each possible actions, (instead of a sample action asgetAction).For an
rlContinuousGaussianActoractor object,evaluatereturns the mean and standard deviation of the Gaussian distribution, (instead of a sample action asgetAction).
When the elements of the cell array in
inDataaredlarrayobjects, the elements of the cell array returned inoutDataare alsodlarrayobjects. This allowsgetActionto be used with automatic differentiation.Specifically, you can write a custom loss function that directly uses
getActionanddlgradientwithin it, and then usedlfevalanddlacceleratewith 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