浏览代码

Merge pull request #1764 from Unity-Technologies/release-v0.7

Release v0.7 into master
/hotfix-v0.9.2a
GitHub 6 年前
当前提交
275ff5d6
共有 253 个文件被更改,包括 3123 次插入706 次删除
  1. 2
      UnitySDK/Assets/ML-Agents/Editor/AgentEditor.cs
  2. 3
      UnitySDK/Assets/ML-Agents/Editor/LearningBrainEditor.cs
  3. 5
      UnitySDK/Assets/ML-Agents/Editor/Tests/EditModeTestInternalBrainTensorGenerator.cs
  4. 2
      UnitySDK/Assets/ML-Agents/Examples/3DBall/Brains/3DBallHardLearning.asset
  5. 2
      UnitySDK/Assets/ML-Agents/Examples/3DBall/Brains/3DBallLearning.asset
  6. 2
      UnitySDK/Assets/ML-Agents/Examples/3DBall/Prefabs/Game.prefab
  7. 2
      UnitySDK/Assets/ML-Agents/Examples/3DBall/Prefabs/GameHard.prefab
  8. 2
      UnitySDK/Assets/ML-Agents/Examples/BananaCollectors/Brains/BananaLearning.asset
  9. 10
      UnitySDK/Assets/ML-Agents/Examples/BananaCollectors/Prefabs/RLArea.prefab
  10. 3
      UnitySDK/Assets/ML-Agents/Examples/Basic/Brains/BasicLearning.asset
  11. 2
      UnitySDK/Assets/ML-Agents/Examples/Basic/Prefabs/Basic.prefab
  12. 2
      UnitySDK/Assets/ML-Agents/Examples/Bouncer/Brains/BouncerLearning.asset
  13. 2
      UnitySDK/Assets/ML-Agents/Examples/Bouncer/Prefabs/Environment.prefab
  14. 40
      UnitySDK/Assets/ML-Agents/Examples/Bouncer/Scenes/Bouncer.unity
  15. 2
      UnitySDK/Assets/ML-Agents/Examples/Crawler/Brains/CrawlerDynamicLearning.asset
  16. 2
      UnitySDK/Assets/ML-Agents/Examples/Crawler/Brains/CrawlerStaticLearning.asset
  17. 2
      UnitySDK/Assets/ML-Agents/Examples/GridWorld/Brains/GridWorldLearning.asset
  18. 9
      UnitySDK/Assets/ML-Agents/Examples/GridWorld/Resources/agent.prefab
  19. 13
      UnitySDK/Assets/ML-Agents/Examples/GridWorld/Scenes/GridWorld.unity
  20. 2
      UnitySDK/Assets/ML-Agents/Examples/Hallway/Brains/HallwayLearning.asset
  21. 2
      UnitySDK/Assets/ML-Agents/Examples/Hallway/Prefabs/HallwayArea.prefab
  22. 2
      UnitySDK/Assets/ML-Agents/Examples/PushBlock/Brains/PushBlockLearning.asset
  23. 2
      UnitySDK/Assets/ML-Agents/Examples/PushBlock/Prefabs/PushBlockArea.prefab
  24. 2
      UnitySDK/Assets/ML-Agents/Examples/Pyramids/Brains/PyramidsLearning.asset
  25. 2
      UnitySDK/Assets/ML-Agents/Examples/Pyramids/Prefabs/AreaPB.prefab
  26. 2
      UnitySDK/Assets/ML-Agents/Examples/Reacher/Brains/ReacherLearning.asset
  27. 2
      UnitySDK/Assets/ML-Agents/Examples/Soccer/Brains/GoalieLearning.asset
  28. 2
      UnitySDK/Assets/ML-Agents/Examples/Soccer/Brains/StrikerLearning.asset
  29. 8
      UnitySDK/Assets/ML-Agents/Examples/Soccer/Prefabs/SoccerFieldTwos.prefab
  30. 124
      UnitySDK/Assets/ML-Agents/Examples/Template/Scene.unity
  31. 3
      UnitySDK/Assets/ML-Agents/Examples/Tennis/Brains/TennisLearning.asset
  32. 4
      UnitySDK/Assets/ML-Agents/Examples/Tennis/Prefabs/TennisArea.prefab
  33. 2
      UnitySDK/Assets/ML-Agents/Examples/Tennis/Scripts/TennisAgent.cs
  34. 2
      UnitySDK/Assets/ML-Agents/Examples/Walker/Brains/WalkerLearning.asset
  35. 2
      UnitySDK/Assets/ML-Agents/Examples/WallJump/Brains/BigWallJumpLearning.asset
  36. 2
      UnitySDK/Assets/ML-Agents/Examples/WallJump/Brains/SmallWallJumpLearning.asset
  37. 80
      UnitySDK/Assets/ML-Agents/Plugins/ProtoBuffer/Grpc.Core.dll.meta
  38. 28
      UnitySDK/Assets/ML-Agents/Scripts/Academy.cs
  39. 21
      UnitySDK/Assets/ML-Agents/Scripts/Agent.cs
  40. 6
      UnitySDK/Assets/ML-Agents/Scripts/CommunicatorObjects/UnityToExternalGrpc.cs
  41. 40
      UnitySDK/Assets/ML-Agents/Scripts/InferenceBrain/ApplierImpl.cs
  42. 61
      UnitySDK/Assets/ML-Agents/Scripts/InferenceBrain/GeneratorImpl.cs
  43. 2
      UnitySDK/Assets/ML-Agents/Scripts/InferenceBrain/ModelParamLoader.cs
  44. 3
      UnitySDK/Assets/ML-Agents/Scripts/InferenceBrain/TensorApplier.cs
  45. 4
      UnitySDK/Assets/ML-Agents/Scripts/InferenceBrain/TensorGenerator.cs
  46. 4
      UnitySDK/Assets/ML-Agents/Scripts/InferenceBrain/TensorNames.cs
  47. 124
      UnitySDK/Assets/ML-Agents/Scripts/LearningBrain.cs
  48. 20
      UnitySDK/Assets/ML-Agents/Scripts/RpcCommunicator.cs
  49. 1
      UnitySDK/Assets/ML-Agents/Scripts/SocketCommunicator.cs
  50. 6
      UnitySDK/ProjectSettings/ProjectSettings.asset
  51. 6
      docs/API-Reference.md
  52. 19
      docs/Background-TensorFlow.md
  53. 50
      docs/Basic-Guide.md
  54. 4
      docs/FAQ.md
  55. 16
      docs/Getting-Started-with-Balance-Ball.md
  56. 18
      docs/Installation-Windows.md
  57. 45
      docs/Learning-Environment-Create-New.md
  58. 4
      docs/Learning-Environment-Design-Academy.md
  59. 41
      docs/Learning-Environment-Design-Agents.md
  60. 10
      docs/Learning-Environment-Design-Learning-Brains.md
  61. 15
      docs/Learning-Environment-Design.md
  62. 4
      docs/Learning-Environment-Executable.md
  63. 4
      docs/ML-Agents-Overview.md
  64. 5
      docs/Readme.md
  65. 4
      docs/Training-Imitation-Learning.md
  66. 2
      docs/Training-ML-Agents.md
  67. 4
      docs/Training-on-Amazon-Web-Service.md
  68. 4
      docs/Training-on-Microsoft-Azure.md
  69. 2
      docs/Using-Docker.md
  70. 220
      gym-unity/README.md
  71. 84
      gym-unity/gym_unity/envs/unity_env.py
  72. 2
      gym-unity/setup.py
  73. 100
      gym-unity/tests/test_gym.py
  74. 2
      ml-agents/mlagents/envs/environment.py
  75. 3
      ml-agents/mlagents/envs/rpc_communicator.py
  76. 3
      ml-agents/mlagents/envs/socket_communicator.py
  77. 144
      ml-agents/mlagents/trainers/learn.py
  78. 2
      ml-agents/mlagents/trainers/models.py
  79. 12
      ml-agents/mlagents/trainers/policy.py
  80. 317
      ml-agents/mlagents/trainers/trainer_controller.py
  81. 5
      ml-agents/setup.py
  82. 2
      ml-agents/tests/mock_communicator.py
  83. 4
      ml-agents/tests/trainers/test_bc.py
  84. 4
      ml-agents/tests/trainers/test_ppo.py
  85. 358
      ml-agents/tests/trainers/test_trainer_controller.py
  86. 12
      protobuf-definitions/README.md
  87. 29
      UnitySDK/Assets/ML-Agents/Editor/NNModelImporter.cs
  88. 11
      UnitySDK/Assets/ML-Agents/Editor/NNModelImporter.cs.meta
  89. 11
      UnitySDK/Assets/ML-Agents/Editor/Tests/MultinomialTest.cs.meta
  90. 11
      UnitySDK/Assets/ML-Agents/Editor/Tests/RandomNormalTest.cs.meta
  91. 556
      UnitySDK/Assets/ML-Agents/Examples/3DBall/TFModels/3DBallHardLearning.nn
  92. 7
      UnitySDK/Assets/ML-Agents/Examples/3DBall/TFModels/3DBallHardLearning.nn.meta
  93. 511
      UnitySDK/Assets/ML-Agents/Examples/3DBall/TFModels/3DBallLearning.nn
  94. 7
      UnitySDK/Assets/ML-Agents/Examples/3DBall/TFModels/3DBallLearning.nn.meta
  95. 307
      UnitySDK/Assets/ML-Agents/Examples/BananaCollectors/TFModels/BananaLearning.nn
  96. 7
      UnitySDK/Assets/ML-Agents/Examples/BananaCollectors/TFModels/BananaLearning.nn.meta
  97. 12
      UnitySDK/Assets/ML-Agents/Examples/Basic/TFModels/BasicLearning.nn
  98. 7
      UnitySDK/Assets/ML-Agents/Examples/Basic/TFModels/BasicLearning.nn.meta
  99. 143
      UnitySDK/Assets/ML-Agents/Examples/Bouncer/TFModels/BouncerLearning.nn
  100. 7
      UnitySDK/Assets/ML-Agents/Examples/Bouncer/TFModels/BouncerLearning.nn.meta

2
UnitySDK/Assets/ML-Agents/Editor/AgentEditor.cs


EditorGUILayout.PropertyField(
actionsPerDecision,
new GUIContent(
"Decision Frequency",
"Decision Interval",
"The agent will automatically request a decision every X" +
" steps and perform an action at every step."));
actionsPerDecision.intValue = Mathf.Max(1, actionsPerDecision.intValue);

3
UnitySDK/Assets/ML-Agents/Editor/LearningBrainEditor.cs


public class LearningBrainEditor : BrainEditor
{
private const string ModelPropName = "model";
private const string InferenceDevicePropName = "inferenceDevice";
private const float TimeBetweenModelReloads = 2f;
// Time since the last reload of the model
private float _timeSinceModelReload;

serializedBrain.Update();
var tfGraphModel = serializedBrain.FindProperty(ModelPropName);
EditorGUILayout.ObjectField(tfGraphModel);
var inferenceDevice = serializedBrain.FindProperty(InferenceDevicePropName);
EditorGUILayout.PropertyField(inferenceDevice);
serializedBrain.ApplyModifiedProperties();
if (EditorGUI.EndChangeCheck())
{

5
UnitySDK/Assets/ML-Agents/Editor/Tests/EditModeTestInternalBrainTensorGenerator.cs


var inputTensor = new Tensor()
{
Shape = new long[] {2, 2},
ValueType = Tensor.TensorType.FloatingPoint
ValueType = Tensor.TensorType.Integer
};
var batchSize = 4;

Assert.Catch<NotImplementedException>(
() => generator.Generate(inputTensor, batchSize, agentInfos));
inputTensor.ValueType = Tensor.TensorType.Integer;
generator.Generate(inputTensor, batchSize, agentInfos);
Assert.IsNotNull(inputTensor.Data as int[,]);
Assert.AreEqual((inputTensor.Data as int[,])[0, 0], 1);

2
UnitySDK/Assets/ML-Agents/Examples/3DBall/Brains/3DBallHardLearning.asset


-
-
vectorActionSpaceType: 1
model: {fileID: 4900000, guid: 8a2da2218425f46e9921caefda4b7813, type: 3}
model: {fileID: 11400000, guid: 8be33caeca04d43498913448b5364f2b, type: 3}

2
UnitySDK/Assets/ML-Agents/Examples/3DBall/Brains/3DBallLearning.asset


-
-
vectorActionSpaceType: 1
model: {fileID: 4900000, guid: 9f58800fa9d54477aa01ee258842f6b3, type: 3}
model: {fileID: 11400000, guid: c282d4bbc4c8f4e78b2bb29eccd17557, type: 3}

2
UnitySDK/Assets/ML-Agents/Examples/3DBall/Prefabs/Game.prefab


m_Script: {fileID: 11500000, guid: aaba48bf82bee4751aa7b89569e57f73, type: 3}
m_Name:
m_EditorClassIdentifier:
brain: {fileID: 11400000, guid: 97d8f9d40dc8c452f932f7caa9549c7d, type: 2}
brain: {fileID: 11400000, guid: 383c589e8bb76464eadc2525b5b0f2c1, type: 2}
agentParameters:
agentCameras: []
maxStep: 5000

2
UnitySDK/Assets/ML-Agents/Examples/3DBall/Prefabs/GameHard.prefab


m_Script: {fileID: 11500000, guid: edf26e11cf4ed42eaa3ffb7b91bb4676, type: 3}
m_Name:
m_EditorClassIdentifier:
brain: {fileID: 11400000, guid: 55f48be32ac184c6ab67cf647100bac4, type: 2}
brain: {fileID: 11400000, guid: 4f74e089fbb75455ebf6f0495e30be6e, type: 2}
agentParameters:
agentCameras: []
maxStep: 5000

2
UnitySDK/Assets/ML-Agents/Examples/BananaCollectors/Brains/BananaLearning.asset


-
-
vectorActionSpaceType: 0
model: {fileID: 4900000, guid: 69bd818d72b944849916d2fda9fe471b, type: 3}
model: {fileID: 11400000, guid: 9aed85b22394844eaa6db4d5e3c61adb, type: 3}

10
UnitySDK/Assets/ML-Agents/Examples/BananaCollectors/Prefabs/RLArea.prefab


m_Script: {fileID: 11500000, guid: 700720465a0104fa586fa4a412b044f8, type: 3}
m_Name:
m_EditorClassIdentifier:
brain: {fileID: 11400000, guid: dff7429d656234fed84c4fac2a7a683c, type: 2}
brain: {fileID: 11400000, guid: 9e7865ec29c894c2d8c1617b0fa392f9, type: 2}
agentParameters:
agentCameras: []
maxStep: 5000

m_Script: {fileID: 11500000, guid: 700720465a0104fa586fa4a412b044f8, type: 3}
m_Name:
m_EditorClassIdentifier:
brain: {fileID: 11400000, guid: dff7429d656234fed84c4fac2a7a683c, type: 2}
brain: {fileID: 11400000, guid: 9e7865ec29c894c2d8c1617b0fa392f9, type: 2}
agentParameters:
agentCameras: []
maxStep: 5000

m_Script: {fileID: 11500000, guid: 700720465a0104fa586fa4a412b044f8, type: 3}
m_Name:
m_EditorClassIdentifier:
brain: {fileID: 11400000, guid: dff7429d656234fed84c4fac2a7a683c, type: 2}
brain: {fileID: 11400000, guid: 9e7865ec29c894c2d8c1617b0fa392f9, type: 2}
agentParameters:
agentCameras: []
maxStep: 5000

m_Script: {fileID: 11500000, guid: 700720465a0104fa586fa4a412b044f8, type: 3}
m_Name:
m_EditorClassIdentifier:
brain: {fileID: 11400000, guid: dff7429d656234fed84c4fac2a7a683c, type: 2}
brain: {fileID: 11400000, guid: 9e7865ec29c894c2d8c1617b0fa392f9, type: 2}
agentParameters:
agentCameras: []
maxStep: 5000

m_Script: {fileID: 11500000, guid: 700720465a0104fa586fa4a412b044f8, type: 3}
m_Name:
m_EditorClassIdentifier:
brain: {fileID: 11400000, guid: dff7429d656234fed84c4fac2a7a683c, type: 2}
brain: {fileID: 11400000, guid: 9e7865ec29c894c2d8c1617b0fa392f9, type: 2}
agentParameters:
agentCameras: []
maxStep: 5000

3
UnitySDK/Assets/ML-Agents/Examples/Basic/Brains/BasicLearning.asset


vectorActionDescriptions:
-
vectorActionSpaceType: 0
model: {fileID: 4900000, guid: 503ce1e8257904bd0b5be8f7fb4b5d28, type: 3}
model: {fileID: 11400000, guid: b9b3600e7ab99422684e1f3bf597a456, type: 3}
inferenceDevice: 0

2
UnitySDK/Assets/ML-Agents/Examples/Basic/Prefabs/Basic.prefab


m_Script: {fileID: 11500000, guid: 624480a72e46148118ab2e2d89b537de, type: 3}
m_Name:
m_EditorClassIdentifier:
brain: {fileID: 11400000, guid: 1adbe3db6a2f94bf2b1e22a29b955387, type: 2}
brain: {fileID: 11400000, guid: e5cf0e35e16264ea483f8863e5115c3c, type: 2}
agentParameters:
agentCameras: []
maxStep: 0

2
UnitySDK/Assets/ML-Agents/Examples/Bouncer/Brains/BouncerLearning.asset


-
-
vectorActionSpaceType: 1
model: {fileID: 4900000, guid: 760d2b8347b4b46e3a44d9b989e1304e, type: 3}
model: {fileID: 11400000, guid: 055df42a4cc114162939e523d053c4d7, type: 3}

2
UnitySDK/Assets/ML-Agents/Examples/Bouncer/Prefabs/Environment.prefab


m_Script: {fileID: 11500000, guid: 0f09741cbce2e44bc88d3e92917eea0e, type: 3}
m_Name:
m_EditorClassIdentifier:
brain: {fileID: 11400000, guid: 5527511df7b944e8e9177dd69db5a9c1, type: 2}
brain: {fileID: 11400000, guid: 573920e3a672d40038169c7ffdbdca05, type: 2}
agentParameters:
agentCameras: []
maxStep: 0

40
UnitySDK/Assets/ML-Agents/Examples/Bouncer/Scenes/Bouncer.unity


m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.4482636, g: 0.49828887, b: 0.5755903, a: 1}
m_IndirectSpecularColor: {r: 0.44824862, g: 0.49827534, b: 0.57558274, a: 1}
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0

objectReference: {fileID: 0}
- target: {fileID: 1397068878990112, guid: e2c4e1ad4f2224d34bb09d20f26b3207, type: 2}
propertyPath: m_IsActive
value: 0
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: e2c4e1ad4f2224d34bb09d20f26b3207, type: 2}

objectReference: {fileID: 0}
- target: {fileID: 1397068878990112, guid: e2c4e1ad4f2224d34bb09d20f26b3207, type: 2}
propertyPath: m_IsActive
value: 0
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: e2c4e1ad4f2224d34bb09d20f26b3207, type: 2}

objectReference: {fileID: 0}
- target: {fileID: 1397068878990112, guid: e2c4e1ad4f2224d34bb09d20f26b3207, type: 2}
propertyPath: m_IsActive
value: 0
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: e2c4e1ad4f2224d34bb09d20f26b3207, type: 2}

objectReference: {fileID: 0}
- target: {fileID: 1397068878990112, guid: e2c4e1ad4f2224d34bb09d20f26b3207, type: 2}
propertyPath: m_IsActive
value: 0
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: e2c4e1ad4f2224d34bb09d20f26b3207, type: 2}

objectReference: {fileID: 0}
- target: {fileID: 1397068878990112, guid: e2c4e1ad4f2224d34bb09d20f26b3207, type: 2}
propertyPath: m_IsActive
value: 0
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: e2c4e1ad4f2224d34bb09d20f26b3207, type: 2}

objectReference: {fileID: 0}
- target: {fileID: 1397068878990112, guid: e2c4e1ad4f2224d34bb09d20f26b3207, type: 2}
propertyPath: m_IsActive
value: 0
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: e2c4e1ad4f2224d34bb09d20f26b3207, type: 2}

objectReference: {fileID: 0}
- target: {fileID: 1397068878990112, guid: e2c4e1ad4f2224d34bb09d20f26b3207, type: 2}
propertyPath: m_IsActive
value: 0
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: e2c4e1ad4f2224d34bb09d20f26b3207, type: 2}

objectReference: {fileID: 0}
- target: {fileID: 1397068878990112, guid: e2c4e1ad4f2224d34bb09d20f26b3207, type: 2}
propertyPath: m_IsActive
value: 0
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: e2c4e1ad4f2224d34bb09d20f26b3207, type: 2}

objectReference: {fileID: 0}
- target: {fileID: 1397068878990112, guid: e2c4e1ad4f2224d34bb09d20f26b3207, type: 2}
propertyPath: m_IsActive
value: 0
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: e2c4e1ad4f2224d34bb09d20f26b3207, type: 2}

objectReference: {fileID: 0}
- target: {fileID: 1397068878990112, guid: e2c4e1ad4f2224d34bb09d20f26b3207, type: 2}
propertyPath: m_IsActive
value: 0
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: e2c4e1ad4f2224d34bb09d20f26b3207, type: 2}

objectReference: {fileID: 0}
- target: {fileID: 1397068878990112, guid: e2c4e1ad4f2224d34bb09d20f26b3207, type: 2}
propertyPath: m_IsActive
value: 0
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: e2c4e1ad4f2224d34bb09d20f26b3207, type: 2}

objectReference: {fileID: 0}
- target: {fileID: 1397068878990112, guid: e2c4e1ad4f2224d34bb09d20f26b3207, type: 2}
propertyPath: m_IsActive
value: 0
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: e2c4e1ad4f2224d34bb09d20f26b3207, type: 2}

objectReference: {fileID: 0}
- target: {fileID: 1397068878990112, guid: e2c4e1ad4f2224d34bb09d20f26b3207, type: 2}
propertyPath: m_IsActive
value: 0
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: e2c4e1ad4f2224d34bb09d20f26b3207, type: 2}

objectReference: {fileID: 0}
- target: {fileID: 1397068878990112, guid: e2c4e1ad4f2224d34bb09d20f26b3207, type: 2}
propertyPath: m_IsActive
value: 0
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: e2c4e1ad4f2224d34bb09d20f26b3207, type: 2}

objectReference: {fileID: 0}
- target: {fileID: 1397068878990112, guid: e2c4e1ad4f2224d34bb09d20f26b3207, type: 2}
propertyPath: m_IsActive
value: 0
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: e2c4e1ad4f2224d34bb09d20f26b3207, type: 2}

objectReference: {fileID: 0}
- target: {fileID: 1397068878990112, guid: e2c4e1ad4f2224d34bb09d20f26b3207, type: 2}
propertyPath: m_IsActive
value: 0
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: e2c4e1ad4f2224d34bb09d20f26b3207, type: 2}

objectReference: {fileID: 0}
- target: {fileID: 1397068878990112, guid: e2c4e1ad4f2224d34bb09d20f26b3207, type: 2}
propertyPath: m_IsActive
value: 0
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: e2c4e1ad4f2224d34bb09d20f26b3207, type: 2}

objectReference: {fileID: 0}
- target: {fileID: 1397068878990112, guid: e2c4e1ad4f2224d34bb09d20f26b3207, type: 2}
propertyPath: m_IsActive
value: 0
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: e2c4e1ad4f2224d34bb09d20f26b3207, type: 2}

objectReference: {fileID: 0}
- target: {fileID: 1397068878990112, guid: e2c4e1ad4f2224d34bb09d20f26b3207, type: 2}
propertyPath: m_IsActive
value: 0
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: e2c4e1ad4f2224d34bb09d20f26b3207, type: 2}

2
UnitySDK/Assets/ML-Agents/Examples/Crawler/Brains/CrawlerDynamicLearning.asset


-
-
vectorActionSpaceType: 1
model: {fileID: 4900000, guid: 9482a8782450a4d87b20942c4523176b, type: 3}
model: {fileID: 11400000, guid: 94d1889cee00f4361b74cbc4eb129f11, type: 3}

2
UnitySDK/Assets/ML-Agents/Examples/Crawler/Brains/CrawlerStaticLearning.asset


-
-
vectorActionSpaceType: 1
model: {fileID: 4900000, guid: e256bd37f98f246e5be72618766d0a93, type: 3}
model: {fileID: 11400000, guid: 9dbf8cc316ac9410b961ed268824778f, type: 3}

2
UnitySDK/Assets/ML-Agents/Examples/GridWorld/Brains/GridWorldLearning.asset


vectorActionDescriptions:
-
vectorActionSpaceType: 0
model: {fileID: 4900000, guid: 0fd168a0ea1d04ef9a68c80cf452ce3d, type: 3}
model: {fileID: 11400000, guid: 86e6c88c11c2a4a72bbe56a71c20bfff, type: 3}

9
UnitySDK/Assets/ML-Agents/Examples/GridWorld/Resources/agent.prefab


m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 4294967295
m_Materials:
- {fileID: 2100000, guid: 00d852aac9443402984416f9dbcd22ea, type: 2}
m_StaticBatchInfo:

m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 4294967295
m_Materials:
- {fileID: 2100000, guid: 00d852aac9443402984416f9dbcd22ea, type: 2}
m_StaticBatchInfo:

m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 4294967295
m_Materials:
- {fileID: 2100000, guid: 00d852aac9443402984416f9dbcd22ea, type: 2}
m_StaticBatchInfo:

m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 4294967295
m_Materials:
- {fileID: 2100000, guid: 00d852aac9443402984416f9dbcd22ea, type: 2}
m_StaticBatchInfo:

m_Script: {fileID: 11500000, guid: 857707f3f352541d5b858efca4479b95, type: 3}
m_Name:
m_EditorClassIdentifier:
brain: {fileID: 0}
brain: {fileID: 11400000, guid: 2c1d51b7167874f31beda0b0cf0af468, type: 2}
agentParameters:
agentCameras:
- {fileID: 0}

numberOfActionsBetweenDecisions: 1
timeBetweenDecisionsAtInference: 0
timeBetweenDecisionsAtInference: 0.15
maskActions: 1

13
UnitySDK/Assets/ML-Agents/Examples/GridWorld/Scenes/GridWorld.unity


m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.43668893, g: 0.4842832, b: 0.56452656, a: 1}
m_IndirectSpecularColor: {r: 0.43667555, g: 0.4842717, b: 0.56452394, a: 1}
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0

objectReference: {fileID: 0}
- target: {fileID: 114143683117020968, guid: 628960e910f094ad1909ecc88cc8016d,
type: 2}
propertyPath: brain
value:
objectReference: {fileID: 11400000, guid: 8096722eb0a294871857e202e0032082,
type: 2}
- target: {fileID: 114143683117020968, guid: 628960e910f094ad1909ecc88cc8016d,
type: 2}
- target: {fileID: 114143683117020968, guid: 628960e910f094ad1909ecc88cc8016d,
type: 2}
propertyPath: timeBetweenDecisionsAtInference
value: 0.15
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: 628960e910f094ad1909ecc88cc8016d, type: 2}
m_IsPrefabParent: 0

2
UnitySDK/Assets/ML-Agents/Examples/Hallway/Brains/HallwayLearning.asset


vectorActionDescriptions:
-
vectorActionSpaceType: 0
model: {fileID: 4900000, guid: 84588668e6ea948d3ab55bb813cc769b, type: 3}
model: {fileID: 11400000, guid: 184185c35f3b14a56946e95977be2904, type: 3}

2
UnitySDK/Assets/ML-Agents/Examples/Hallway/Prefabs/HallwayArea.prefab


m_Script: {fileID: 11500000, guid: b446afae240924105b36d07e8d17a608, type: 3}
m_Name:
m_EditorClassIdentifier:
brain: {fileID: 11400000, guid: 51f870f0190b643adae5432c0e6205e7, type: 2}
brain: {fileID: 11400000, guid: 533f2edd327794ca996d0320901b501c, type: 2}
agentParameters:
agentCameras: []
maxStep: 3000

2
UnitySDK/Assets/ML-Agents/Examples/PushBlock/Brains/PushBlockLearning.asset


vectorActionDescriptions:
-
vectorActionSpaceType: 0
model: {fileID: 4900000, guid: e22850d2072904a0ab06069cda2599e5, type: 3}
model: {fileID: 11400000, guid: 16027726448534f92916ae237e0ba315, type: 3}

2
UnitySDK/Assets/ML-Agents/Examples/PushBlock/Prefabs/PushBlockArea.prefab


m_Script: {fileID: 11500000, guid: dea8c4f2604b947e6b7b97750dde87ca, type: 3}
m_Name:
m_EditorClassIdentifier:
brain: {fileID: 11400000, guid: dd07b1953eac4411b81fba032f394726, type: 2}
brain: {fileID: 11400000, guid: e8b2d719f6a324b1abb68d8cf2859f5c, type: 2}
agentParameters:
agentCameras: []
maxStep: 5000

2
UnitySDK/Assets/ML-Agents/Examples/Pyramids/Brains/PyramidsLearning.asset


vectorActionDescriptions:
-
vectorActionSpaceType: 0
model: {fileID: 4900000, guid: 7d1c7f27447234c3a81169de00dcaa8a, type: 3}
model: {fileID: 11400000, guid: 38874f53f06bd4f7782bc81d917a0442, type: 3}

2
UnitySDK/Assets/ML-Agents/Examples/Pyramids/Prefabs/AreaPB.prefab


m_Script: {fileID: 11500000, guid: b8db44472779248d3be46895c4d562d5, type: 3}
m_Name:
m_EditorClassIdentifier:
brain: {fileID: 11400000, guid: d60466fdbfb194c56bdaf78887f2afc8, type: 2}
brain: {fileID: 11400000, guid: 7b7715ed1d436417db67026a47f17576, type: 2}
agentParameters:
agentCameras: []
maxStep: 5000

2
UnitySDK/Assets/ML-Agents/Examples/Reacher/Brains/ReacherLearning.asset


-
-
vectorActionSpaceType: 1
model: {fileID: 4900000, guid: 5fb4a3624e9ca4e1c81b51b5117cb31e, type: 3}
model: {fileID: 11400000, guid: 0c779bd93060f405cbe4446e1dcbf2a6, type: 3}

2
UnitySDK/Assets/ML-Agents/Examples/Soccer/Brains/GoalieLearning.asset


vectorActionDescriptions:
-
vectorActionSpaceType: 0
model: {fileID: 4900000, guid: 890ab8f03425c4a80a52ba674ddec3f3, type: 3}
model: {fileID: 11400000, guid: b6dd703e0bf914268a4e110ad85ab7a9, type: 3}

2
UnitySDK/Assets/ML-Agents/Examples/Soccer/Brains/StrikerLearning.asset


vectorActionDescriptions:
-
vectorActionSpaceType: 0
model: {fileID: 4900000, guid: 23410257d39d44616bfefdff59c7fbc9, type: 3}
model: {fileID: 11400000, guid: 0df960ed78a964cd4a671395390ac522, type: 3}

8
UnitySDK/Assets/ML-Agents/Examples/Soccer/Prefabs/SoccerFieldTwos.prefab


m_Script: {fileID: 11500000, guid: 2a2688ef4a36349f9aa010020c32d198, type: 3}
m_Name:
m_EditorClassIdentifier:
brain: {fileID: 11400000, guid: b7b6884feff2f4a17a645d7e0b9dc8f3, type: 2}
brain: {fileID: 11400000, guid: 090fa5a8588f5433bb7f878e6f5ac954, type: 2}
agentParameters:
agentCameras: []
maxStep: 3000

m_Script: {fileID: 11500000, guid: 2a2688ef4a36349f9aa010020c32d198, type: 3}
m_Name:
m_EditorClassIdentifier:
brain: {fileID: 11400000, guid: 0e2b949bf7d37469786426a6d913f5af, type: 2}
brain: {fileID: 11400000, guid: 29ed78b3e8fef4340b3a1f6954b88f18, type: 2}
agentParameters:
agentCameras: []
maxStep: 3000

m_Script: {fileID: 11500000, guid: 2a2688ef4a36349f9aa010020c32d198, type: 3}
m_Name:
m_EditorClassIdentifier:
brain: {fileID: 11400000, guid: b7b6884feff2f4a17a645d7e0b9dc8f3, type: 2}
brain: {fileID: 11400000, guid: 090fa5a8588f5433bb7f878e6f5ac954, type: 2}
agentParameters:
agentCameras: []
maxStep: 3000

m_Script: {fileID: 11500000, guid: 2a2688ef4a36349f9aa010020c32d198, type: 3}
m_Name:
m_EditorClassIdentifier:
brain: {fileID: 11400000, guid: 0e2b949bf7d37469786426a6d913f5af, type: 2}
brain: {fileID: 11400000, guid: 29ed78b3e8fef4340b3a1f6954b88f18, type: 2}
agentParameters:
agentCameras: []
maxStep: 3000

124
UnitySDK/Assets/ML-Agents/Examples/Template/Scene.unity


m_PVRDirectSampleCount: 32
m_PVRSampleCount: 500
m_PVRBounces: 2
m_PVRFiltering: 0
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVRFilteringAtrousColorSigma: 1
m_PVRFilteringAtrousNormalSigma: 1
m_PVRFilteringAtrousPositionSigma: 1
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_ShowResolutionOverlay: 1
m_LightingDataAsset: {fileID: 0}
m_UseShadowmask: 1
--- !u!196 &4

manualTileSize: 0
tileSize: 256
accuratePlacement: 0
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &762086410
GameObject:

m_Lightmapping: 4
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_FalloffTable:
m_Table[0]: 0
m_Table[1]: 0
m_Table[2]: 0
m_Table[3]: 0
m_Table[4]: 0
m_Table[5]: 0
m_Table[6]: 0
m_Table[7]: 0
m_Table[8]: 0
m_Table[9]: 0
m_Table[10]: 0
m_Table[11]: 0
m_Table[12]: 0
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_ShadowRadius: 0

m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!1 &846768603
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 846768604}
- component: {fileID: 846768605}
m_Layer: 0
m_Name: Brain
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &846768604
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 846768603}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1574236049}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &846768605
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 846768603}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c676a8ddf5a5f4f64b35e9ed5028679d, type: 3}
m_Name:
m_EditorClassIdentifier:
brainParameters:
stateSize: 12
actionSize: 4
memorySize: 0
cameraResolutions:
- width: 80
height: 80
blackAndWhite: 1
actionDescriptions:
- Up
- Down
- Left
- Right
actionSpaceType: 0
stateSpaceType: 1
brainType: 2
CoreBrains: []
CollectData: 0
instanceID: 0
--- !u!1 &1223085755
GameObject:
m_ObjectHideFlags: 0

m_Script: {fileID: 11500000, guid: 33bb739f1138d40798114d667776a1d6, type: 3}
m_Name:
m_EditorClassIdentifier:
brain: {fileID: 846768605}
observations:
- {fileID: 1715640924}
maxStep: 100
resetOnDone: 1
id: 0
reward: 0
done: 0
value: 0
CummulativeReward: 0
stepCounter: 0
agentStoredAction: []
memory: []
brain: {fileID: 0}
agentParameters:
agentCameras: []
maxStep: 0
resetOnDone: 1
onDemandDecision: 0
numberOfActionsBetweenDecisions: 1
--- !u!4 &1223085757
Transform:
m_ObjectHideFlags: 0

m_Script: {fileID: 11500000, guid: 9af83cd96d4bc4088a966af174446d1b, type: 3}
m_Name:
m_EditorClassIdentifier:
broadcastHub:
broadcastingBrains: []
_brainsToControl: []
frameToSkip: 0
waitTime: 0
trainingConfiguration:
width: 80
height: 80

qualityLevel: 1
timeScale: 1
targetFrameRate: 60
defaultResetParameters: []
episodeCount: 0
done: 0
currentStep: 0
isInference: 0
windowResize: 0
resetParameters:
resetParameters: []
--- !u!4 &1574236049
Transform:
m_ObjectHideFlags: 0

m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.71938086, y: 0.27357092, z: 4.1970553}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 846768604}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

m_TargetEye: 3
m_HDR: 1
m_AllowMSAA: 1
m_AllowDynamicResolution: 0
m_StereoMirrorMode: 0
--- !u!4 &1715640925
Transform:
m_ObjectHideFlags: 0

3
UnitySDK/Assets/ML-Agents/Examples/Tennis/Brains/TennisLearning.asset


-
-
vectorActionSpaceType: 1
model: {fileID: 4900000, guid: 6d4281b70d41f48cb83d663b84f78c9a, type: 3}
model: {fileID: 11400000, guid: 0b22bc7e45e8347fd897bdf0e1d38c6e, type: 3}
inferenceDevice: 0

4
UnitySDK/Assets/ML-Agents/Examples/Tennis/Prefabs/TennisArea.prefab


m_Script: {fileID: 11500000, guid: e51a3fb0b3186433ea84fc1e0549cc91, type: 3}
m_Name:
m_EditorClassIdentifier:
brain: {fileID: 11400000, guid: 6bf6a586a645b471bb9bd1194ae0e229, type: 2}
brain: {fileID: 11400000, guid: 1674996276be448c2ad51fb139e21e05, type: 2}
agentParameters:
agentCameras: []
maxStep: 5000

m_Script: {fileID: 11500000, guid: e51a3fb0b3186433ea84fc1e0549cc91, type: 3}
m_Name:
m_EditorClassIdentifier:
brain: {fileID: 11400000, guid: 6bf6a586a645b471bb9bd1194ae0e229, type: 2}
brain: {fileID: 11400000, guid: 1674996276be448c2ad51fb139e21e05, type: 2}
agentParameters:
agentCameras: []
maxStep: 5000

2
UnitySDK/Assets/ML-Agents/Examples/Tennis/Scripts/TennisAgent.cs


public override void InitializeAgent()
{
agentRb = GetComponent<Rigidbody>();
ballRb = GetComponent<Rigidbody>();
ballRb = ball.GetComponent<Rigidbody>();
var canvas = GameObject.Find(CanvasName);
GameObject scoreBoard;
if (invertX)

2
UnitySDK/Assets/ML-Agents/Examples/Walker/Brains/WalkerLearning.asset


-
-
vectorActionSpaceType: 1
model: {fileID: 4900000, guid: 48ab33cf9fbee4883948187618027835, type: 3}
model: {fileID: 11400000, guid: 097040deda0de41ddb3050c60d8cfc67, type: 3}

2
UnitySDK/Assets/ML-Agents/Examples/WallJump/Brains/BigWallJumpLearning.asset


-
-
vectorActionSpaceType: 0
model: {fileID: 4900000, guid: c118879bb5db84f269e4da23ba8c4f61, type: 3}
model: {fileID: 11400000, guid: dc3a7a234db41444fb51386dafe44cbc, type: 3}

2
UnitySDK/Assets/ML-Agents/Examples/WallJump/Brains/SmallWallJumpLearning.asset


-
-
vectorActionSpaceType: 0
model: {fileID: 4900000, guid: 92cd96b2c34334db692e93af25b64d2a, type: 3}
model: {fileID: 11400000, guid: 7ed5da5ea3aa74cb4bf83bda60b1518e, type: 3}

80
UnitySDK/Assets/ML-Agents/Plugins/ProtoBuffer/Grpc.Core.dll.meta


isOverridable: 0
platformData:
- first:
'': Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 0
Exclude Linux: 0
Exclude Linux64: 0
Exclude LinuxUniversal: 0
Exclude OSXUniversal: 0
Exclude Win: 0
Exclude Win64: 0
Exclude iOS: 1
- first:
Android: Android
second:
enabled: 0
settings:
CPU: ARMv7
- first:
enabled: 1
enabled: 0
enabled: 0
enabled: 1
CPU: AnyCPU
OS: AnyOS
- first:
Facebook: Win
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Facebook: Win64
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Standalone: Linux
second:
enabled: 1
settings:
CPU: x86
- first:
Standalone: Linux64
second:
enabled: 1
settings:
CPU: x86_64
- first:
Standalone: LinuxUniversal
second:
enabled: 1
settings: {}
- first:
Standalone: OSXUniversal
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
Standalone: Win
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
Standalone: Win64
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
Windows Store Apps: WindowsStoreApps
second:

- first:
iPhone: iOS
second:
enabled: 0
settings:
CompileFlags:
FrameworkDependencies:
userData:
assetBundleName:
assetBundleVariant:

28
UnitySDK/Assets/ML-Agents/Scripts/Academy.cs


[SerializeField]
public BroadcastHub broadcastHub = new BroadcastHub();
private const string kApiVersion = "API-6";
private const string kApiVersion = "API-7";
/// Temporary storage for global gravity value
/// Used to restore oringal value when deriving Academy modifies it
private Vector3 originalGravity;
/// Temporary storage for global fixedDeltaTime value
/// Used to restore oringal value when deriving Academy modifies it
private float originalFixedDeltaTime;
/// Temporary storage for global maximumDeltaTime value
/// Used to restore oringal value when deriving Academy modifies it
private float originalMaximumDeltaTime;
// Fields provided in the Inspector

/// </summary>
private void InitializeEnvironment()
{
originalGravity = Physics.gravity;
originalFixedDeltaTime = Time.fixedDeltaTime;
originalMaximumDeltaTime = Time.maximumDeltaTime;
InitializeAcademy();
Communicator communicator = null;

void FixedUpdate()
{
EnvironmentStep();
}
/// <summary>
/// Cleanup function
/// </summary>
protected virtual void OnDestroy()
{
Physics.gravity = originalGravity;
Time.fixedDeltaTime = originalFixedDeltaTime;
Time.maximumDeltaTime = originalMaximumDeltaTime;
}
}
}

21
UnitySDK/Assets/ML-Agents/Scripts/Agent.cs


}
/// <summary>
/// Adds a float array observation to the vector observations of the agent.
/// Increases the size of the agents vector observation by size of array.
/// </summary>
/// <param name="observation">Observation.</param>
protected void AddVectorObs(float[] observation)
{
info.vectorObservation.AddRange(observation);
}
/// <summary>
/// Adds a float list observation to the vector observations of the agent.
/// Increases the size of the agents vector observation by size of list.
/// Adds a collection of float observations to the vector observations of the agent.
/// Increases the size of the agents vector observation by size of the collection.
protected void AddVectorObs(List<float> observation)
protected void AddVectorObs(IEnumerable<float> observation)
{
info.vectorObservation.AddRange(observation);
}

public void UpdateMemoriesAction(List<float> memories)
{
action.memories = memories;
}
public void AppendMemoriesAction(List<float> memories)
{
action.memories.AddRange(memories);
}
/// <summary>

6
UnitySDK/Assets/ML-Agents/Scripts/CommunicatorObjects/UnityToExternalGrpc.cs


// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: mlagents/envs/communicator_objects/unity_to_external.proto
// </auto-generated>
# if UNITY_EDITOR || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_STANDALONE_LINUX
#pragma warning disable 1591
#region Designer generated code

}
}
#endregion
#endif

40
UnitySDK/Assets/ML-Agents/Scripts/InferenceBrain/ApplierImpl.cs


using System.Collections.Generic;
using MLAgents.InferenceBrain.Utils;
using UnityEngine;
namespace MLAgents.InferenceBrain
{

public void Apply(Tensor tensor, Dictionary<Agent, AgentInfo> agentInfo)
{
var tensorDataAction = tensor.Data as float[,];
var actionSize = tensor.Shape[1];
var actionSize = tensor.Shape[tensor.Shape.Length - 1];
var agentIndex = 0;
foreach (var agent in agentInfo.Keys)
{

}
}
}
public class BarracudaMemoryOutputApplier : TensorApplier.Applier
{
private bool firstHalf = true;
public BarracudaMemoryOutputApplier(bool firstHalf)
{
this.firstHalf = firstHalf;
}
public void Apply(Tensor tensor, Dictionary<Agent, AgentInfo> agentInfo)
{
var tensorDataMemory = tensor.Data as float[,];
var agentIndex = 0;
var memorySize = tensor.Shape[tensor.Shape.Length - 1];
foreach (var agent in agentInfo.Keys)
{
var memory = new List<float>();
for (var j = 0; j < memorySize; j++)
{
memory.Add(tensorDataMemory[agentIndex, j]);
}
if (firstHalf)
{
agent.UpdateMemoriesAction(memory);
}
else
{
agent.AppendMemoriesAction(memory);
}
agentIndex++;
}
}
}
/// <summary>
/// The Applier for the Memory output tensor. Tensor is assumed to contain the new

{
var tensorDataMemory = tensor.Data as float[,];
var agentIndex = 0;
var memorySize = tensor.Shape[1];
var memorySize = tensor.Shape[tensor.Shape.Length - 1];
foreach (var agent in agentInfo.Keys)
{
var memory = new List<float>();

61
UnitySDK/Assets/ML-Agents/Scripts/InferenceBrain/GeneratorImpl.cs


{
public void Generate(Tensor tensor, int batchSize, Dictionary<Agent, AgentInfo> agentInfo)
{
var shapeSecondAxis = tensor.Shape[1];
var shapeSecondAxis = tensor.Shape[tensor.Shape.Length - 1];
tensor.Shape[0] = batchSize;
if (tensor.ValueType == Tensor.TensorType.FloatingPoint)
{

public void Generate(Tensor tensor, int batchSize, Dictionary<Agent, AgentInfo> agentInfo)
{
tensor.Shape[0] = batchSize;
var vecObsSizeT = tensor.Shape[1];
var vecObsSizeT = tensor.Shape[tensor.Shape.Length - 1];
tensor.Data = new float[batchSize, vecObsSizeT];
var agentIndex = 0;
foreach (var agent in agentInfo.Keys)

public void Generate(Tensor tensor, int batchSize, Dictionary<Agent, AgentInfo> agentInfo)
{
tensor.Shape[0] = batchSize;
var memorySize = tensor.Shape[1];
var memorySize = tensor.Shape[tensor.Shape.Length - 1];
tensor.Data = new float[batchSize, memorySize];
var agentIndex = 0;
foreach (var agent in agentInfo.Keys)

}
}
}
public class BarracudaRecurrentInputGenerator : TensorGenerator.Generator
{
private bool firstHalf = true;
public BarracudaRecurrentInputGenerator(bool firstHalf)
{
this.firstHalf = firstHalf;
}
public void Generate(Tensor tensor, int batchSize, Dictionary<Agent, AgentInfo> agentInfo)
{
tensor.Shape[0] = batchSize;
var memorySize = tensor.Shape[tensor.Shape.Length - 1];
tensor.Data = new float[batchSize, memorySize];
var agentIndex = 0;
foreach (var agent in agentInfo.Keys)
{
var memory = agentInfo[agent].memories;
int offset = 0;
if (!firstHalf)
{
offset = memory.Count - (int)memorySize;
}
if (memory == null)
{
agentIndex++;
continue;
}
for (var j = 0; j < memorySize; j++)
{
if (j >= memory.Count)
{
break;
}
tensor.Data.SetValue(memory[j + offset], new int[2] {agentIndex, j});
}
agentIndex++;
}
}
}
/// <summary>
/// Generates the Tensor corresponding to the Previous Action input : Will be a two

{
public void Generate(Tensor tensor, int batchSize, Dictionary<Agent, AgentInfo> agentInfo)
{
if (tensor.ValueType != Tensor.TensorType.Integer)
{
throw new NotImplementedException(
"Previous Action Inputs are only valid for discrete control");
}
var actionSize = tensor.Shape[1];
var actionSize = tensor.Shape[tensor.Shape.Length - 1];
tensor.Data = new int[batchSize, actionSize];
var agentIndex = 0;
foreach (var agent in agentInfo.Keys)

public void Generate(Tensor tensor, int batchSize, Dictionary<Agent, AgentInfo> agentInfo)
{
tensor.Shape[0] = batchSize;
var maskSize = tensor.Shape[1];
var maskSize = tensor.Shape[tensor.Shape.Length - 1];
tensor.Data = new float[batchSize, maskSize];
var agentIndex = 0;
foreach (var agent in agentInfo.Keys)

public void Generate(Tensor tensor, int batchSize, Dictionary<Agent, AgentInfo> agentInfo)
{
tensor.Shape[0] = batchSize;
var actionSize = tensor.Shape[1];
var actionSize = tensor.Shape[tensor.Shape.Length - 1];
tensor.Data = new float[batchSize, actionSize];
_randomNormal.FillTensor(tensor);
}

2
UnitySDK/Assets/ML-Agents/Scripts/InferenceBrain/ModelParamLoader.cs


Discrete,
Continuous
}
private const long ApiVersion = 1;
private const long ApiVersion = 2;
private TFSharpInferenceEngine _engine;
private BrainParameters _brainParameters;
private List<string> _failedModelChecks = new List<string>();

3
UnitySDK/Assets/ML-Agents/Scripts/InferenceBrain/TensorApplier.cs


bp.vectorActionSize, seed);
}
_dict[TensorNames.RecurrentOutput] = new MemoryOutputApplier();
_dict[TensorNames.RecurrentOutput_C] = new BarracudaMemoryOutputApplier(true);
_dict[TensorNames.RecurrentOutput_H] = new BarracudaMemoryOutputApplier(false);
}
/// <summary>

4
UnitySDK/Assets/ML-Agents/Scripts/InferenceBrain/TensorGenerator.cs


_dict[TensorNames.SequenceLengthPlaceholder] = new SequenceLengthGenerator();
_dict[TensorNames.VectorObservationPlacholder] = new VectorObservationGenerator();
_dict[TensorNames.RecurrentInPlaceholder] = new RecurrentInputGenerator();
_dict[TensorNames.RecurrentInPlaceholder_C] = new BarracudaRecurrentInputGenerator(true);
_dict[TensorNames.RecurrentInPlaceholder_H] = new BarracudaRecurrentInputGenerator(false);
_dict[TensorNames.PreviousActionPlaceholder] = new PreviousActionInputGenerator();
_dict[TensorNames.ActionMaskPlaceholder] = new ActionMaskInputGenerator();
_dict[TensorNames.RandomNormalEpsilonPlaceholder] = new RandomNormalInputGenerator(seed);

4
UnitySDK/Assets/ML-Agents/Scripts/InferenceBrain/TensorNames.cs


public const string SequenceLengthPlaceholder = "sequence_length";
public const string VectorObservationPlacholder = "vector_observation";
public const string RecurrentInPlaceholder = "recurrent_in";
public const string RecurrentInPlaceholder_H = "recurrent_in_h";
public const string RecurrentInPlaceholder_C = "recurrent_in_c";
public const string VisualObservationPlaceholderPrefix = "visual_observation_";
public const string PreviousActionPlaceholder = "prev_action";
public const string ActionMaskPlaceholder = "action_masks";

public const string RecurrentOutput = "recurrent_out";
public const string RecurrentOutput_H = "recurrent_out_h";
public const string RecurrentOutput_C = "recurrent_out_c";
public const string MemorySize = "memory_size";
public const string VersionNumber = "version_number";
public const string IsContinuousControl = "is_continuous_control";

124
UnitySDK/Assets/ML-Agents/Scripts/LearningBrain.cs


using System;
#define ENABLE_BARRACUDA
using System;
using Barracuda;
using Tensor = MLAgents.InferenceBrain.Tensor;
public enum InferenceDevice
{
CPU = 0,
GPU = 1
}
/// <summary>
/// The Learning Brain works differently if you are training it or not.
/// When training your Agents, drag the Learning Brain to the Academy's BroadcastHub and check

private TensorGenerator _tensorGenerator;
private TensorApplier _tensorApplier;
#if ENABLE_TENSORFLOW
private ModelParamLoader _modelParamLoader;
#endif
#if ENABLE_TENSORFLOW
private ModelParamLoader _modelParamLoader;
#elif ENABLE_BARRACUDA
public NNModel model;
private Model _barracudaModel;
private IWorker _engine;
private bool _verbose = false;
private BarracudaModelParamLoader _modelParamLoader;
private string[] _outputNames;
[Tooltip("Inference execution device. CPU is the fastest option for most of ML Agents models. " +
"(This field is not applicable for training).")]
public InferenceDevice inferenceDevice = InferenceDevice.CPU;
private IEnumerable<Tensor> _inferenceInputs;
private IEnumerable<Tensor> _inferenceOutputs;

_inferenceOutputs = _modelParamLoader.GetOutputTensors();
_tensorGenerator = new TensorGenerator(brainParameters, seed);
_tensorApplier = new TensorApplier(brainParameters, seed);
#elif ENABLE_BARRACUDA
if (model != null)
{
#if BARRACUDA_VERBOSE
_verbose = true;
#endif
D.logEnabled = _verbose;
// Cleanup previous instance
if (_engine != null)
_engine.Dispose();
_barracudaModel = ModelLoader.Load(model.Value);
var executionDevice = inferenceDevice == InferenceDevice.GPU
? BarracudaWorkerFactory.Type.ComputeFast
: BarracudaWorkerFactory.Type.CSharpFast;
_engine = BarracudaWorkerFactory.CreateWorker(executionDevice, _barracudaModel, _verbose);
}
else
{
_barracudaModel = null;
_engine = null;
}
_modelParamLoader = BarracudaModelParamLoader.GetLoaderAndCheck(_engine, _barracudaModel, brainParameters);
_inferenceInputs = _modelParamLoader.GetInputTensors();
_outputNames = _modelParamLoader.GetOutputNames();
_tensorGenerator = new TensorGenerator(brainParameters, seed);
_tensorApplier = new TensorApplier(brainParameters, seed);
#endif
}

{
#if ENABLE_TENSORFLOW
return (_modelParamLoader != null) ? _modelParamLoader.GetChecks() : new List<string>();
#elif ENABLE_BARRACUDA
return (_modelParamLoader != null) ? _modelParamLoader.GetChecks() : new List<string>();