- Ensure that the ‘Name’ property of the ‘featureInputLayer’ in your actor and critic networks matches the Name property of ‘stateSpec’.
- Verify that the ‘stateSpec.Name’ is correctly defined and matches the names used in your neural network.
- 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’.
错误使用 rlDeterministicActorRepresentation。Observation 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);
0 个评论
回答(1 个)
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:
% 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
2024-8-13
Try and use 'rlContinuousDeterministicActor' instead of 'rlDeterministicActorRepresentation'.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Deep Learning Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!