浏览代码

Fix issue with BatchedStepResult with no agents (#3240)

/asymm-envs
GitHub 5 年前
当前提交
a64e7850
共有 2 个文件被更改,包括 12 次插入2 次删除
  1. 3
      ml-agents/mlagents/trainers/agent_processor.py
  2. 11
      ml-agents/mlagents/trainers/tests/test_agent_processor.py

3
ml-agents/mlagents/trainers/agent_processor.py


import sys
import numpy as np
from typing import List, Dict, Deque, TypeVar, Generic
from collections import defaultdict, Counter, deque

for global_id in action_global_agent_ids:
self.last_take_action_outputs[global_id] = take_action_outputs
for _id in np.nditer(batched_step_result.agent_id): # Explicit numpy iteration
for _id in batched_step_result.agent_id: # Assume agent_id is 1-D
local_id = int(
_id
) # Needed for mypy to pass since ndarray has no content type

11
ml-agents/mlagents/trainers/tests/test_agent_processor.py


# Assert that the AgentProcessor is empty
assert len(processor.experience_buffers[0]) == 0
# Test empty BatchedStepResult
mock_step = mb.create_mock_batchedstep(
num_agents=0,
num_vector_observations=8,
action_shape=[2],
num_vis_observations=num_vis_obs,
)
processor.add_experiences(mock_step, 0, ActionInfo([], [], {}, []))
# Assert that the AgentProcessor is still empty
assert len(processor.experience_buffers[0]) == 0
def test_agent_manager():
policy = create_mock_policy()

正在加载...
取消
保存