setActor

Set actor representation of reinforcement learning agent

Syntax

newAgent = setActor(oldAgent,actor)

Description

example

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.

Examples

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')
        fullyConnectedLayer(2,'Name','action')];

Create an actor representation with an additional fully connected layer.

actorNetwork = [
        imageInputLayer([4 1 1],'Normalization','none','Name','state')
        fullyConnectedLayer(3,'Name','x');
        fullyConnectedLayer(2,'Name','action')];
actor = rlRepresentation(actorNetwork,...
    'Observation',{'state'},getObservationInfo(env),
    'Action',{'action'},getActionInfo(env));

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