Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

Question Reading tfevents into Unity

Discussion in 'ML-Agents' started by joeyvdkaaij, Sep 6, 2023.

  1. joeyvdkaaij

    joeyvdkaaij

    Joined:
    May 11, 2020
    Posts:
    10
    I'm trying to read out the training data as it appears in the TensorBoard in Unity (Environment/Cumulative Reward, Policy/Learning Rate, etc). I figured out it's stored in the .tfevents file, which (correct me if I'm wrong) is encoded in the ProtoBuf format. I'm trying to read those Scalars into Unity after a RL training was concluded.

    I know that the ML-Agents package already includes ProtoBuf, but I wouldn't expect the .proto structure for the .fevents file to exist in Unity - so I guess I need to generate that to be able to Deserialize the fevents file. I looked into the protobuf-definitions/proto folder for a definition but I cannot find any that looks similar to how the file is stored.

    This is where I'm stuck now. I'm not sure if this is the right path - and if so, I'm not sure how to deserialize the .fevents file so it can be read into Unity. I have no experience with ProtoBuf, so that also doesn't help.
     
  2. joeyvdkaaij

    joeyvdkaaij

    Joined:
    May 11, 2020
    Posts:
    10
    I found it's a lot easier to read this from Python with the tensor package:

    Code (CSharp):
    1. import tensorflow as tf
    2.  
    3. def main():
    4.     for summary in tf.compat.v1.train.summary_iterator(path):
    5.         print(summary)
    6.  
    7. if __name__ == '__main__':
    8.     main()
    9.