浏览代码

Logging lesson number at the begining of training (#5199)

/check-for-ModelOverriders
GitHub 4 年前
当前提交
9a3600d5
共有 2 个文件被更改,包括 31 次插入7 次删除
  1. 37
      ml-agents/mlagents/trainers/environment_parameter_manager.py
  2. 1
      ml-agents/mlagents/trainers/trainer_controller.py

37
ml-agents/mlagents/trainers/environment_parameter_manager.py


)
return result
def log_current_lesson(self, parameter_name: Optional[str] = None) -> None:
"""
Logs the current lesson number and sampler value of the parameter with name
parameter_name. If no parameter_name is provided, the values and lesson
numbers of all parameters will be displayed.
"""
if parameter_name is not None:
settings = self._dict_settings[parameter_name]
lesson_number = GlobalTrainingStatus.get_parameter_state(
parameter_name, StatusType.LESSON_NUM
)
lesson_name = settings.curriculum[lesson_number].name
lesson_value = settings.curriculum[lesson_number].value
logger.info(
f"Parameter '{parameter_name}' is in lesson '{lesson_name}' "
f"and has value '{lesson_value}'."
)
else:
for parameter_name, settings in self._dict_settings.items():
lesson_number = GlobalTrainingStatus.get_parameter_state(
parameter_name, StatusType.LESSON_NUM
)
lesson_name = settings.curriculum[lesson_number].name
lesson_value = settings.curriculum[lesson_number].value
logger.info(
f"Parameter '{parameter_name}' is in lesson '{lesson_name}' "
f"and has value '{lesson_value}'."
)
def update_lessons(
self,
trainer_steps: Dict[str, int],

GlobalTrainingStatus.set_parameter_state(
param_name, StatusType.LESSON_NUM, next_lesson_num
)
new_lesson_name = settings.curriculum[next_lesson_num].name
new_lesson_value = settings.curriculum[next_lesson_num].value
logger.info(
f"Parameter '{param_name}' has been updated to {new_lesson_value}."
+ f" Now in lesson '{new_lesson_name}'"
)
self.log_current_lesson(param_name)
updated = True
if lesson.completion_criteria.require_reset:
must_reset = True

1
ml-agents/mlagents/trainers/trainer_controller.py


try:
# Initial reset
self._reset_env(env_manager)
self.param_manager.log_current_lesson()
while self._not_done_training():
n_steps = self.advance(env_manager)
for _ in range(n_steps):

正在加载...
取消
保存