Skip to content

Commit 258f4dc

Browse files
author
Chris Elion
authored
In-Editor Analytics for inference (#4677)
1 parent 91af77a commit 258f4dc

File tree

14 files changed

+486
-4
lines changed

14 files changed

+486
-4
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,12 @@ minutes to
161161
For any other questions or feedback, connect directly with the ML-Agents team at
162162
163163

164+
## Privacy
165+
166+
In order to improve the developer experience for Unity ML-Agents Toolkit, we have added in-editor analytics.
167+
Please refer to "Information that is passively collected by Unity" in the
168+
[Unity Privacy Policy](https://unity3d.com/legal/privacy-policy).
169+
164170
## License
165171

166172
[Apache License 2.0](LICENSE)

com.unity.ml-agents/CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,12 @@ and this project adheres to
1717
#### com.unity.ml-agents / com.unity.ml-agents.extensions (C#)
1818
- Agents with both continuous and discrete actions are now supported. You can specify
1919
both continuous and discrete action sizes in Behavior Parameters. (#4702, #4718)
20+
- In order to improve the developer experience for Unity ML-Agents Toolkit, we have added in-editor analytics.
21+
Please refer to "Information that is passively collected by Unity" in the
22+
[Unity Privacy Policy](https://unity3d.com/legal/privacy-policy). (#4677)
23+
2024
#### ml-agents / ml-agents-envs / gym-unity (Python)
21-
- `ActionSpec.validate_action()` now enforces that `UnityEnvironment.set_action_for_agent()` receives a 1D `np.array`.
25+
- `ActionSpec.validate_action()` now enforces that `UnityEnvironment.set_action_for_agent()` receives a 1D `np.array`. (#4691)
2226

2327
### Bug Fixes
2428
#### com.unity.ml-agents (C#)

com.unity.ml-agents/Documentation~/com.unity.ml-agents.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ If you are new to the Unity ML-Agents package, or have a question after reading
111111
the documentation, you can checkout our [GitHub Repository], which also includes
112112
a number of ways to [connect with us] including our [ML-Agents Forum].
113113

114+
In order to improve the developer experience for Unity ML-Agents Toolkit, we have added in-editor analytics.
115+
Please refer to "Information that is passively collected by Unity" in the
116+
[Unity Privacy Policy](https://unity3d.com/legal/privacy-policy).
117+
114118
[unity ML-Agents Toolkit]: https://github.com/Unity-Technologies/ml-agents
115119
[unity inference engine]: https://docs.unity3d.com/Packages/com.unity.barracuda@latest/index.html
116120
[package manager documentation]: https://docs.unity3d.com/Manual/upm-ui-install.html

com.unity.ml-agents/Runtime/Analytics.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using Unity.MLAgents.Actuators;
4+
using Unity.MLAgents.Sensors;
5+
6+
namespace Unity.MLAgents.Analytics
7+
{
8+
internal struct InferenceEvent
9+
{
10+
/// <summary>
11+
/// Hash of the BehaviorName.
12+
/// </summary>
13+
public string BehaviorName;
14+
public string BarracudaModelSource;
15+
public string BarracudaModelVersion;
16+
public string BarracudaModelProducer;
17+
public string BarracudaPackageVersion;
18+
/// <summary>
19+
/// Whether inference is performed on CPU (0) or GPU (1).
20+
/// </summary>
21+
public int InferenceDevice;
22+
public List<EventObservationSpec> ObservationSpecs;
23+
public EventActionSpec ActionSpec;
24+
public int MemorySize;
25+
public long TotalWeightSizeBytes;
26+
public string ModelHash;
27+
}
28+
29+
/// <summary>
30+
/// Simplified version of ActionSpec struct for use in analytics
31+
/// </summary>
32+
[Serializable]
33+
internal struct EventActionSpec
34+
{
35+
public int NumContinuousActions;
36+
public int NumDiscreteActions;
37+
public int[] BranchSizes;
38+
39+
public static EventActionSpec FromActionSpec(ActionSpec actionSpec)
40+
{
41+
var branchSizes = actionSpec.BranchSizes ?? Array.Empty<int>();
42+
return new EventActionSpec
43+
{
44+
NumContinuousActions = actionSpec.NumContinuousActions,
45+
NumDiscreteActions = actionSpec.NumDiscreteActions,
46+
BranchSizes = branchSizes,
47+
};
48+
}
49+
}
50+
51+
/// <summary>
52+
/// Information about one dimension of an observation.
53+
/// </summary>
54+
[Serializable]
55+
internal struct EventObservationDimensionInfo
56+
{
57+
public int Size;
58+
public int Flags;
59+
}
60+
61+
/// <summary>
62+
/// Simplified summary of Agent observations for use in analytics
63+
/// </summary>
64+
[Serializable]
65+
internal struct EventObservationSpec
66+
{
67+
public string SensorName;
68+
public string CompressionType;
69+
public EventObservationDimensionInfo[] DimensionInfos;
70+
71+
public static EventObservationSpec FromSensor(ISensor sensor)
72+
{
73+
var shape = sensor.GetObservationShape();
74+
var dimInfos = new EventObservationDimensionInfo[shape.Length];
75+
for (var i = 0; i < shape.Length; i++)
76+
{
77+
dimInfos[i].Size = shape[i];
78+
// TODO copy flags when we have them
79+
}
80+
81+
return new EventObservationSpec
82+
{
83+
SensorName = sensor.GetName(),
84+
CompressionType = sensor.GetCompressionType().ToString(),
85+
DimensionInfos = dimInfos,
86+
};
87+
}
88+
}
89+
}

com.unity.ml-agents/Runtime/Analytics/Events.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)