浏览代码

Fixing bug when no curriculum folder is passed.

- The old Curriculum object would accept None
as a location for the curriculum. If the
location was None, it would return default
values as its config and lesson number.

- The new MetaCurriculum does not accept
None as a location for the curriculum
folder. This was done to remove unnecessary
edge case functionality from curriculums.

- None checks have been added into
trainer_controller. In the future,
it should be possible to better refactor
trainer_controller so that these None
checks can be removed. This is preferable
to hard-coding default behavior into
MetaCurriculum objects when a metacurriculum
would not even be in place.
/develop-generalizationTraining-TrainerController
Deric Pang 7 年前
当前提交
822d329a
共有 2 个文件被更改,包括 18 次插入8 次删除
  1. 2
      python/unitytrainers/trainer.py
  2. 24
      python/unitytrainers/trainer_controller.py

2
python/unitytrainers/trainer.py


"""
raise UnityTrainerException("The update_model method was not implemented.")
def write_summary(self, lesson_num):
def write_summary(self, lesson_num=0):
"""
Saves training statistics to Tensorboard.
:param lesson_num: The lesson the trainer is at.

24
python/unitytrainers/trainer_controller.py


else:
self.meta_curriculum = MetaCurriculum(self.curriculum_folder, self.env._resetParameters)
if self.meta_curriculum is not None and self.curriculum_folder is not None:
if self.meta_curriculum is not None:
for brain_name in self.meta_curriculum.brains_to_curriculums.keys():
if brain_name not in self.env.external_brain_names:
raise MetaCurriculumError('One of the curriculums '

def start_learning(self):
# TODO: Should be able to start learning at different lesson numbers for each curriculum.
self.meta_curriculum.set_all_curriculums_to_lesson_num(self.lesson)
if self.meta_curriculum is not None:
self.meta_curriculum.set_all_curriculums_to_lesson_num(self.lesson)
trainer_config = self._load_config()
self._create_model_path(self.model_path)

else:
sess.run(init)
global_step = 0 # This is only for saving the model
self.meta_curriculum.increment_lessons(self._get_progresses())
curr_info = self.env.reset(config=self.meta_curriculum.get_config(), train_mode=self.fast_simulation)
if self.meta_curriculum is not None:
self.meta_curriculum.increment_lessons(self._get_progresses())
curr_info = self.env.reset(config=self.meta_curriculum.get_config(), train_mode=self.fast_simulation)
else:
curr_info = self.env.reset(train_mode=self.fast_simulation)
if self.train_model:
for brain_name, trainer in self.trainers.items():
trainer.write_tensorboard_text('Hyperparameters', trainer.parameters)

self.meta_curriculum.increment_lessons(self._get_progresses())
curr_info = self.env.reset(config=self.meta_curriculum.get_config(), train_mode=self.fast_simulation)
if self.meta_curriculum is not None:
self.meta_curriculum.increment_lessons(self._get_progresses())
curr_info = self.env.reset(config=self.meta_curriculum.get_config(), train_mode=self.fast_simulation)
else:
curr_info = self.env.reset(train_mode=self.fast_simulation)
for brain_name, trainer in self.trainers.items():
trainer.end_episode()
# Decide and take an action

# Perform gradient descent with experience buffer
trainer.update_model()
# Write training statistics to Tensorboard.
trainer.write_summary(self.meta_curriculum.brains_to_curriculums[brain_name].lesson_num)
if self.meta_curriculum is not None:
trainer.write_summary(lesson=self.meta_curriculum.brains_to_curriculums[brain_name].lesson_num)
else:
trainer.write_summary()
if self.train_model and trainer.get_step <= trainer.get_max_steps:
trainer.increment_step_and_update_last_reward()
if self.train_model:

正在加载...
取消
保存