actor-凯发k8网页登录

main content

actor-critic (ac) agents

you can use the actor-critic (ac) agent, which uses a model-free, online, on-policy reinforcement learning method, to implement actor-critic algorithms, such as a2c and a3c. the goal of this agent is to optimize the policy (actor) directly and train a critic to estimate the return or future rewards [1].

for more information on the different types of reinforcement learning agents, see reinforcement learning agents.

actor-critic agents can be trained in environments with the following observation and action spaces.

observation spaceaction space
discrete or continuousdiscrete or continuous

actor-critic agents use the following actor and critics.

criticactor

value function critic v(s), which you create using

stochastic policy actor π(s), which you create using (for discrete action spaces) or (for continuous action spaces)

during training, an actor-critic agent:

  • estimates probabilities of taking each action in the action space and randomly selects actions based on the probability distribution.

  • interacts with the environment for multiple steps using the current policy before updating the actor and critic properties.

if the useexplorationpolicy option of the agent is set to false the action with maximum likelihood is always used in sim and . as a result, the simulated agent and generated policy behave deterministically.

if the useexplorationpolicy is set to true the agent selects its actions by sampling its probability distribution. as a result the policy is stochastic and the agent explores its observation space.

this option affects only simulation and deployment; it does not affect training.

actor and critic function approximators

to estimate the policy and value function, an actor-critic agent maintains two function approximators.

  • actor π(a|s;θ) — the actor, with parameters θ, outputs the conditional probability of taking each action a when in state s as one of the following:

    • discrete action space — the probability of taking each discrete action. the sum of these probabilities across all actions is 1.

    • continuous action space — the mean and standard deviation of the gaussian probability distribution for each continuous action.

  • critic v(s;ϕ) — the critic, with parameters ϕ, takes observation s and returns the corresponding expectation of the discounted long-term reward.

for more information on creating actors and critics for function approximation, see create policies and value functions.

during training, the agent tunes the parameter values in θ. after training, the parameters remain at their tuned value and the trained actor function approximator is stored in π(a|s).

agent creation

you can create an actor-critic agent with default actor and critics based on the observation and action specifications from the environment. to do so, perform the following steps.

  1. create observation specifications for your environment. if you already have an environment interface object, you can obtain these specifications using getobservationinfo.

  2. create action specifications for your environment. if you already have an environment interface object, you can obtain these specifications using getactioninfo.

  3. if needed, specify the number of neurons in each learnable layer or whether to use an lstm layer. to do so, create an agent initialization option object using .

  4. if needed, specify agent options using an rlacagentoptions object.

  5. create the agent using an rlacagent object.

alternatively, you can create actor and critic and use these objects to create your agent. in this case, ensure that the input and output dimensions of the actor and critic match the corresponding action and observation specifications of the environment.

  1. create an actor using an (for discrete action spaces) or an (for continuous action spaces) object.

  2. create a critic using an object.

  3. specify agent options using an rlacagentoptions object.

  4. create the agent using an rlacagent object.

for more information on creating actors and critics for function approximation, see create policies and value functions.

training algorithm

actor-critic agents use the following training algorithm. to configure the training algorithm, specify options using an rlacagentoptions object.

  1. initialize the actor π(a|s;θ) with random parameter values θ.

  2. initialize the critic v(s;ϕ) with random parameter values ϕ.

  3. generate n experiences by following the current policy. the episode experience sequence is

    sts,ats,rts 1,sts 1,,sts n1,ats n1,rts n,sts n

    here, st is a state observation, at is an action taken from that state, st 1 is the next state, and rt 1 is the reward received for moving from st to st 1.

    when in state st, the agent computes the probability of taking each action in the action space using π(a|st;θ) and randomly selects action at based on the probability distribution.

    ts is the starting time step of the current set of n experiences. at the beginning of the training episode, ts = 1. for each subsequent set of n experiences in the same training episode, ts = ts n.

    for each training episode that does not contain a terminal state, n is equal to the numstepstolookahead option value. otherwise, n is less than numstepstolookahead and sn is the terminal state.

  4. for each episode step t = ts, ts 1, …, ts n, compute the return gt, which is the sum of the reward for that step and the discounted future reward. if sts n is not a terminal state, the discounted future reward includes the discounted state value function, computed using the critic network v.

    gt=k=t 1ts n(γkt1rk) bγts ntv(sts n;ϕ)

    here, b is 0 if sts n is a terminal state and 1 otherwise.

    to specify the discount factor γ, use the discountfactor option.

  5. compute the advantage function dt.

    dt=gtv(st;ϕ)

  6. accumulate the gradients for the actor network by following the policy gradient to maximize the expected discounted reward.

    dθ=t=1nθμlnπ(a|st;θ)dt

  7. accumulate the gradients for the critic network by minimizing the mean squared error loss between the estimated value function v (st;ϕ) and the computed target return gt across all n experiences. if the entropylossweight option is greater than zero, then additional gradients are accumulated to minimize the entropy loss function.

    dϕ=t=1nϕ(gtv(st;ϕ))2

  8. update the actor parameters by applying the gradients.

    θ=θ αdθ

    here, α is the learning rate of the actor. specify the learning rate when you create the actor by setting the learnrate option in the rlactoroptimizeroptions property within the agent options object.

  9. update the critic parameters by applying the gradients.

    ϕ=ϕ βdϕ

    here, β is the learning rate of the critic. specify the learning rate when you create the critic by setting the learnrate option in the rlcriticoptimizeroptions property within the agent options object.

  10. repeat steps 3 through 9 for each training episode until training is complete.

for simplicity, the actor and critic updates in this algorithm description show a gradient update using basic stochastic gradient descent. the actual gradient update method depends on the optimizer you specify using in the rloptimizeroptions object assigned to the rlcriticoptimizeroptions property.

references

[1] mnih, volodymyr, adrià puigdomènech badia, mehdi mirza, alex graves, timothy p. lillicrap, tim harley, david silver, and koray kavukcuoglu. “asynchronous methods for deep reinforcement learning.” arxiv:1602.01783 [cs], february 4, 2016..

see also

objects

related examples

more about

网站地图