浏览代码
Decoupling IPolicy from Agent (#3203)
Decoupling IPolicy from Agent (#3203)
* initial commit * Fixed the compilation errors * fixing the tests * Addressing the comment about the brain parameters * Fixing typo * Made timers more accurate * addressing comments * Better memory allocation * Added some docstrings * Adding better sensor validation * Wrapped in #if DEBUG and also wrapped GenerateSensorData in a timer * Timer changes/asymm-envs
GitHub
5 年前
当前提交
f97bcf1c
共有 24 个文件被更改,包括 363 次插入 和 328 次删除
-
2UnitySDK/Assets/ML-Agents/Editor/Tests/DemonstrationTests.cs
-
89UnitySDK/Assets/ML-Agents/Editor/Tests/EditModeTestInternalBrainTensorApplier.cs
-
33UnitySDK/Assets/ML-Agents/Editor/Tests/EditModeTestInternalBrainTensorGenerator.cs
-
1UnitySDK/Assets/ML-Agents/Editor/Tests/MLAgentsEditModeTest.cs
-
56UnitySDK/Assets/ML-Agents/Scripts/Agent.cs
-
6UnitySDK/Assets/ML-Agents/Scripts/DemonstrationRecorder.cs
-
7UnitySDK/Assets/ML-Agents/Scripts/DemonstrationStore.cs
-
10UnitySDK/Assets/ML-Agents/Scripts/Grpc/GrpcExtensions.cs
-
100UnitySDK/Assets/ML-Agents/Scripts/Grpc/RpcCommunicator.cs
-
9UnitySDK/Assets/ML-Agents/Scripts/ICommunicator.cs
-
61UnitySDK/Assets/ML-Agents/Scripts/InferenceBrain/ApplierImpl.cs
-
56UnitySDK/Assets/ML-Agents/Scripts/InferenceBrain/GeneratorImpl.cs
-
46UnitySDK/Assets/ML-Agents/Scripts/InferenceBrain/ModelRunner.cs
-
8UnitySDK/Assets/ML-Agents/Scripts/InferenceBrain/TensorApplier.cs
-
15UnitySDK/Assets/ML-Agents/Scripts/InferenceBrain/TensorGenerator.cs
-
6UnitySDK/Assets/ML-Agents/Scripts/Monitor.cs
-
45UnitySDK/Assets/ML-Agents/Scripts/Policy/BarracudaPolicy.cs
-
14UnitySDK/Assets/ML-Agents/Scripts/Policy/HeuristicPolicy.cs
-
5UnitySDK/Assets/ML-Agents/Scripts/Policy/IPolicy.cs
-
45UnitySDK/Assets/ML-Agents/Scripts/Policy/RemotePolicy.cs
-
6UnitySDK/Assets/ML-Agents/Scripts/Sensor/WriteAdapter.cs
-
16UnitySDK/Assets/ML-Agents/Scripts/Utilities.cs
-
44UnitySDK/Assets/ML-Agents/Scripts/Sensor/SensorShapeValidator.cs
-
11UnitySDK/Assets/ML-Agents/Scripts/Sensor/SensorShapeValidator.cs.meta
|
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
|
|||
namespace MLAgents.Sensor |
|||
{ |
|||
|
|||
public class SensorShapeValidator |
|||
{ |
|||
private List<int[]> m_SensorShapes; |
|||
|
|||
/// <summary>
|
|||
/// Check that the List Sensors are the same shape as the previous ones.
|
|||
/// If this is the first List of Sensors being checked, its Sensor sizes will be saved.
|
|||
/// </summary>
|
|||
public void ValidateSensors(List<ISensor> sensors) |
|||
{ |
|||
if (m_SensorShapes == null) |
|||
{ |
|||
m_SensorShapes = new List<int[]>(sensors.Count); |
|||
// First agent, save the sensor sizes
|
|||
foreach (var sensor in sensors) |
|||
{ |
|||
m_SensorShapes.Add(sensor.GetObservationShape()); |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
// Check for compatibility with the other Agents' Sensors
|
|||
// TODO make sure this only checks once per agent
|
|||
Debug.Assert(m_SensorShapes.Count == sensors.Count, $"Number of Sensors must match. {m_SensorShapes.Count} != {sensors.Count}"); |
|||
for (var i = 0; i < m_SensorShapes.Count; i++) |
|||
{ |
|||
var cachedShape = m_SensorShapes[i]; |
|||
var sensorShape = sensors[i].GetObservationShape(); |
|||
Debug.Assert(cachedShape.Length == sensorShape.Length, "Sensor dimensions must match."); |
|||
for (var j = 0; j < cachedShape.Length; j++) |
|||
{ |
|||
Debug.Assert(cachedShape[j] == sensorShape[j], "Sensor sizes much match."); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: a7b5a4560ee254be497321527f92c174 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue