This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Set actor representation of reinforcement learning agent


newAgent = setActor(oldAgent,actor)



newAgent = setActor(oldAgent,actor) returns a new reinforcement learning agent, newAgent, that uses the specified actor representation. Apart from the actor representation, the new agent has the same configuration as the specified original agent, oldAgent.


collapse all

Assume that you have an existing trained reinforcement learning agent, agent.

Obtain the actor representation from the agent.

actor = getActor(agent);

Obtain the learnable parameters from the critic.

params = getLearnableParameters(actor);

Modify the parameter values. For this example, simply multiply all of the parameters by 2.

modifiedParams = cellfun(@(x) x*2,params,'UniformOutput',false);

Set the parameter values of the critic to the new modified values.

actor = setLearnableParameterValues(actor,modifiedParams);

Set the critic in the agent to the new modified critic.

agent = setActor(agent,actor);

Assume that you have an existing reinforcement learning agent, agent.

Further, assume that this agent has an actor representation that contains the following deep neural network structure.

originalActor = [
        imageInputLayer([4 1 1],'Normalization','none','Name','state')

Create an actor representation with an additional fully connected layer.

actorNetwork = [
        imageInputLayer([4 1 1],'Normalization','none','Name','state')
actor = rlRepresentation(actorNetwork,...

Set the actor representation of the agent to the new augmented actor.

agent = setActor(actor);

Input Arguments

collapse all

Original reinforcement learning agent that contains an actor representation, specified as one of the following:

Actor representation object, specified as one of the following:

  • rlLayerRepresentation object for deep neural network representations

  • rlTableRepresentation object for value table or Q table representations

The input and output layers of the specified representation must match the observation and action specifications of the original agent.

To create an actor representation, use one of the following methods:

Output Arguments

collapse all

Updated reinforcement learning agent, returned as an agent object that uses the specified actor representation. Apart from the actor representation, the new agent has the same configuration as oldAgent.

Introduced in R2019a