浏览代码

Fix determinism in unit test (#2530)

* initialize random instance correctly

* restore threshold (I hope)
/develop-gpu-test
GitHub 5 年前
当前提交
0390c78b
共有 1 个文件被更改,包括 4 次插入3 次删除
  1. 7
      ml-agents/mlagents/trainers/tests/test_simple_rl.py

7
ml-agents/mlagents/trainers/tests/test_simple_rl.py


super().__init__()
self.discrete = use_discrete
self._brains: Dict[str, BrainParameters] = {}
self._brains[BRAIN_NAME] = BrainParameters(
brain_params = BrainParameters(
brain_name=BRAIN_NAME,
vector_observation_space_size=OBS_SIZE,
num_stacked_vector_observations=1,

vector_action_space_type=0 if use_discrete else 1,
)
self._brains[BRAIN_NAME] = brain_params
self.random = random.Random(str(self._brains))
self.random = random.Random(str(brain_params))
self.goal = self.random.choice([-1, 1])
def step(

print(tc._get_measure_vals())
for brain_name, mean_reward in tc._get_measure_vals().items():
assert not math.isnan(mean_reward)
assert mean_reward > 0.9
assert mean_reward > 0.99
@pytest.mark.parametrize("use_discrete", [True, False])

正在加载...
取消
保存