コード例 #1
0
    if args.save_azure_container is not None:
        account_name, account_key, container_name = \
            args.save_azure_container.split(":")
        container = Container(account_name=account_name,
                              account_key=account_key,
                              container_name=container_name,
                              maybe_create=True)
        if savedir is None:
            # Careful! This will not get cleaned up.
            savedir = tempfile.TemporaryDirectory().name
    else:
        container = None
    # Create and seed the env.
    env, monitored_env = make_env(args.env)
    if args.seed > 0:
        set_global_seeds(args.seed)
        env.unwrapped.seed(args.seed)

    # V: Save arguments, configure log dump path to savedir #
    if savedir:
        with open(os.path.join(savedir, 'args.json'), 'w') as f:
            json.dump(vars(args), f)
        logger.configure(dir=savedir)  # log to savedir

    with U.make_session(4) as sess:
        # Create training graph and replay buffer
        act, train, update_target, debug, craft_adv = deepq.build_train(
            make_obs_ph=lambda name: U.Uint8Input(env.observation_space.shape,
                                                  name=name),
            q_func=dueling_model if args.dueling else model,
            num_actions=env.action_space.n,
コード例 #2
0
ファイル: train.py プロジェクト: limin24kobe/cleverhans
            args.save_azure_container.split(":")
        container = Container(
            account_name=account_name,
            account_key=account_key,
            container_name=container_name,
            maybe_create=True
        )
        if savedir is None:
            # Careful! This will not get cleaned up.
            savedir = tempfile.TemporaryDirectory().name
    else:
        container = None
    # Create and seed the env.
    env, monitored_env = make_env(args.env)
    if args.seed > 0:
        set_global_seeds(args.seed)
        env.unwrapped.seed(args.seed)

    # V: Save arguments, configure log dump path to savedir #
    if savedir:
        with open(os.path.join(savedir, 'args.json'), 'w') as f:
            json.dump(vars(args), f)
        logger.configure(dir=savedir)  # log to savedir

    with U.make_session(4) as sess:
        # Create training graph and replay buffer
        act, train, update_target, debug, craft_adv = deepq.build_train(
            make_obs_ph=lambda name: U.Uint8Input(env.observation_space.shape,
                                                  name=name),
            q_func=dueling_model if args.dueling else model,
            num_actions=env.action_space.n,