浏览代码

avoid empty set iteration, avoid Debug.AssertFormat (#5246)

* avoid empty set iteration, avoid Debug.AssertFormat

* changelog
/check-for-ModelOverriders
GitHub 4 年前
当前提交
03af9322
共有 4 个文件被更改,包括 37 次插入21 次删除
  1. 1
      com.unity.ml-agents/CHANGELOG.md
  2. 11
      com.unity.ml-agents/Runtime/Actuators/ActuatorManager.cs
  3. 14
      com.unity.ml-agents/Runtime/Agent.cs
  4. 32
      com.unity.ml-agents/Runtime/Sensors/SensorShapeValidator.cs

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


- Fixed a bug where sensors and actuators could get sorted inconsistently on different systems to different Culture
settings. Unfortunately, this may require retraining models if it changes the resulting order of the sensors
or actuators on your system. (#5194)
- Removed additional memory allocations that were occurring due to assert messages and iterating of DemonstrationRecorders. (#5246)
#### ml-agents / ml-agents-envs / gym-unity (Python)
- Fixed an issue which was causing increased variance when using LSTMs. Also fixed an issue with LSTM when used with POCA and `sequence_length` < `time_horizon`. (#5206)
- Fixed a bug where the SAC replay buffer would not be saved out at the end of a run, even if `save_replay_buffer` was enabled. (#5205)

11
com.unity.ml-agents/Runtime/Actuators/ActuatorManager.cs


}
else
{
Debug.AssertFormat(sourceActionBuffer.Length == destination.Length,
"sourceActionBuffer: {0} is a different size than destination: {1}.",
sourceActionBuffer.Length,
destination.Length);
if (sourceActionBuffer.Length != destination.Length)
{
Debug.AssertFormat(sourceActionBuffer.Length == destination.Length,
"sourceActionBuffer: {0} is a different size than destination: {1}.",
sourceActionBuffer.Length,
destination.Length);
}
Array.Copy(sourceActionBuffer.Array,
sourceActionBuffer.Offset,

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


m_Brain?.RequestDecision(m_Info, sensors);
// We also have to write any to any DemonstationStores so that they get the "done" flag.
foreach (var demoWriter in DemonstrationWriters)
if (DemonstrationWriters.Count != 0)
demoWriter.Record(m_Info, sensors);
foreach (var demoWriter in DemonstrationWriters)
{
demoWriter.Record(m_Info, sensors);
}
}
ResetSensors();

}
// If we have any DemonstrationWriters, write the AgentInfo and sensors to them.
foreach (var demoWriter in DemonstrationWriters)
if (DemonstrationWriters.Count != 0)
demoWriter.Record(m_Info, sensors);
foreach (var demoWriter in DemonstrationWriters)
{
demoWriter.Record(m_Info, sensors);
}
}
}

32
com.unity.ml-agents/Runtime/Sensors/SensorShapeValidator.cs


else
{
// Check for compatibility with the other Agents' Sensors
// TODO make sure this only checks once per agent
Debug.AssertFormat(
m_SensorShapes.Count == sensors.Count,
"Number of Sensors must match. {0} != {1}",
m_SensorShapes.Count,
sensors.Count
);
if (m_SensorShapes.Count != sensors.Count)
{
Debug.AssertFormat(
m_SensorShapes.Count == sensors.Count,
"Number of Sensors must match. {0} != {1}",
m_SensorShapes.Count,
sensors.Count
);
}
Debug.AssertFormat(
cachedSpec.Shape == sensorSpec.Shape,
"Sensor shapes must match. {0} != {1}",
cachedSpec.Shape,
sensorSpec.Shape
);
if (cachedSpec.Shape != sensorSpec.Shape)
{
Debug.AssertFormat(
cachedSpec.Shape == sensorSpec.Shape,
"Sensor shapes must match. {0} != {1}",
cachedSpec.Shape,
sensorSpec.Shape
);
}
}
}
}
正在加载...
取消
保存