Search Unity

What is the order of observations?

Discussion in 'ML-Agents' started by ValBis, Oct 22, 2020.

  1. ValBis

    ValBis

    Joined:
    Jul 9, 2017
    Posts:
    50
    Hello,
    I have an agent with, let's say, 6 cameraSensorComponents, and 2 vector observations.
    When I get the DecisionStep in python, I noticed that these observations are returned scrambled up: I get 4 visual observations (from DS[0] to DS[3]), then 1 observation corresponding to vector obs. (DS[4]), and then all the remaining visual observations DS[5] and DS[6]).

    Why is that? Is it possible to specify an order in advance? Is the order always the same? (so that I can rearrange them in my pyhon code)?
     
  2. ValBis

    ValBis

    Joined:
    Jul 9, 2017
    Posts:
    50
    I will answer my own question since this may be important to other people.
    The observations are passed alphabetically. The vector observation should corresponds to the letter "V" (from vector, probably). Some of my camera's Sensor Name started with the letter T, other with Z, so the observation would be split accordingly.

    Also, thank you for this beautiful toolkit <3
     
    samarth-robo likes this.
  3. celion_unity

    celion_unity

    Joined:
    Jun 12, 2019
    Posts:
    289
    You're correct that they're sorted alphabetically by name. This is because they always need to be in the same order between training and inference, and on Agents of the same behavior name, and I couldn't find any guarantees on the ordering for GetComponents.

    The Agent's VectorSensor that it uses for CollectObservations is named $"VectorSensor_size{observationSize}".
     
    samarth-robo likes this.
  4. samarth-robo

    samarth-robo

    Joined:
    Aug 13, 2020
    Posts:
    4
    Thanks for this information. I noticed a small addition: the observations are first ordered by GameObject hierarchy, and then alphabetically if two sensors are siblings in the hierarchy.