本文整理汇总了Python中tensorboardX.SummaryWriter.add_video方法的典型用法代码示例。如果您正苦于以下问题:Python SummaryWriter.add_video方法的具体用法?Python SummaryWriter.add_video怎么用?Python SummaryWriter.add_video使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tensorboardX.SummaryWriter
的用法示例。
在下文中一共展示了SummaryWriter.add_video方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: range
# 需要导入模块: from tensorboardX import SummaryWriter [as 别名]
# 或者: from tensorboardX.SummaryWriter import add_video [as 别名]
## PLAY GAME
metrics['epsilon'] = eps.get(step)
game = utils.play_game(env, agent = dqn_epsilon_agent, th = metrics['epsilon'], memory = memory)
metrics['run_reward'], metrics['run_episode_steps'] = game['cum_reward'], game['steps']
step += metrics['run_episode_steps']
## TRAIN
for _ in range(metrics['run_episode_steps']//param['batch_size']):
metrics['run_loss'] = train_batch(param)
if metrics['episode'] % 500 == 0:
target_dqn.load_state_dict(dqn.state_dict())
# Test agent:
if metrics['episode'] % 100 == 0:
game = utils.play_game(env, agent = dqn_epsilon_agent, th = 0.02, memory = memory)
metrics['test_reward'], metrics['test_episode_steps'] = game['cum_reward'], game['steps']
checkpoint.save(dqn, step = step, step_loss = -metrics['test_reward'])
# REPORTING
if metrics['episode'] % 100 == 0:
for key, val in metrics.items():
writer.add_scalar(key, val, global_step = step)
# Animate agent:
if metrics['episode'] % 2500 == 0:
print("episode: {}, step: {}, reward: {}".format(metrics['episode'], step, metrics['run_reward']))
game = utils.play_game(env, agent = dqn_epsilon_agent, th = 0.02, render = True, memory = memory)
writer.add_video("test_game", game['frames'], global_step = step)