错误使用 rlDetermin​isticActor​Representa​tion。Obser​vation names must match the names of the deep neural network's input layers.

조회 수: 15 (최근 30일)
% 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);

답변 (1개)

Ronit
Ronit 2024년 8월 12일
Hello,
The error you're encountering is due to a mismatch between the observation names used in your environment's observation specification ‘stateSpec.Name’ and the names of the input layers in your deep neural network. The names must match exactly.
Here’s how you can resolve this issue:
  1. Ensure that the ‘Name’ property of the ‘featureInputLayer’ in your actor and critic networks matches the Name property of ‘stateSpec’.
  2. Verify that the ‘stateSpec.Name’ is correctly defined and matches the names used in your neural network.
  3. Try adding a check to ensure that ‘stateName’ is a string. If ‘stateName’ is a cell array, it extracts the first element. This should ensure that the ‘Name’ property of the ‘featureInputLayer’ matches the Name property of ‘stateSpec’.
% Ensure stateName is a string
if iscell(stateName)
stateName = stateName{1};
end
Although, ‘rlDeterministicActorRepresentation’ is not recommended anymore since R2022a, you can use ‘rlContinuousDeterministicActor’ instead.
For more details, please refer to the following documentations:
Hope it helps!
  댓글 수: 3
Ronit
Ronit 2024년 8월 13일
Try and use 'rlContinuousDeterministicActor' instead of 'rlDeterministicActorRepresentation'.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by