当前位置: 首页>>代码示例>>Python>>正文


Python SummaryWriter.add_video方法代码示例

本文整理汇总了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)
开发者ID:abri-simond,项目名称:RL,代码行数:32,代码来源:train_atari.py


注:本文中的tensorboardX.SummaryWriter.add_video方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。