當前位置: 首頁>>代碼示例>>Python>>正文


Python atari_wrappers_deprecated.wrap_dqn方法代碼示例

本文整理匯總了Python中baselines.common.atari_wrappers_deprecated.wrap_dqn方法的典型用法代碼示例。如果您正苦於以下問題:Python atari_wrappers_deprecated.wrap_dqn方法的具體用法?Python atari_wrappers_deprecated.wrap_dqn怎麽用?Python atari_wrappers_deprecated.wrap_dqn使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在baselines.common.atari_wrappers_deprecated的用法示例。


在下文中一共展示了atari_wrappers_deprecated.wrap_dqn方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: main

# 需要導入模塊: from baselines.common import atari_wrappers_deprecated [as 別名]
# 或者: from baselines.common.atari_wrappers_deprecated import wrap_dqn [as 別名]
def main():
    env = gym.make("PongNoFrameskip-v4")
    env = ScaledFloatFrame(wrap_dqn(env))
    model = deepq.models.cnn_to_mlp(
        convs=[(32, 8, 4), (64, 4, 2), (64, 3, 1)],
        hiddens=[256],
        dueling=True
    )
    act = deepq.learn(
        env,
        q_func=model,
        lr=1e-4,
        max_timesteps=2000000,
        buffer_size=10000,
        exploration_fraction=0.1,
        exploration_final_eps=0.01,
        train_freq=4,
        learning_starts=10000,
        target_network_update_freq=1000,
        gamma=0.99,
        prioritized_replay=True
    )
    act.save("pong_model.pkl")
    env.close() 
開發者ID:AdamStelmaszczyk,項目名稱:learning2run,代碼行數:26,代碼來源:train_pong.py

示例2: main

# 需要導入模塊: from baselines.common import atari_wrappers_deprecated [as 別名]
# 或者: from baselines.common.atari_wrappers_deprecated import wrap_dqn [as 別名]
def main():
    if False:
        # deterministic version 4 results in a frame skip of 4 and no repeat action probability
        environment = gym.make('BreakoutDeterministic-v4')
        environment = TerminateOnEndOfLifeWrapper(environment)
        environment = ReshapeWrapper(environment)
        environment = ClipRewardWrapper(environment)
        environment = RepeatWrapper(environment, frames=4)
    else:
        # use the environment wrappers found in openai baselines.
        environment = gym.make('BreakoutNoFrameskip-v4')
        environment = wrap_dqn(environment)
        environment = DimShuffleWrapper(environment)

    # todo: perhaps these should be defined in the environment itself
    state_axes = ng.make_axes([
        ng.make_axis(environment.observation_space.shape[0], name='C'),
        ng.make_axis(environment.observation_space.shape[1], name='H'),
        ng.make_axis(environment.observation_space.shape[2], name='W'),
    ])

    agent = dqn.Agent(
        state_axes,
        environment.action_space,
        model=model,
        epsilon=dqn.linear_generator(start=1.0, end=0.1, steps=1000000),
        gamma=0.99,
        learning_rate=0.00025,
        memory=dqn.Memory(maxlen=1000000),
        target_network_update_frequency=1000,
        learning_starts=10000,
    )

    rl_loop.rl_loop_train(environment, agent, episodes=200000) 
開發者ID:NervanaSystems,項目名稱:ngraph-python,代碼行數:36,代碼來源:dqn_atari.py

示例3: make_env

# 需要導入模塊: from baselines.common import atari_wrappers_deprecated [as 別名]
# 或者: from baselines.common.atari_wrappers_deprecated import wrap_dqn [as 別名]
def make_env(game_name):
    env = gym.make(game_name + "NoFrameskip-v4")
    env_monitored = SimpleMonitor(env)
    env = wrap_dqn(env_monitored)
    return env_monitored, env 
開發者ID:AdamStelmaszczyk,項目名稱:learning2run,代碼行數:7,代碼來源:wang2015_eval.py

示例4: make_env

# 需要導入模塊: from baselines.common import atari_wrappers_deprecated [as 別名]
# 或者: from baselines.common.atari_wrappers_deprecated import wrap_dqn [as 別名]
def make_env(game_name):
    env = gym.make(game_name + "NoFrameskip-v4")
    env = SimpleMonitor(env)
    env = wrap_dqn(env)
    return env 
開發者ID:AdamStelmaszczyk,項目名稱:learning2run,代碼行數:7,代碼來源:enjoy.py

示例5: make_env

# 需要導入模塊: from baselines.common import atari_wrappers_deprecated [as 別名]
# 或者: from baselines.common.atari_wrappers_deprecated import wrap_dqn [as 別名]
def make_env(game_name):
    env = gym.make(game_name + "NoFrameskip-v4")
    monitored_env = SimpleMonitor(env)  # puts rewards and number of steps in info, before environment is wrapped
    env = wrap_dqn(monitored_env)  # applies a bunch of modification to simplify the observation space (downsample, make b/w)
    return env, monitored_env 
開發者ID:AdamStelmaszczyk,項目名稱:learning2run,代碼行數:7,代碼來源:train.py

示例6: main

# 需要導入模塊: from baselines.common import atari_wrappers_deprecated [as 別名]
# 或者: from baselines.common.atari_wrappers_deprecated import wrap_dqn [as 別名]
def main():
    env = gym.make("PongNoFrameskip-v4")
    env = ScaledFloatFrame(wrap_dqn(env))
    act = deepq.load("pong_model.pkl")

    while True:
        obs, done = env.reset(), False
        episode_rew = 0
        while not done:
            env.render()
            obs, rew, done, _ = env.step(act(obs[None])[0])
            episode_rew += rew
        print("Episode reward", episode_rew) 
開發者ID:AdamStelmaszczyk,項目名稱:learning2run,代碼行數:15,代碼來源:enjoy_pong.py

示例7: make_env

# 需要導入模塊: from baselines.common import atari_wrappers_deprecated [as 別名]
# 或者: from baselines.common.atari_wrappers_deprecated import wrap_dqn [as 別名]
def make_env(game_name):
    env = gym.make(game_name + "NoFrameskip-v4")
    env_monitored = bench.Monitor(env, None)
    env = wrap_dqn(env_monitored)
    return env_monitored, env 
開發者ID:cxxgtxy,項目名稱:deeprl-baselines,代碼行數:7,代碼來源:wang2015_eval.py

示例8: make_env

# 需要導入模塊: from baselines.common import atari_wrappers_deprecated [as 別名]
# 或者: from baselines.common.atari_wrappers_deprecated import wrap_dqn [as 別名]
def make_env(game_name):
    env = gym.make(game_name + "NoFrameskip-v4")
    env = bench.Monitor(env, None)
    env = wrap_dqn(env)
    return env 
開發者ID:cxxgtxy,項目名稱:deeprl-baselines,代碼行數:7,代碼來源:enjoy.py

示例9: make_env

# 需要導入模塊: from baselines.common import atari_wrappers_deprecated [as 別名]
# 或者: from baselines.common.atari_wrappers_deprecated import wrap_dqn [as 別名]
def make_env(game_name):
    env = gym.make(game_name + "NoFrameskip-v4")
    monitored_env = bench.SimpleMonitor(env, logger.get_dir())  # puts rewards and number of steps in info, before environment is wrapped
    env = wrap_dqn(monitored_env)  # applies a bunch of modification to simplify the observation space (downsample, make b/w)
    return env, monitored_env 
開發者ID:cxxgtxy,項目名稱:deeprl-baselines,代碼行數:7,代碼來源:train.py

示例10: make_env

# 需要導入模塊: from baselines.common import atari_wrappers_deprecated [as 別名]
# 或者: from baselines.common.atari_wrappers_deprecated import wrap_dqn [as 別名]
def make_env(game_name):
    env = gym.make(game_name + "NoFrameskip-v4")
    monitored_env = bench.SimpleMonitor(env)  # puts rewards and number of steps in info, before environment is wrapped
    env = wrap_dqn(monitored_env)
    return env, monitored_env 
開發者ID:cxxgtxy,項目名稱:deeprl-baselines,代碼行數:7,代碼來源:rainbow.py

示例11: make_env

# 需要導入模塊: from baselines.common import atari_wrappers_deprecated [as 別名]
# 或者: from baselines.common.atari_wrappers_deprecated import wrap_dqn [as 別名]
def make_env(game_name):
    env = gym.make(game_name + "NoFrameskip-v4")
    monitored_env = bench.Monitor(env, logger.get_dir())  # puts rewards and number of steps in info, before environment is wrapped
    env = wrap_dqn(monitored_env)  # applies a bunch of modification to simplify the observation space (downsample, make b/w)
    return env, monitored_env 
開發者ID:wgrathwohl,項目名稱:BackpropThroughTheVoidRL,代碼行數:7,代碼來源:train.py


注:本文中的baselines.common.atari_wrappers_deprecated.wrap_dqn方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。