Discrete Action Size Mismatch: BrainParameters Expects 4 but Model Contains 3
Description
I'm encountering an issue where the discrete action size between the ML-Agents script and the Unity environment build does not match. The BrainParameters in Unity expects 4 discrete action spaces, but the model contains 3. This leads to a mismatch error when trying to run the environment.
Error Message
Discrete Action size of the model does not match. The Brainparameters expects 4 but the model contains 3.
Environment
ml-agents: 1.1.0
ml-agents-envs: 1.1.0
Communicator API: 1.5.0
Unity Version: 3.0.0
Operating System: MacOS
Steps to Reproduce
Set up the environment with an action size mismatch between the Unity environment build and the ML-Agents script.
Run the environment.
Observe the mismatch error.
Solution
I solved the issue by configuring the default discrete action spaces of the agents using OnValidate in the Unity script. Here is the code snippet that resolved the problem:
void OnValidate()
{
// Configure action space in editor
var behaviorParameters = GetComponent<BehaviorParameters>();
if (behaviorParameters != null)
{
behaviorParameters.BrainParameters.ActionSpec = ActionSpec.MakeDiscrete(3, 3, 3, 2);
}
}
After applying the above configuration, I rebuilt the model with the correct discrete action spaces, and the problem was resolved.
Expected Behavior
The discrete action sizes between the Unity environment and the script should match, preventing the error from occurring.
Additional Context
This issue is caused by the mismatch between the number of discrete action spaces expected by BrainParameters and the number in the ML-Agents model. Modifying the action space via OnValidate and rebuilding the model resolved the problem.
Discrete Action Size Mismatch: BrainParameters Expects 4 but Model Contains 3
Description
I'm encountering an issue where the discrete action size between the ML-Agents script and the Unity environment build does not match. The
BrainParameters
in Unity expects 4 discrete action spaces, but the model contains 3. This leads to a mismatch error when trying to run the environment.Error Message
Discrete Action size of the model does not match. The Brainparameters expects 4 but the model contains 3.
Environment
ml-agents
: 1.1.0ml-agents-envs
: 1.1.0Steps to Reproduce
Solution
I solved the issue by configuring the default discrete action spaces of the agents using
OnValidate
in the Unity script. Here is the code snippet that resolved the problem:After applying the above configuration, I rebuilt the model with the correct discrete action spaces, and the problem was resolved.
Expected Behavior
The discrete action sizes between the Unity environment and the script should match, preventing the error from occurring.
Additional Context
This issue is caused by the mismatch between the number of discrete action spaces expected by
BrainParameters
and the number in the ML-Agents model. Modifying the action space viaOnValidate
and rebuilding the model resolved the problem.