浏览代码

Reintroduce MLAgents.Sensors namespace (#3509)

* Reintroduced the namespace MLAgents.Sensors

* Documentation changes

* updated the changelog
/asymm-envs
GitHub 5 年前
当前提交
f25bf7d3
共有 56 个文件被更改,包括 57 次插入26 次删除
  1. 1
      Project/Assets/ML-Agents/Examples/3DBall/Scripts/Ball3DAgent.cs
  2. 1
      Project/Assets/ML-Agents/Examples/3DBall/Scripts/Ball3DHardAgent.cs
  3. 1
      Project/Assets/ML-Agents/Examples/Basic/Scripts/BasicAgent.cs
  4. 1
      Project/Assets/ML-Agents/Examples/Bouncer/Scripts/BouncerAgent.cs
  5. 1
      Project/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerAgent.cs
  6. 1
      Project/Assets/ML-Agents/Examples/FoodCollector/Scripts/FoodCollectorAgent.cs
  7. 1
      Project/Assets/ML-Agents/Examples/GridWorld/Scripts/GridAgent.cs
  8. 1
      Project/Assets/ML-Agents/Examples/Hallway/Scripts/HallwayAgent.cs
  9. 1
      Project/Assets/ML-Agents/Examples/Pyramids/Scripts/PyramidAgent.cs
  10. 1
      Project/Assets/ML-Agents/Examples/Reacher/Scripts/ReacherAgent.cs
  11. 1
      Project/Assets/ML-Agents/Examples/Template/Scripts/TemplateAgent.cs
  12. 1
      Project/Assets/ML-Agents/Examples/Tennis/Scripts/TennisAgent.cs
  13. 1
      Project/Assets/ML-Agents/Examples/Walker/Scripts/WalkerAgent.cs
  14. 2
      Project/Assets/ML-Agents/Examples/WallJump/Scripts/WallJumpAgent.cs
  15. 1
      com.unity.ml-agents/CHANGELOG.md
  16. 2
      com.unity.ml-agents/Editor/BehaviorParametersEditor.cs
  17. 2
      com.unity.ml-agents/Editor/RayPerceptionSensorComponentBaseEditor.cs
  18. 1
      com.unity.ml-agents/Runtime/Agent.cs
  19. 1
      com.unity.ml-agents/Runtime/Communicator/GrpcExtensions.cs
  20. 1
      com.unity.ml-agents/Runtime/Communicator/ICommunicator.cs
  21. 1
      com.unity.ml-agents/Runtime/Communicator/RpcCommunicator.cs
  22. 1
      com.unity.ml-agents/Runtime/Demonstrations/DemonstrationWriter.cs
  23. 2
      com.unity.ml-agents/Runtime/InferenceBrain/BarracudaModelParamLoader.cs
  24. 1
      com.unity.ml-agents/Runtime/InferenceBrain/GeneratorImpl.cs
  25. 2
      com.unity.ml-agents/Runtime/InferenceBrain/ModelRunner.cs
  26. 1
      com.unity.ml-agents/Runtime/InferenceBrain/TensorGenerator.cs
  27. 1
      com.unity.ml-agents/Runtime/Policy/BarracudaPolicy.cs
  28. 1
      com.unity.ml-agents/Runtime/Policy/HeuristicPolicy.cs
  29. 1
      com.unity.ml-agents/Runtime/Policy/IPolicy.cs
  30. 1
      com.unity.ml-agents/Runtime/Policy/RemotePolicy.cs
  31. 2
      com.unity.ml-agents/Runtime/Sensor/CameraSensor.cs
  32. 2
      com.unity.ml-agents/Runtime/Sensor/CameraSensorComponent.cs
  33. 2
      com.unity.ml-agents/Runtime/Sensor/ISensor.cs
  34. 3
      com.unity.ml-agents/Runtime/Sensor/Observation.cs
  35. 2
      com.unity.ml-agents/Runtime/Sensor/RayPerceptionSensor.cs
  36. 2
      com.unity.ml-agents/Runtime/Sensor/RayPerceptionSensorComponent2D.cs
  37. 2
      com.unity.ml-agents/Runtime/Sensor/RayPerceptionSensorComponent3D.cs
  38. 2
      com.unity.ml-agents/Runtime/Sensor/RayPerceptionSensorComponentBase.cs
  39. 2
      com.unity.ml-agents/Runtime/Sensor/RenderTextureSensor.cs
  40. 2
      com.unity.ml-agents/Runtime/Sensor/RenderTextureSensorComponent.cs
  41. 2
      com.unity.ml-agents/Runtime/Sensor/SensorBase.cs
  42. 2
      com.unity.ml-agents/Runtime/Sensor/SensorComponent.cs
  43. 2
      com.unity.ml-agents/Runtime/Sensor/SensorShapeValidator.cs
  44. 2
      com.unity.ml-agents/Runtime/Sensor/StackingSensor.cs
  45. 2
      com.unity.ml-agents/Runtime/Sensor/VectorSensor.cs
  46. 2
      com.unity.ml-agents/Runtime/Sensor/WriteAdapter.cs
  47. 1
      com.unity.ml-agents/Runtime/Utilities.cs
  48. 1
      com.unity.ml-agents/Tests/Editor/DemonstrationTests.cs
  49. 1
      com.unity.ml-agents/Tests/Editor/MLAgentsEditModeTest.cs
  50. 2
      com.unity.ml-agents/Tests/Editor/Sensor/FloatVisualSensorTests.cs
  51. 1
      com.unity.ml-agents/Tests/Editor/Sensor/RayPerceptionSensorTests.cs
  52. 2
      com.unity.ml-agents/Tests/Editor/Sensor/StackingSensorTests.cs
  53. 1
      com.unity.ml-agents/Tests/Editor/Sensor/VectorSensorTests.cs
  54. 2
      com.unity.ml-agents/Tests/Editor/Sensor/WriterAdapterTests.cs
  55. 3
      docs/Learning-Environment-Create-New.md
  56. 1
      docs/Migrating.md

1
Project/Assets/ML-Agents/Examples/3DBall/Scripts/Ball3DAgent.cs


using UnityEngine;
using MLAgents;
using MLAgents.Sensors;
public class Ball3DAgent : Agent
{

1
Project/Assets/ML-Agents/Examples/3DBall/Scripts/Ball3DHardAgent.cs


using UnityEngine;
using MLAgents;
using MLAgents.Sensors;
public class Ball3DHardAgent : Agent
{

1
Project/Assets/ML-Agents/Examples/Basic/Scripts/BasicAgent.cs


using UnityEngine;
using MLAgents;
using MLAgents.Sensors;
public class BasicAgent : Agent
{

1
Project/Assets/ML-Agents/Examples/Bouncer/Scripts/BouncerAgent.cs


using UnityEngine;
using MLAgents;
using MLAgents.Sensors;
public class BouncerAgent : Agent
{

1
Project/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerAgent.cs


using UnityEngine;
using MLAgents;
using MLAgentsExamples;
using MLAgents.Sensors;
[RequireComponent(typeof(JointDriveController))] // Required to set joint forces
public class CrawlerAgent : Agent

1
Project/Assets/ML-Agents/Examples/FoodCollector/Scripts/FoodCollectorAgent.cs


using UnityEngine;
using MLAgents;
using MLAgents.Sensors;
public class FoodCollectorAgent : Agent
{

1
Project/Assets/ML-Agents/Examples/GridWorld/Scripts/GridAgent.cs


using UnityEngine;
using System.Linq;
using MLAgents;
using MLAgents.Sensors;
using UnityEngine.Serialization;
public class GridAgent : Agent

1
Project/Assets/ML-Agents/Examples/Hallway/Scripts/HallwayAgent.cs


using System.Collections;
using UnityEngine;
using MLAgents;
using MLAgents.Sensors;
public class HallwayAgent : Agent
{

1
Project/Assets/ML-Agents/Examples/Pyramids/Scripts/PyramidAgent.cs


using UnityEngine;
using Random = UnityEngine.Random;
using MLAgents;
using MLAgents.Sensors;
public class PyramidAgent : Agent
{

1
Project/Assets/ML-Agents/Examples/Reacher/Scripts/ReacherAgent.cs


using UnityEngine;
using MLAgents;
using MLAgents.Sensors;
public class ReacherAgent : Agent
{

1
Project/Assets/ML-Agents/Examples/Template/Scripts/TemplateAgent.cs


using UnityEngine;
using MLAgents;
using MLAgents.Sensors;
public class TemplateAgent : Agent
{

1
Project/Assets/ML-Agents/Examples/Tennis/Scripts/TennisAgent.cs


using UnityEngine;
using UnityEngine.UI;
using MLAgents;
using MLAgents.Sensors;
public class TennisAgent : Agent
{

1
Project/Assets/ML-Agents/Examples/Walker/Scripts/WalkerAgent.cs


using UnityEngine;
using MLAgents;
using MLAgentsExamples;
using MLAgents.Sensors;
public class WalkerAgent : Agent
{

2
Project/Assets/ML-Agents/Examples/WallJump/Scripts/WallJumpAgent.cs


using UnityEngine;
using MLAgents;
using Barracuda;
using MLAgents.Sensors;
public class WallJumpAgent : Agent
{

1
com.unity.ml-agents/CHANGELOG.md


- Beta support for ONNX export was added. If the `tf2onnx` python package is installed, models will be saved to `.onnx` as well as `.nn` format.
Note that Barracuda 0.6.0 or later is required to import the `.onnx` files properly
- Multi-GPU training and the `--multi-gpu` option has been removed temporarily. (#3345)
- All Sensor related code has been moved to the namespace `MLAgents.Sensors`.
### Minor Changes
- Monitor.cs was moved to Examples. (#3372)

2
com.unity.ml-agents/Editor/BehaviorParametersEditor.cs


using UnityEngine;
using MLAgents.Sensors;
using UnityEditor;
using Barracuda;

2
com.unity.ml-agents/Editor/RayPerceptionSensorComponentBaseEditor.cs


using UnityEngine;
using UnityEditor;
using Barracuda;
using MLAgents.Sensors;
namespace MLAgents
{

1
com.unity.ml-agents/Runtime/Agent.cs


using System.Collections.Generic;
using UnityEngine;
using Barracuda;
using MLAgents.Sensors;
namespace MLAgents
{

1
com.unity.ml-agents/Runtime/Communicator/GrpcExtensions.cs


using MLAgents.CommunicatorObjects;
using UnityEngine;
using System.Runtime.CompilerServices;
using MLAgents.Sensors;
[assembly: InternalsVisibleTo("Unity.ML-Agents.Editor")]
[assembly: InternalsVisibleTo("Unity.ML-Agents.Editor.Tests")]

1
com.unity.ml-agents/Runtime/Communicator/ICommunicator.cs


using System;
using System.Collections.Generic;
using UnityEngine;
using MLAgents.Sensors;
namespace MLAgents
{

1
com.unity.ml-agents/Runtime/Communicator/RpcCommunicator.cs


using System.Linq;
using UnityEngine;
using MLAgents.CommunicatorObjects;
using MLAgents.Sensors;
using System.IO;
using Google.Protobuf;

1
com.unity.ml-agents/Runtime/Demonstrations/DemonstrationWriter.cs


using System.IO;
using Google.Protobuf;
using System.Collections.Generic;
using MLAgents.Sensors;
namespace MLAgents
{

2
com.unity.ml-agents/Runtime/InferenceBrain/BarracudaModelParamLoader.cs


using System.Collections.Generic;
using System.Linq;
using Barracuda;
using UnityEngine;
using MLAgents.Sensors;
namespace MLAgents.InferenceBrain
{

1
com.unity.ml-agents/Runtime/InferenceBrain/GeneratorImpl.cs


using Barracuda;
using MLAgents.InferenceBrain.Utils;
using UnityEngine;
using MLAgents.Sensors;
namespace MLAgents.InferenceBrain
{

2
com.unity.ml-agents/Runtime/InferenceBrain/ModelRunner.cs


using System.Collections.Generic;
using Barracuda;
using UnityEngine.Profiling;
using System;
using MLAgents.Sensors;
namespace MLAgents.InferenceBrain
{

1
com.unity.ml-agents/Runtime/InferenceBrain/TensorGenerator.cs


using System.Collections.Generic;
using Barracuda;
using MLAgents.Sensors;
namespace MLAgents.InferenceBrain
{

1
com.unity.ml-agents/Runtime/Policy/BarracudaPolicy.cs


using System.Collections.Generic;
using MLAgents.InferenceBrain;
using System;
using MLAgents.Sensors;
namespace MLAgents
{

1
com.unity.ml-agents/Runtime/Policy/HeuristicPolicy.cs


using System.Collections.Generic;
using System;
using MLAgents.Sensors;
namespace MLAgents
{

1
com.unity.ml-agents/Runtime/Policy/IPolicy.cs


using System;
using System.Collections.Generic;
using MLAgents.Sensors;
namespace MLAgents
{

1
com.unity.ml-agents/Runtime/Policy/RemotePolicy.cs


using UnityEngine;
using System.Collections.Generic;
using System;
using MLAgents.Sensors;
namespace MLAgents
{

2
com.unity.ml-agents/Runtime/Sensor/CameraSensor.cs


using UnityEngine;
namespace MLAgents
namespace MLAgents.Sensors
{
/// <summary>
/// A sensor that wraps a Camera object to generate visual observations for an agent.

2
com.unity.ml-agents/Runtime/Sensor/CameraSensorComponent.cs


using UnityEngine;
namespace MLAgents
namespace MLAgents.Sensors
{
/// <summary>
/// A SensorComponent that creates a <see cref="CameraSensor"/>.

2
com.unity.ml-agents/Runtime/Sensor/ISensor.cs


namespace MLAgents
namespace MLAgents.Sensors
{
/// <summary>
/// The compression setting for visual/camera observations.

3
com.unity.ml-agents/Runtime/Sensor/Observation.cs


using System;
using UnityEngine;
namespace MLAgents
namespace MLAgents.Sensors
{
internal struct Observation
{

2
com.unity.ml-agents/Runtime/Sensor/RayPerceptionSensor.cs


using System.Collections.Generic;
using UnityEngine;
namespace MLAgents
namespace MLAgents.Sensors
{
/// <summary>
/// Determines which dimensions the sensor will perform the casts in.

2
com.unity.ml-agents/Runtime/Sensor/RayPerceptionSensorComponent2D.cs


using UnityEngine;
namespace MLAgents
namespace MLAgents.Sensors
{
/// <summary>
/// A component for 2D Ray Perception.

2
com.unity.ml-agents/Runtime/Sensor/RayPerceptionSensorComponent3D.cs


using UnityEngine;
using UnityEngine.Serialization;
namespace MLAgents
namespace MLAgents.Sensors
{
/// <summary>
/// A component for 3D Ray Perception.

2
com.unity.ml-agents/Runtime/Sensor/RayPerceptionSensorComponentBase.cs


using UnityEngine;
using UnityEngine.Serialization;
namespace MLAgents
namespace MLAgents.Sensors
{
/// <summary>
/// A base class to support sensor components for raycast-based sensors.

2
com.unity.ml-agents/Runtime/Sensor/RenderTextureSensor.cs


using UnityEngine;
namespace MLAgents
namespace MLAgents.Sensors
{
/// <summary>
/// Sensor class that wraps a <see cref="RenderTexture"/> instance.

2
com.unity.ml-agents/Runtime/Sensor/RenderTextureSensorComponent.cs


using UnityEngine;
namespace MLAgents
namespace MLAgents.Sensors
{
/// <summary>
/// Component that wraps a <see cref="RenderTextureSensor"/>.

2
com.unity.ml-agents/Runtime/Sensor/SensorBase.cs


namespace MLAgents
namespace MLAgents.Sensors
{
/// <summary>
/// A base sensor that provides a number default implementations.

2
com.unity.ml-agents/Runtime/Sensor/SensorComponent.cs


using UnityEngine;
namespace MLAgents
namespace MLAgents.Sensors
{
/// <summary>
/// Editor components for creating Sensors. Generally an ISensor implementation should have a

2
com.unity.ml-agents/Runtime/Sensor/SensorShapeValidator.cs


using System.Collections.Generic;
using UnityEngine;
namespace MLAgents
namespace MLAgents.Sensors
{
internal class SensorShapeValidator
{

2
com.unity.ml-agents/Runtime/Sensor/StackingSensor.cs


namespace MLAgents
namespace MLAgents.Sensors
{
/// <summary>
/// Sensor that wraps around another Sensor to provide temporal stacking.

2
com.unity.ml-agents/Runtime/Sensor/VectorSensor.cs


using System.Collections.Generic;
using UnityEngine;
namespace MLAgents
namespace MLAgents.Sensors
{
/// <summary>
/// A sensor implementation for vector observations.

2
com.unity.ml-agents/Runtime/Sensor/WriteAdapter.cs


using Barracuda;
using MLAgents.InferenceBrain;
namespace MLAgents
namespace MLAgents.Sensors
{
/// <summary>
/// Allows sensors to write to both TensorProxy and float arrays/lists.

1
com.unity.ml-agents/Runtime/Utilities.cs


using System;
using UnityEngine;
using MLAgents.Sensors;
namespace MLAgents
{

1
com.unity.ml-agents/Tests/Editor/DemonstrationTests.cs


using System.IO.Abstractions.TestingHelpers;
using System.Reflection;
using MLAgents.CommunicatorObjects;
using MLAgents.Sensors;
namespace MLAgents.Tests
{

1
com.unity.ml-agents/Tests/Editor/MLAgentsEditModeTest.cs


using NUnit.Framework;
using System.Reflection;
using System.Collections.Generic;
using MLAgents.Sensors;
namespace MLAgents.Tests
{

2
com.unity.ml-agents/Tests/Editor/Sensor/FloatVisualSensorTests.cs


using NUnit.Framework;
using UnityEngine;
using MLAgents.Sensors;
namespace MLAgents.Tests
{

1
com.unity.ml-agents/Tests/Editor/Sensor/RayPerceptionSensorTests.cs


using System.Collections.Generic;
using NUnit.Framework;
using UnityEngine;
using MLAgents.Sensors;
namespace MLAgents.Tests
{

2
com.unity.ml-agents/Tests/Editor/Sensor/StackingSensorTests.cs


using NUnit.Framework;
using UnityEngine;
using MLAgents.Sensors;
namespace MLAgents.Tests
{

1
com.unity.ml-agents/Tests/Editor/Sensor/VectorSensorTests.cs


using NUnit.Framework;
using UnityEngine;
using MLAgents.Sensors;
namespace MLAgents.Tests
{

2
com.unity.ml-agents/Tests/Editor/Sensor/WriterAdapterTests.cs


using NUnit.Framework;
using UnityEngine;
using MLAgents.Sensors;
using Barracuda;
using MLAgents.InferenceBrain;

3
docs/Learning-Environment-Create-New.md


1. In the Unity Project window, double-click the `RollerAgent` script to open it
in your code editor.
2. In the editor, add the `using MLAgents;` statement and then change the base
2. In the editor, add the `using MLAgents;` and `using MLAgents.Sensors` statements and then change the base
class from `MonoBehaviour` to `Agent`.
3. Delete the `Update()` method, but we will use the `Start()` function, so
leave it alone for now.

using System.Collections.Generic;
using UnityEngine;
using MLAgents;
using MLAgents.Sensors;
public class RollerAgent : Agent
{

1
docs/Migrating.md


* The `--multi-gpu` option has been removed temporarily.
### Steps to Migrate
* Add the `using MLAgents.Sensors;` in addition to `using MLAgents;` on top of your Agent's script.
* Replace your Agent's implementation of `CollectObservations()` with `CollectObservations(VectorSensor sensor)`. In addition, replace all calls to `AddVectorObs()` with `sensor.AddObservation()` or `sensor.AddOneHotObservation()` on the `VectorSensor` passed as argument.
* Replace your calls to `SetActionMask` on your Agent to `ActionMasker.SetActionMask` in `CollectObservations`
* If you call `RayPerceptionSensor.PerceiveStatic()` manually, add your inputs to a `RayPerceptionInput`. To get the previous float array output, use `RayPerceptionOutput.ToFloatArray()`

正在加载...
取消
保存