- 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 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
% 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 commentaires
Réponses (1)
Ronit
le 12 Août 2024
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 commentaires
Ronit
le 13 Août 2024
Try and use 'rlContinuousDeterministicActor' instead of 'rlDeterministicActorRepresentation'.
Voir également
Catégories
En savoir plus sur Deep Learning Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!