浏览代码

Log lesson in TensorBoard

/develop-generalizationTraining-TrainerController
Arthur Juliani 7 年前
当前提交
06d9bbec
共有 3 个文件被更改,包括 8 次插入4 次删除
  1. 7
      python/PPO.ipynb
  2. 2
      python/ppo.py
  3. 3
      python/ppo/trainer.py

7
python/PPO.ipynb


{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"env = UnityEnvironment(file_name=env_name, curriculum=curriculum_file)\n",

"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true,
"scrolled": true
},
"outputs": [],

" trainer.update_model(batch_size, num_epoch)\n",
" if steps % summary_freq == 0 and steps != 0 and train_model:\n",
" # Write training statistics to tensorboard.\n",
" trainer.write_summary(summary_writer, steps)\n",
" trainer.write_summary(summary_writer, steps, env._curriculum.lesson_number)\n",
" if steps % save_freq == 0 and steps != 0 and train_model:\n",
" # Save Tensorflow model\n",
" save_model(sess, model_path=model_path, steps=steps, saver=saver)\n",

2
python/ppo.py


trainer.update_model(batch_size, num_epoch)
if steps % summary_freq == 0 and steps != 0 and train_model:
# Write training statistics to tensorboard.
trainer.write_summary(summary_writer, steps)
trainer.write_summary(summary_writer, steps, env._curriculum.lesson_number)
if steps % save_freq == 0 and steps != 0 and train_model:
# Save Tensorflow model
save_model(sess, model_path=model_path, steps=steps, saver=saver)

3
python/ppo/trainer.py


for key in self.history_dict:
self.history_dict[key] = empty_local_history(self.history_dict[key])
def write_summary(self, summary_writer, steps):
def write_summary(self, summary_writer, steps, lesson_number):
"""
Saves training statistics to Tensorboard.
:param summary_writer: writer associated with Tensorflow session.

stat_mean = float(np.mean(self.stats[key]))
summary.value.add(tag='Info/{}'.format(key), simple_value=stat_mean)
self.stats[key] = []
summary.value.add(tag='Info/Lesson', simple_value=lesson_number)
summary_writer.add_summary(summary, steps)
summary_writer.flush()
正在加载...
取消
保存