浏览代码

Improving MetaCurriculum initialization.

- Raises MetaCurriculumError when curriculum_folder is not a folder.
- Removed the ability to set curriculum_folder to None.
  trainer_controller.py has been refactored to not depend on this
  functionality which will make curriculums more stable.
/develop-generalizationTraining-TrainerController
Deric Pang 6 年前
当前提交
4429077f
共有 3 个文件被更改,包括 22 次插入8 次删除
  1. 7
      python/tests/test_meta_curriculum.py
  2. 21
      python/unitytrainers/meta_curriculum.py
  3. 2
      python/unitytrainers/trainer_controller.py

7
python/tests/test_meta_curriculum.py


from unittest.mock import patch, call, Mock
from unitytrainers.meta_curriculum import MetaCurriculum
from unitytrainers.exception import MetaCurriculumError
class MetaCurriculumTest(MetaCurriculum):

call('test/Brain2.json', default_reset_parameters)]
mock_curriculum_init.assert_has_calls(calls)
@patch('os.listdir', side_effect=NotADirectoryError())
def test_init_meta_curriculum_bad_curriculum_folder_raises_error(listdir):
with pytest.raises(MetaCurriculumError):
MetaCurriculum('test/', default_reset_parameters)
@patch('unitytrainers.Curriculum')

21
python/unitytrainers/meta_curriculum.py


default_reset_parameters (dict): The default reset parameters
of the environment.
"""
if curriculum_folder is None:
self._brains_to_curriculums = None
else:
used_reset_parameters = set()
self._brains_to_curriculums = {}
used_reset_parameters = set()
self._brains_to_curriculums = {}
try:
# Check if any two curriculums use the same reset params.
logger.info('Two of more curriculums have attempted to change '
'the same reset parameter. The result will be '
logger.info('WARNING: Two of more curriculums will '
'attempt to change the same reset '
'parameter. The result will be '
except NotADirectoryError:
raise MetaCurriculumError(curriculum_folder + ' is not a '
'directory. Refer to the ML-Agents '
'curriculum learning docs.')
@property

2
python/unitytrainers/trainer_controller.py


'defined in ' +
self.curriculum_folder + ' '
'does not have a corresponding '
'Brain. Please check that the '
'Brain. Check that the '
'curriculum file has the same '
'name as the Brain '
'whose curriculum it defines.')

正在加载...
取消
保存