Search Unity

Question UnityObservationException: observation did not have the expected shape error

Discussion in 'ML-Agents' started by unity_DCD5DF81BF2BC6ADAB9B, Dec 18, 2023.

  1. unity_DCD5DF81BF2BC6ADAB9B

    unity_DCD5DF81BF2BC6ADAB9B

    Joined:
    Nov 4, 2021
    Posts:
    2
    Hi there!

    I'm new to Unity-ML and got some error while working with visual observation. I followed the instruction in the Unity ML-Agent toolkit documentation (link), but I got the following error message.
    mlagents_envs.exception.UnityObservationException: Decompressed observation did not have the expected shape - decompressed had (3, 46, 64) but expected [46, 64, 3]


    What I did was attach a camera sensor component, drag the camera I want to use and set the width and height of the visual observation (I attached an image of the camera sensor component). If I understand the instruction correctly, there is not much I need to do to add a visual observation for my agent. No need to code or modify the training config yaml file.

    Is there anything I'm missing or is this error a bug? If anyone could help me I would greatly appreciate it. I have been googling it for weeks but I found nothing.
     

    Attached Files:

  2. smallg2023

    smallg2023

    Joined:
    Sep 2, 2018
    Posts:
    144
    if your agent already has a brain attached it is expecting the observations in a different order, best to train a new one with the new camera sensor
     
  3. unity_DCD5DF81BF2BC6ADAB9B

    unity_DCD5DF81BF2BC6ADAB9B

    Joined:
    Nov 4, 2021
    Posts:
    2
    Thank you for your reply! I updated the ML-Agent package from version 2.0.1 to 3.0.0 and it solved the problem. The latest version cannot be installed from unity registry but has to be installed from github.