浏览代码

[WIP] [Fix] Fixing collect observation called on done (#5375)

* [WIP] [Fix] Fixing collect observation called on done

* Update com.unity.ml-agents/Runtime/Agent.cs

* ⚠️ Modifying the test of stacking sensor when the agent is done

* modifying the documentation for BufferSensor to specify to call AddObservation in the CollectObservations method
/colab-links
GitHub 3 年前
当前提交
8bb1fe6a
共有 3 个文件被更改,包括 17 次插入11 次删除
  1. 11
      com.unity.ml-agents/Runtime/Agent.cs
  2. 11
      com.unity.ml-agents/Tests/Runtime/Sensor/StackingSensorTests.cs
  3. 6
      docs/Learning-Environment-Design-Agents.md

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


m_Info.done = true;
m_Info.maxStepReached = doneReason == DoneReason.MaxStepReached;
m_Info.groupId = m_GroupId;
if (collectObservationsSensor != null)
UpdateSensors();
// Make sure the latest observations are being passed to training.
using (m_CollectObservationsChecker.Start())
// Make sure the latest observations are being passed to training.
collectObservationsSensor.Reset();
using (m_CollectObservationsChecker.Start())
{
CollectObservations(collectObservationsSensor);
}
CollectObservations(collectObservationsSensor);
}
// Request the last decision with no callbacks
// We request a decision so Python knows the Agent is done immediately

11
com.unity.ml-agents/Tests/Runtime/Sensor/StackingSensorTests.cs


agent1.RequestDecision();
aca.EnvironmentStep();
}
policy.OnRequestDecision = () => SensorTestHelper.CompareObservation(sensor, new[] { 18f, 19f, 21f });
SensorTestHelper.CompareObservation(sensor, new[] { 18f, 19f, 20f });
policy.OnRequestDecision = () => SensorTestHelper.CompareObservation(sensor, new[] { 19f, 20f, 21f });
policy.OnRequestDecision = () => { };
for (int i = 0; i < 20; i++)
{
agent1.RequestDecision();
aca.EnvironmentStep();
SensorTestHelper.CompareObservation(sensor, new[] { Math.Max(0, i - 1f), i, i + 1 });
}
}
[Test]

6
docs/Learning-Environment-Design-Agents.md


the `BufferSensor` will be able to collect.
To add an entity's observations to a `BufferSensorComponent`, you need
to call `BufferSensorComponent.AppendObservation()`
to call `BufferSensorComponent.AppendObservation()` in the
Agent.CollectObservations() method
with a float array of size `Observation Size` as argument.
__Note__: Currently, the observations put into the `BufferSensor` are

#### Variable Length Observation Summary & Best Practices
- Attach `BufferSensorComponent` to use.
- Call `BufferSensorComponent.AppendObservation()` to add the observations
- Call `BufferSensorComponent.AppendObservation()` in the
Agent.CollectObservations() methodto add the observations
of an entity to the `BufferSensor`.
- Normalize the entities observations before feeding them into the `BufferSensor`.

正在加载...
取消
保存