浏览代码

[bug-fix] Fix non-LSTM SeparateActorCritic (#4306)

/develop/add-fire
GitHub 4 年前
当前提交
17f03980
共有 2 个文件被更改,包括 5 次插入3 次删除
  1. 4
      ml-agents/mlagents/trainers/tests/torch/test_networks.py
  2. 4
      ml-agents/mlagents/trainers/torch/networks.py

4
ml-agents/mlagents/trainers/tests/torch/test_networks.py


)
else:
sample_obs = torch.ones((1, obs_size))
memories = None
memories = torch.tensor([])
# memories isn't always set to None, the network should be able to
# deal with that.
# Test critic pass
value_out = actor.critic_pass([sample_obs], [], memories=memories)
for stream in stream_names:

4
ml-agents/mlagents/trainers/torch/networks.py


vis_inputs: List[torch.Tensor],
memories: Optional[torch.Tensor] = None,
) -> Dict[str, torch.Tensor]:
if memories is not None:
if self.use_lstm:
# Use only the back half of memories for critic
_, critic_mem = torch.split(memories, self.half_mem_size, -1)
else:

memories: Optional[torch.Tensor] = None,
sequence_length: int = 1,
) -> Tuple[List[DistInstance], Dict[str, torch.Tensor], torch.Tensor]:
if memories is not None:
if self.use_lstm:
# Use only the back half of memories for critic and actor
actor_mem, critic_mem = torch.split(memories, self.half_mem_size, dim=-1)
else:

正在加载...
取消
保存