The error message “Number of input layers for state-action-value function deep neural network must equal the number of observation and action specifications” suggests that
- The critic network should have distinct input layers for observations and actions.
- These input layers must be combined using a concatenation layer before they proceed through the rest of the network.
You can modify your critic network setup as given below:
% Define observation and action input layers
obsInputLayer = featureInputLayer(prod(obsInfo.Dimension), 'Name', 'obsInput');
actInputLayer = featureInputLayer(prod(actInfo.Dimension), 'Name', 'actInput');
% Define the layers for the critic network
criticLayers = [
concatenationLayer(1, 2, 'Name', 'concat')
fullyConnectedLayer(200, 'Name', 'fc1')
reluLayer('Name', 'relu1')
fullyConnectedLayer(200, 'Name', 'fc2')
reluLayer('Name', 'relu2')
fullyConnectedLayer(1, 'Name', 'qValue')];
% Create the critic network
criticNet = layerGraph();
criticNet = addLayers(criticNet, obsInputLayer);
criticNet = addLayers(criticNet, actInputLayer);
criticNet = addLayers(criticNet, criticLayers);
% Connect the input layers to the concatenation layer
criticNet = connectLayers(criticNet, 'obsInput', 'concat/in1');
criticNet = connectLayers(criticNet, 'actInput', 'concat/in2');
% Convert to dlnetwork
criticNet = dlnetwork(criticNet);
% Create Critic object
critic = rlQValueFunction(criticNet, obsInfo, actInfo);
The second error message “Error using dlnetwork argument list is invalid. The function requires 1 additional input.” typically occurs when:
- The layers are not correctly added to the ‘dlnetwork’ object.
- The above solution will address this by correctly setting up the layer graph and converting it to a ‘dlnetwork’.
Hope this helps!