I received this error in DDPG "Model input sizes must match the dimensions specified in the corresponding observation and action info specifications."

12 vues (au cours des 30 derniers jours)
hi every body
i want to impliment LSTM layers in state path of my critic network
my code is :
obsInfo = rlNumericSpec([42 1]);
obsInfo.Name = 'observation';
actInfo = rlNumericSpec([6 1]);
actInfo.Name = 'action';
actInfo.UpperLimit =0.01*ones(6,1);
actInfo.LowerLimit =-0.01*ones(6,1);
numObs=prod(obsInfo.Dimension) ;
numAcs=prod(actInfo.Dimension) ;
numHiddenUnits=100;
statePath = [sequenceInputLayer(numObs)
lstmLayer(numHiddenUnits,'OutputMode','sequence')
fullyConnectedLayer(500,'Name','CriticStateFC1')
reluLayer('Name', 'CriticStateRelu1')
fullyConnectedLayer(450,'Name','CriticStateFC2')
reluLayer('Name', 'CriticStateRelu2')
fullyConnectedLayer(300,'Name','CriticStateFC3')
reluLayer('Name', 'CriticStateRelu3')
fullyConnectedLayer(250,'Name','CriticStateFC4')
reluLayer('Name', 'CriticStateRelu4')
fullyConnectedLayer(200,'Name','CriticStateFC5')
reluLayer('Name', 'CriticStateRelu5')
fullyConnectedLayer(100,'Name','CriticStateFC6')
reluLayer('Name', 'CriticStateRelu6')
fullyConnectedLayer(50,'Name','CriticStateFC7')
reluLayer('Name', 'CriticStateRelu7')
fullyConnectedLayer(25,'Name','CriticStateFC8')
];
actionPath = [
sequenceInputLayer(numAcs)
fullyConnectedLayer(300,'Name','CriticActionFC1')
reluLayer('Name', 'CriticActionRelu1')
fullyConnectedLayer(250,'Name','CriticActionFC2')
reluLayer('Name', 'CriticActionRelu2')
fullyConnectedLayer(200,'Name','CriticActionFC3')
reluLayer('Name', 'CriticActionRelu3')
fullyConnectedLayer(100,'Name','CriticActionFC4')
reluLayer('Name', 'CriticActionRelu4')
fullyConnectedLayer(50,'Name','CriticActionFC5')
reluLayer('Name', 'CriticActionRelu5')
fullyConnectedLayer(25,'Name','CriticActionFC6')];
commonPath = [
concatenationLayer(1,2,Name='concat')
reluLayer('Name','CriticCommonRelu')
fullyConnectedLayer(512,'Name','CriticCommon1')
reluLayer('Name','CriticCommonRelu2')
fullyConnectedLayer(300,'Name','CriticCommon2')
reluLayer('Name','CriticCommonRelu3')
fullyConnectedLayer(1,'Name','CriticOutput')];
criticOpts =rlOptimizerOptions(LearnRate=1e-04,GradientThreshold=inf,...
L2RegularizationFactor=0.0001,Optimizer="adam");
criticNetwork = layerGraph();
criticNetwork = addLayers(criticNetwork,statePath);
criticNetwork = addLayers(criticNetwork,actionPath);
criticNetwork = addLayers(criticNetwork,commonPath);
criticNetwork = connectLayers(criticNetwork,'CriticStateFC8','concat/in1');
criticNetwork = connectLayers(criticNetwork,'CriticActionFC6','concat/in2');
criticNetwork = dlnetwork(criticNetwork);
analyzeNetwork(criticNetwork)
critic = rlQValueFunction(criticNetwork,obsInfo,actInfo,...
ObservationInputNames='observation',ActionInputNames='action',UseDevice="gpu");
when i run above code i received this error
"Error using rlQValueFunction
Model input sizes must match the dimensions specified in the corresponding observation
and action info specifications." please help me

Réponses (1)

Emmanouil Tzorakoleftherakis
The easiest way to discover your error yourself is to use the default agent feature have use the network architecture that's automatically generated by Reinforcement Learning Toolbox. Please take a look here. Don't forget to indicate that you want your network to use LSTM layers in the initialization options.
Per the example in the link above, after the agent is created, you can extract the actor and critic and compare the generated architecture with what you have.
Hope this helps

Tags

Produits


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by