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


Python validator.Validator方法代码示例

本文整理汇总了Python中validator.Validator方法的典型用法代码示例。如果您正苦于以下问题:Python validator.Validator方法的具体用法?Python validator.Validator怎么用?Python validator.Validator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在validator的用法示例。


在下文中一共展示了validator.Validator方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: import validator [as 别名]
# 或者: from validator import Validator [as 别名]
def main():

    args = get_args()

    nn.set_default_context(get_extension_context(
        args.extension, device_id=args.device_id))

    from atari_utils import make_atari_deepmind
    env = make_atari_deepmind(args.gym_env, valid=True)
    print('Observation:', env.observation_space)
    print('Action:', env.action_space)
    obs_sampler = ObsSampler(args.num_frames)
    val_replay_memory = ReplayMemory(env.observation_space.shape,
                                     env.action_space.shape, max_memory=args.num_frames)

    # for one file
    explorer = GreedyExplorer(
        env.action_space.n, use_nnp=True, nnp_file=args.nnp, name='qnet')
    validator = Validator(env, val_replay_memory, explorer, obs_sampler,
                          num_episodes=30, clip_episode_step=True,
                          render=not args.no_render)

    mean_reward = validator.step()
    with open(os.path.join(args.log_path, 'mean_reward.txt'), 'a') as f:
        print("{} {}".format(args.gym_env, str(mean_reward)), file=f) 
开发者ID:sony,项目名称:nnabla-examples,代码行数:27,代码来源:eval_atari.py

示例2: __init__

# 需要导入模块: import validator [as 别名]
# 或者: from validator import Validator [as 别名]
def __init__(self, config, loglevel=logging.INFO):
        logging.basicConfig(level=loglevel)
        log.LOGLEVEL = loglevel
        self.config = config['foreman']
        self.loglevel = loglevel
        self.validator = Validator() 
开发者ID:adfinis-sygroup,项目名称:foreman-yml,代码行数:8,代码来源:base.py

示例3: main

# 需要导入模块: import validator [as 别名]
# 或者: from validator import Validator [as 别名]
def main():

    args = get_args()

    nn.set_default_context(get_extension_context(
        args.extension, device_id=args.device_id))

    if args.nnp is None:
        local_nnp_dir = os.path.join("asset", args.gym_env)
        local_nnp_file = os.path.join(local_nnp_dir, "qnet.nnp")

        if not find_local_nnp(args.gym_env):
            logger.info("Downloading nnp data since you didn't specify...")
            nnp_uri = os.path.join("https://nnabla.org/pretrained-models/nnp_models/examples/dqn",
                                   args.gym_env,
                                   "qnet.nnp")
            if not os.path.exists(local_nnp_dir):
                os.mkdir(local_nnp_dir)
            download(nnp_uri, output_file=local_nnp_file, open_file=False)
            logger.info("Download done!")

        args.nnp = local_nnp_file

    from atari_utils import make_atari_deepmind
    env = make_atari_deepmind(args.gym_env, valid=False)
    print('Observation:', env.observation_space)
    print('Action:', env.action_space)
    obs_sampler = ObsSampler(args.num_frames)
    val_replay_memory = ReplayMemory(env.observation_space.shape,
                                     env.action_space.shape,
                                     max_memory=args.num_frames)
    # just play greedily
    explorer = GreedyExplorer(
        env.action_space.n, use_nnp=True, nnp_file=args.nnp, name='qnet')
    validator = Validator(env, val_replay_memory, explorer, obs_sampler,
                          num_episodes=1, render=not args.no_render)
    while True:
        validator.step() 
开发者ID:sony,项目名称:nnabla-examples,代码行数:40,代码来源:play_atari.py

示例4: validate

# 需要导入模块: import validator [as 别名]
# 或者: from validator import Validator [as 别名]
def validate():
    """
    Run ESLint validation using settings from the current TextMate
    environment. Return a list of issues.
    """

    eslint_command = os.environ.get('TM_JAVASCRIPT_ESLINT_ESLINT', 'eslint')
    the_validator = validator.Validator(eslint_command)

    filename = os.environ.get('TM_FILEPATH', None)
    input_is_html = not os.environ['TM_SCOPE'].startswith('source.js')
    line_offset = int(os.environ.get('TM_INPUT_START_LINE', 1)) - 1
    cwd = get_cwd()

    try:
        issues = the_validator.run(
            filename=filename,
            input_is_html=input_is_html,
            line_offset=line_offset,
            cwd=cwd
        )
    except validator.ValidateError as err:
        context = {
            'BASE_PATH': BASE_PATH,
            'timestamp': time.strftime('%c'),
            'errorMessage': err.message,
        }
        if err.path:
            context['searchPath'] = err.path
            html = ASHES_ENV.render('error_eslint_path.html', context)
        else:
            html = ASHES_ENV.render('error_eslint_other.html', context)
        print(html)
        sys.exit()

    return issues 
开发者ID:natesilva,项目名称:javascript-eslint.tmbundle,代码行数:38,代码来源:main.py

示例5: fix

# 需要导入模块: import validator [as 别名]
# 或者: from validator import Validator [as 别名]
def fix():
    """ Run the eslint --fix command against the current file. """
    if 'TM_FILEPATH' not in os.environ:
        # ignore if file is not saved
        return

    if not os.environ['TM_SCOPE'].startswith('source.js'):
        # refuse to run against HTML-embedded JavaScript
        return

    eslint_command = os.environ.get('TM_JAVASCRIPT_ESLINT_ESLINT', 'eslint')
    the_validator = validator.Validator(eslint_command)
    filename = os.environ['TM_FILEPATH']
    cwd = get_cwd()

    try:
        the_validator.fix(filename, cwd)
    except validator.ValidateError as err:
        context = {
            'BASE_PATH': BASE_PATH,
            'timestamp': time.strftime('%c'),
            'errorMessage': err.message,
        }
        if err.path:
            context['searchPath'] = err.path
            html = ASHES_ENV.render('error_eslint_path.html', context)
        else:
            html = ASHES_ENV.render('error_eslint_other.html', context)
        print(html)
        sys.exit()

    mate = os.environ['TM_MATE']
    subprocess.call([mate, '--clear-mark=warning', filename]) 
开发者ID:natesilva,项目名称:javascript-eslint.tmbundle,代码行数:35,代码来源:main.py

示例6: main

# 需要导入模块: import validator [as 别名]
# 或者: from validator import Validator [as 别名]
def main():

    args = get_args()

    nn.set_default_context(get_extension_context(
        args.extension, device_id=args.device_id))

    if args.log_path:
        output_path = OutputPath(args.log_path)
    else:
        output_path = OutputPath()
    monitor = Monitor(output_path.path)

    tbw = SummaryWriter(output_path.path)

    # Create an atari env.
    from atari_utils import make_atari_deepmind
    env = make_atari_deepmind(args.gym_env, valid=False)
    env_val = make_atari_deepmind(args.gym_env, valid=True)
    print('Observation:', env.observation_space)
    print('Action:', env.action_space)

    # 10000 * 4 frames
    val_replay_memory = ReplayMemory(
        env.observation_space.shape, env.action_space.shape, max_memory=args.num_frames)
    replay_memory = ReplayMemory(
        env.observation_space.shape, env.action_space.shape, max_memory=40000)

    learner = QLearner(q_cnn, env.action_space.n, sync_freq=1000, save_freq=250000,
                       gamma=0.99, learning_rate=1e-4, name_q='q', save_path=output_path)

    explorer = LinearDecayEGreedyExplorer(
        env.action_space.n, eps_start=1.0, eps_end=0.01, eps_steps=1e6,
        q_builder=q_cnn, name='q')

    sampler = Sampler(args.num_frames)
    obs_sampler = ObsSampler(args.num_frames)

    validator = Validator(env_val, val_replay_memory, explorer, obs_sampler,
                          num_episodes=args.num_val_episodes, num_eval_steps=args.num_eval_steps,
                          render=args.render_val, monitor=monitor, tbw=tbw)

    trainer_with_validator = Trainer(env, replay_memory, learner, sampler, explorer, obs_sampler, inter_eval_steps=args.inter_eval_steps,
                                     num_episodes=args.num_episodes, train_start=10000, batch_size=32,
                                     render=args.render_train, validator=validator, monitor=monitor, tbw=tbw)

    for e in range(args.num_epochs):
        trainer_with_validator.step() 
开发者ID:sony,项目名称:nnabla-examples,代码行数:50,代码来源:train_atari.py


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