错误使用 rlDeterministicActorRepresentation。Observation names must match the names of the deep neural network’s input layers.
% Create Environment
env = MYEnv();
% Define State and Action Specifications
stateSpec = env.getObservationInfo();
actionSpec = env.getActionInfo();
stateName = stateSpec.Name;
% Create Actor Network
actorNetwork = [
featureInputLayer(stateSpec.Dimension(1), ‘Name’, stateName)
fullyConnectedLayer(400, ‘Name’, ‘ActorHiddenLayer1’)
reluLayer(‘Name’, ‘ActorReLU1’)
fullyConnectedLayer(300, ‘Name’, ‘ActorHiddenLayer2’)
reluLayer(‘Name’, ‘ActorReLU2’)
fullyConnectedLayer(actionSpec.Dimension(1), ‘Name’, ‘ActorOutputLayer’)
tanhLayer(‘Name’, ‘ActorTanh’)
];
% Create Critic Network
criticNetwork = [
featureInputLayer(stateSpec.Dimension(1), ‘Name’, stateName)
fullyConnectedLayer(400, ‘Name’, ‘CriticHiddenLayer1’)
reluLayer(‘Name’, ‘CriticReLU1’)
fullyConnectedLayer(300, ‘Name’, ‘CriticHiddenLayer2’)
reluLayer(‘Name’, ‘CriticReLU2’)
fullyConnectedLayer(1, ‘Name’, ‘CriticOutputLayer’)
];
% Create Actor Representation
actorOpts = rlRepresentationOptions(‘LearnRate’, actorLearningRate);
actor = rlDeterministicActorRepresentation(actorNetwork, stateSpec, actionSpec, actorOpts);% Create Environment
env = MYEnv();
% Define State and Action Specifications
stateSpec = env.getObservationInfo();
actionSpec = env.getActionInfo();
stateName = stateSpec.Name;
% Create Actor Network
actorNetwork = [
featureInputLayer(stateSpec.Dimension(1), ‘Name’, stateName)
fullyConnectedLayer(400, ‘Name’, ‘ActorHiddenLayer1’)
reluLayer(‘Name’, ‘ActorReLU1’)
fullyConnectedLayer(300, ‘Name’, ‘ActorHiddenLayer2’)
reluLayer(‘Name’, ‘ActorReLU2’)
fullyConnectedLayer(actionSpec.Dimension(1), ‘Name’, ‘ActorOutputLayer’)
tanhLayer(‘Name’, ‘ActorTanh’)
];
% Create Critic Network
criticNetwork = [
featureInputLayer(stateSpec.Dimension(1), ‘Name’, stateName)
fullyConnectedLayer(400, ‘Name’, ‘CriticHiddenLayer1’)
reluLayer(‘Name’, ‘CriticReLU1’)
fullyConnectedLayer(300, ‘Name’, ‘CriticHiddenLayer2’)
reluLayer(‘Name’, ‘CriticReLU2’)
fullyConnectedLayer(1, ‘Name’, ‘CriticOutputLayer’)
];
% Create Actor Representation
actorOpts = rlRepresentationOptions(‘LearnRate’, actorLearningRate);
actor = rlDeterministicActorRepresentation(actorNetwork, stateSpec, actionSpec, actorOpts); % Create Environment
env = MYEnv();
% Define State and Action Specifications
stateSpec = env.getObservationInfo();
actionSpec = env.getActionInfo();
stateName = stateSpec.Name;
% Create Actor Network
actorNetwork = [
featureInputLayer(stateSpec.Dimension(1), ‘Name’, stateName)
fullyConnectedLayer(400, ‘Name’, ‘ActorHiddenLayer1’)
reluLayer(‘Name’, ‘ActorReLU1’)
fullyConnectedLayer(300, ‘Name’, ‘ActorHiddenLayer2’)
reluLayer(‘Name’, ‘ActorReLU2’)
fullyConnectedLayer(actionSpec.Dimension(1), ‘Name’, ‘ActorOutputLayer’)
tanhLayer(‘Name’, ‘ActorTanh’)
];
% Create Critic Network
criticNetwork = [
featureInputLayer(stateSpec.Dimension(1), ‘Name’, stateName)
fullyConnectedLayer(400, ‘Name’, ‘CriticHiddenLayer1’)
reluLayer(‘Name’, ‘CriticReLU1’)
fullyConnectedLayer(300, ‘Name’, ‘CriticHiddenLayer2’)
reluLayer(‘Name’, ‘CriticReLU2’)
fullyConnectedLayer(1, ‘Name’, ‘CriticOutputLayer’)
];
% Create Actor Representation
actorOpts = rlRepresentationOptions(‘LearnRate’, actorLearningRate);
actor = rlDeterministicActorRepresentation(actorNetwork, stateSpec, actionSpec, actorOpts); observation names, rldeterministicactorrepresentation MATLAB Answers — New Questions