Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Can BufferSensor take int arrays instead of float arrays as observations?

Discussion in 'ML-Agents' started by macsimilian, Aug 14, 2023.

  1. macsimilian

    macsimilian

    Joined:
    Sep 19, 2020
    Posts:
    19
    According to the documentation, Buffer Sensor takes float[] or Single[] as observations. Any way for it to take int[] instead?

    Looking at the source code, floats seem hardcoded into the BufferSensor. But it also looks like it could be easy to edit and make my own IntBufferSensor just by replacing "float" with "int" in a few places - would this work?

    I am doing this because my data is discrete and not continuous.

    Update: Changing BufferSensor to use ints wouldn't work as it goes even deeper, with ObservationWriter only dealing with floats as well. Do I have an incorrect assumption? Is using floats fine, even with discrete data values, since it is state-based and floats vs. ints doesn't matter?

    Update 2: Looking at the VectorSensor source, it looks like even then with its AddObservation(int) function, it immediately just implicitly converts it to a float. So I guess my current question is still whether I have an incorrect assumption. Is the learning state-based such that using integers vs. floating points is the same?
     
    Last edited: Aug 15, 2023
  2. Luke-Houlihan

    Luke-Houlihan

    Joined:
    Jun 26, 2007
    Posts:
    303
    Every number type you send to the network will be converted to a float no matter what type you sent it as, neural networks are made of and only work with floating point numbers.