Reinforcement Learning
ml-agents
TensorBoard
ONNX
Pyramids
deep-reinforcement-learning
ML-Agents-Pyramids
Instructions to use AnnaMats/ppo-Pyramids-Training with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- ml-agents
How to use AnnaMats/ppo-Pyramids-Training with ml-agents:
mlagents-load-from-hf --repo-id="AnnaMats/ppo-Pyramids-Training" --local-dir="./downloads"
- Notebooks
- Google Colab
- Kaggle
Download com.unity.ml-agents/Runtime/Sensors/Reflection/EnumReflectionSensor.cs from AnnaMats/ppo-Pyramids-Training: direct link, hf CLI and curl.
- Browser
- Download file 1.86 kB
-
https://huggingface.co/AnnaMats/ppo-Pyramids-Training/resolve/main/com.unity.ml-agents/Runtime/Sensors/Reflection/EnumReflectionSensor.cs
- Command line
-
hf download hf://AnnaMats/ppo-Pyramids-Training/com.unity.ml-agents/Runtime/Sensors/Reflection/EnumReflectionSensor.cs
-
curl -L -o EnumReflectionSensor.cs https://huggingface.co/AnnaMats/ppo-Pyramids-Training/resolve/main/com.unity.ml-agents/Runtime/Sensors/Reflection/EnumReflectionSensor.cs
1.86 kB
| using System; | |
| namespace Unity.MLAgents.Sensors.Reflection | |
| { | |
| internal class EnumReflectionSensor : ReflectionSensorBase | |
| { | |
| Array m_Values; | |
| bool m_IsFlags; | |
| internal EnumReflectionSensor(ReflectionSensorInfo reflectionSensorInfo) | |
| : base(reflectionSensorInfo, GetEnumObservationSize(reflectionSensorInfo.GetMemberType())) | |
| { | |
| var memberType = reflectionSensorInfo.GetMemberType(); | |
| m_Values = Enum.GetValues(memberType); | |
| m_IsFlags = memberType.IsDefined(typeof(FlagsAttribute), false); | |
| } | |
| internal override void WriteReflectedField(ObservationWriter writer) | |
| { | |
| // Write the enum value as a one-hot encoding. | |
| // Note that unknown enum values will record all 0's. | |
| // Flags will get treated as a sequence of bools. | |
| var enumValue = (Enum)GetReflectedValue(); | |
| int i = 0; | |
| foreach (var val in m_Values) | |
| { | |
| if (m_IsFlags) | |
| { | |
| if (enumValue.HasFlag((Enum)val)) | |
| { | |
| writer[i] = 1.0f; | |
| } | |
| else | |
| { | |
| writer[i] = 0.0f; | |
| } | |
| } | |
| else | |
| { | |
| if (val.Equals(enumValue)) | |
| { | |
| writer[i] = 1.0f; | |
| } | |
| else | |
| { | |
| writer[i] = 0.0f; | |
| } | |
| } | |
| i++; | |
| } | |
| } | |
| internal static int GetEnumObservationSize(Type t) | |
| { | |
| var values = Enum.GetValues(t); | |
| // Account for all enum values | |
| return values.Length; | |
| } | |
| } | |
| } | |