Skip to content

Sensor shapes must match. [20, 20, 1] != [23, 23, 8] . A problem with sensor initialization? #10

Description

@MarkTension

Hello, my gridsensor somehow doesn't initialize corerctly.

Sensor shapes must match. [20, 20, 1] != [23, 23, 8]
UnityEngine.Debug:AssertFormat (bool,string,object[])
Unity.MLAgents.Sensors.SensorShapeValidator:ValidateSensors (System.Collections.Generic.List`1<Unity.MLAgents.Sensors.ISensor>) (at Library/PackageCache/com.unity.ml-agents@2.1.0-exp.1/Runtime/Sensors/SensorShapeValidator.cs:43)
Unity.MLAgents.Inference.ModelRunner:PutObservations (Unity.MLAgents.AgentInfo,System.Collections.Generic.List`1<Unity.MLAgents.Sensors.ISensor>) (at Library/PackageCache/com.unity.ml-agents@2.1.0-exp.1/Runtime/Inference/ModelRunner.cs:160)
Unity.MLAgents.Policies.BarracudaPolicy:RequestDecision (Unity.MLAgents.AgentInfo,System.Collections.Generic.List`1<Unity.MLAgents.Sensors.ISensor>) (at Library/PackageCache/com.unity.ml-agents@2.1.0-exp.1/Runtime/Policies/BarracudaPolicy.cs:96)
Unity.MLAgents.Agent:SendInfoToBrain () (at Library/PackageCache/com.unity.ml-agents@2.1.0-exp.1/Runtime/Agent.cs:1096)
Unity.MLAgents.Agent:SendInfo () (at Library/PackageCache/com.unity.ml-agents@2.1.0-exp.1/Runtime/Agent.cs:1323)
Unity.MLAgents.Academy:EnvironmentStep () (at Library/PackageCache/com.unity.ml-agents@2.1.0-exp.1/Runtime/Academy.cs:573)
Environment:FixedUpdate () (at Assets/Assets_rl 1/scripts/Environment/Environment.cs:148

It says the sensor shapes don't match, but I do specify a colorgridbuffer with a shape (23, 23, 8) like so:

customGridSensor.cs

m_SensorBuffer = new ColorGridBuffer(8, 23, 23);
var sensorComp = GetComponent<MBaske.Sensors.Grid.GridSensorComponent>();
sensorComp.GridBuffer = m_SensorBuffer;

I'm not sure where 20,20,1 comes from. When I hard-code the GridSensorComponentBase script, where the (20,20,1) comes from, then it sometimes works. But other times it still gives the same error

GridSensorComponentBase .cs

[SerializeField, HideInInspector]
private GridBuffer.Shape m_GridShape = new GridBuffer.Shape(8, 23, 23);

When it works, all looks good in the debugging visualization. Is there a way to fix this, or did I forget anything? Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions