浏览代码

deep copy action buffer

/ai-hw-2021
Ruo-Ping Dong 4 年前
当前提交
95bc89c8
共有 1 个文件被更改,包括 17 次插入2 次删除
  1. 19
      com.unity.ml-agents/Runtime/Training/ReplayBuffer.cs

19
com.unity.ml-agents/Runtime/Training/ReplayBuffer.cs


{
m_Buffer.Add(new Transition() {
state = CopyTensorList(state),
action = info.storedActions,
action = CopyActionBuffer(info.storedActions),
reward = info.reward,
done = info.done,
nextState = CopyTensorList(nextState)

{
m_Buffer[m_CurrentIndex] = new Transition() {
state = CopyTensorList(state),
action = info.storedActions,
action = CopyActionBuffer(info.storedActions),
reward = info.reward,
done = info.done,
nextState = CopyTensorList(nextState)

newList.Add(TensorUtils.DeepCopy(inputList[i]));
}
return (IReadOnlyList<TensorProxy>) newList;
}
ActionBuffers CopyActionBuffer(ActionBuffers actionBuffer)
{
float[] continuous = new float[] {actionBuffer.ContinuousActions.Length};
for (var i = 0; i < actionBuffer.ContinuousActions.Length; i++)
{
continuous[i] = actionBuffer.ContinuousActions[i];
}
int[] discrete = new int[] {actionBuffer.DiscreteActions.Length};
for (var i = 0; i < actionBuffer.DiscreteActions.Length; i++)
{
discrete[i] = actionBuffer.DiscreteActions[i];
}
return new ActionBuffers(continuous, discrete);
}
}
}
正在加载...
取消
保存