rlValueFunction error: The number of network input layers must be equal to the number of observation channels in the environment specification object.
Hi,
I am currently training the biped robot with PPO algorithm. I used rlValueFunction to create critic, but it keep shows this error:
Error using rl.internal.validate.mapFunctionObservationInput (line 5)
The number of network input layers must be equal to the number of observation channels in the
environment specification object.
Error in rlValueFunction (line 81)
model = rl.internal.validate.mapFunctionObservationInput(model,observationInfo,…
Error in createPPONetworks (line 219)
critic = rlValueFunction(criticNetwork,env.getObservationInfo)
The critic network code and plot image is below:
criticLayerSizes = [600,400]; %400,300
statePath = [
imageInputLayer([31 1 1],’Normalization’,’none’,’Name’, ‘observation’)
fullyConnectedLayer(criticLayerSizes(1), ‘Name’, ‘CriticStateFC1’, …
‘Weights’,2/sqrt(31)*(rand(criticLayerSizes(1),31)-0.5), …
‘Bias’,2/sqrt(31)*(rand(criticLayerSizes(1),1)-0.5))
reluLayer(‘Name’,’CriticStateRelu1′)
fullyConnectedLayer(criticLayerSizes(2), ‘Name’, ‘CriticStateFC2’, …
‘Weights’,2/sqrt(criticLayerSizes(1))*(rand(criticLayerSizes(2),criticLayerSizes(1))-0.5), …
‘Bias’,2/sqrt(criticLayerSizes(1))*(rand(criticLayerSizes(2),1)-0.5))
];
actionPath = [
imageInputLayer([6 1 1],’Normalization’,’none’, ‘Name’, ‘action’) %numAct
fullyConnectedLayer(criticLayerSizes(2), ‘Name’, ‘CriticActionFC1’, …
‘Weights’,2/sqrt(6)*(rand(criticLayerSizes(2),6)-0.5), …
‘Bias’,2/sqrt(6)*(rand(criticLayerSizes(2),1)-0.5))
];
commonPath = [
additionLayer(2,’Name’,’add’)
reluLayer(‘Name’,’CriticCommonRelu1′)
fullyConnectedLayer(1, ‘Name’, ‘CriticOutput’,…
‘Weights’,2*5e-3*(rand(1,criticLayerSizes(2))-0.5), …
‘Bias’,2*5e-3*(rand(1,1)-0.5))
];
% Connect the layer graph
criticNetwork = layerGraph(statePath);
criticNetwork = addLayers(criticNetwork, actionPath);
criticNetwork = addLayers(criticNetwork, commonPath);
criticNetwork = connectLayers(criticNetwork,’CriticStateFC2′,’add/in1′);
criticNetwork = connectLayers(criticNetwork,’CriticActionFC1′,’add/in2′);
plot(criticNetwork)
% Create critic representation
criticOptions = rlRepresentationOptions(‘Optimizer’,’adam’,’LearnRate’,1e-3, …
‘GradientThreshold’,1,’L2RegularizationFactor’,2e-4);
if useGPU
%criticOptions.UseDevice = ‘gpu’;
end
critic = rlValueFunction(criticNetwork,env.getObservationInfo)
I couldn’t find why that error occurs. Can anyone please offer me some guidance regarding this problem? Thank you very much.Hi,
I am currently training the biped robot with PPO algorithm. I used rlValueFunction to create critic, but it keep shows this error:
Error using rl.internal.validate.mapFunctionObservationInput (line 5)
The number of network input layers must be equal to the number of observation channels in the
environment specification object.
Error in rlValueFunction (line 81)
model = rl.internal.validate.mapFunctionObservationInput(model,observationInfo,…
Error in createPPONetworks (line 219)
critic = rlValueFunction(criticNetwork,env.getObservationInfo)
The critic network code and plot image is below:
criticLayerSizes = [600,400]; %400,300
statePath = [
imageInputLayer([31 1 1],’Normalization’,’none’,’Name’, ‘observation’)
fullyConnectedLayer(criticLayerSizes(1), ‘Name’, ‘CriticStateFC1’, …
‘Weights’,2/sqrt(31)*(rand(criticLayerSizes(1),31)-0.5), …
‘Bias’,2/sqrt(31)*(rand(criticLayerSizes(1),1)-0.5))
reluLayer(‘Name’,’CriticStateRelu1′)
fullyConnectedLayer(criticLayerSizes(2), ‘Name’, ‘CriticStateFC2’, …
‘Weights’,2/sqrt(criticLayerSizes(1))*(rand(criticLayerSizes(2),criticLayerSizes(1))-0.5), …
‘Bias’,2/sqrt(criticLayerSizes(1))*(rand(criticLayerSizes(2),1)-0.5))
];
actionPath = [
imageInputLayer([6 1 1],’Normalization’,’none’, ‘Name’, ‘action’) %numAct
fullyConnectedLayer(criticLayerSizes(2), ‘Name’, ‘CriticActionFC1’, …
‘Weights’,2/sqrt(6)*(rand(criticLayerSizes(2),6)-0.5), …
‘Bias’,2/sqrt(6)*(rand(criticLayerSizes(2),1)-0.5))
];
commonPath = [
additionLayer(2,’Name’,’add’)
reluLayer(‘Name’,’CriticCommonRelu1′)
fullyConnectedLayer(1, ‘Name’, ‘CriticOutput’,…
‘Weights’,2*5e-3*(rand(1,criticLayerSizes(2))-0.5), …
‘Bias’,2*5e-3*(rand(1,1)-0.5))
];
% Connect the layer graph
criticNetwork = layerGraph(statePath);
criticNetwork = addLayers(criticNetwork, actionPath);
criticNetwork = addLayers(criticNetwork, commonPath);
criticNetwork = connectLayers(criticNetwork,’CriticStateFC2′,’add/in1′);
criticNetwork = connectLayers(criticNetwork,’CriticActionFC1′,’add/in2′);
plot(criticNetwork)
% Create critic representation
criticOptions = rlRepresentationOptions(‘Optimizer’,’adam’,’LearnRate’,1e-3, …
‘GradientThreshold’,1,’L2RegularizationFactor’,2e-4);
if useGPU
%criticOptions.UseDevice = ‘gpu’;
end
critic = rlValueFunction(criticNetwork,env.getObservationInfo)
I couldn’t find why that error occurs. Can anyone please offer me some guidance regarding this problem? Thank you very much. Hi,
I am currently training the biped robot with PPO algorithm. I used rlValueFunction to create critic, but it keep shows this error:
Error using rl.internal.validate.mapFunctionObservationInput (line 5)
The number of network input layers must be equal to the number of observation channels in the
environment specification object.
Error in rlValueFunction (line 81)
model = rl.internal.validate.mapFunctionObservationInput(model,observationInfo,…
Error in createPPONetworks (line 219)
critic = rlValueFunction(criticNetwork,env.getObservationInfo)
The critic network code and plot image is below:
criticLayerSizes = [600,400]; %400,300
statePath = [
imageInputLayer([31 1 1],’Normalization’,’none’,’Name’, ‘observation’)
fullyConnectedLayer(criticLayerSizes(1), ‘Name’, ‘CriticStateFC1’, …
‘Weights’,2/sqrt(31)*(rand(criticLayerSizes(1),31)-0.5), …
‘Bias’,2/sqrt(31)*(rand(criticLayerSizes(1),1)-0.5))
reluLayer(‘Name’,’CriticStateRelu1′)
fullyConnectedLayer(criticLayerSizes(2), ‘Name’, ‘CriticStateFC2’, …
‘Weights’,2/sqrt(criticLayerSizes(1))*(rand(criticLayerSizes(2),criticLayerSizes(1))-0.5), …
‘Bias’,2/sqrt(criticLayerSizes(1))*(rand(criticLayerSizes(2),1)-0.5))
];
actionPath = [
imageInputLayer([6 1 1],’Normalization’,’none’, ‘Name’, ‘action’) %numAct
fullyConnectedLayer(criticLayerSizes(2), ‘Name’, ‘CriticActionFC1’, …
‘Weights’,2/sqrt(6)*(rand(criticLayerSizes(2),6)-0.5), …
‘Bias’,2/sqrt(6)*(rand(criticLayerSizes(2),1)-0.5))
];
commonPath = [
additionLayer(2,’Name’,’add’)
reluLayer(‘Name’,’CriticCommonRelu1′)
fullyConnectedLayer(1, ‘Name’, ‘CriticOutput’,…
‘Weights’,2*5e-3*(rand(1,criticLayerSizes(2))-0.5), …
‘Bias’,2*5e-3*(rand(1,1)-0.5))
];
% Connect the layer graph
criticNetwork = layerGraph(statePath);
criticNetwork = addLayers(criticNetwork, actionPath);
criticNetwork = addLayers(criticNetwork, commonPath);
criticNetwork = connectLayers(criticNetwork,’CriticStateFC2′,’add/in1′);
criticNetwork = connectLayers(criticNetwork,’CriticActionFC1′,’add/in2′);
plot(criticNetwork)
% Create critic representation
criticOptions = rlRepresentationOptions(‘Optimizer’,’adam’,’LearnRate’,1e-3, …
‘GradientThreshold’,1,’L2RegularizationFactor’,2e-4);
if useGPU
%criticOptions.UseDevice = ‘gpu’;
end
critic = rlValueFunction(criticNetwork,env.getObservationInfo)
I couldn’t find why that error occurs. Can anyone please offer me some guidance regarding this problem? Thank you very much. rlvaluefunction, reinforcement learning, rl, rlppoagent, ppo MATLAB Answers — New Questions