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.

setLearnableParameterValues

Set learnable parameter values of policy or value function representation

Syntax

newRep = setLearnableParameterValues(oldRep,val)

Description

example

newRep = setLearnableParameterValues(oldRep,val) returns a new policy or value function representation, newRep, with the same structure as the original representation, oldRep, and the learnable parameter values specified in val.

Examples

collapse all

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

Obtain the critic representation from the agent.

critic = getCritic(agent);

Obtain the learnable parameters from the critic.

params = getLearnableParameters(critic);

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.

critic = setLearnableParameterValues(critic,modifiedParams);

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

agent = setCritic(agent,critic);

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);

Input Arguments

collapse all

Original policy or value function representation, specified as one of the following:

  • rlLayerRepresentation object for deep neural network representations

  • rlTableRepresentation object for value table or Q table representations

To create a policy or value function representation, use one of the following methods:

  • Create a representation using rlRepresentation.

  • Obtain the existing value function representation from an agent using getCritic

  • Obtain the existing policy representation from an agent using getActor.

Learnable parameter values for the representation object, specified as a cell array. The parameters in val must be compatible with the structure and parameterization of oldRep.

To obtain a cell array of learnable parameter values from an existing representation, which you can then modify, use the getLearnableParameterValues function.

Output Arguments

collapse all

New policy or value function representation, returned as a representation object of the same type as oldRep. newRep has the same structure as oldRep but with parameter values from val.

Introduced in R2019a