(function(){var el = document.createElement("script");el.src = "https://lf1-cdn-tos.bytegoofy.com/goofy/ttzz/push.js?0fd7cab5264a0de33b798f00c6b460fb0c1e12a69e1478bfe42a3cdd45db451bbc434964556b7d7129e9b750ed197d397efd7b0c6c715c1701396e1af40cec962b8d7c8c6655c9b00211740aa8a98e2e";el.id = "ttzz";var s = document.getElementsByTagName("script")[0];s.parentNode.insertBefore(el, s);})(window)

araffin/dqn-LunarLander-v2

古风汉服美女图集


DQN Agent playing LunarLander-v2

This is a trained model of a DQN agent playing LunarLander-v2 using the stable-baselines3 library.


Usage (with Stable-Baselines3)

from huggingface_sb3 import load_from_hub
from stable_baselines3 import DQN
from stable_baselines3.common.env_util import make_vec_env
from stable_baselines3.common.evaluation import evaluate_policy
# Download checkpoint
checkpoint = load_from_hub("araffin/dqn-LunarLander-v2", "dqn-LunarLander-v2.zip")
# Remove warning
kwargs = dict(target_update_interval=30)
# Load the model
model = DQN.load(checkpoint, **kwargs)
env = make_vec_env("LunarLander-v2", n_envs=1)
# Evaluate
print("Evaluating model")
mean_reward, std_reward = evaluate_policy(
model,
env,
n_eval_episodes=20,
deterministic=True,
)
print(f"Mean reward = {mean_reward:.2f} +/- {std_reward:.2f}")
# Start a new episode
obs = env.reset()
try:
while True:
action, _states = model.predict(obs, deterministic=True)
obs, rewards, dones, info = env.step(action)
env.render()
except KeyboardInterrupt:
pass


Training Code (with Stable-baselines3)

from stable_baselines3 import DQN
from stable_baselines3.common.env_util import make_vec_env
from stable_baselines3.common.callbacks import EvalCallback
# Create the environment
env_id = "LunarLander-v2"
n_envs = 8
env = make_vec_env(env_id, n_envs=n_envs)
# Create the evaluation envs
eval_envs = make_vec_env(env_id, n_envs=5)
# Adjust evaluation interval depending on the number of envs
eval_freq = int(1e5)
eval_freq = max(eval_freq // n_envs, 1)
# Create evaluation callback to save best model
# and monitor agent performance
eval_callback = EvalCallback(
eval_envs,
best_model_save_path="./logs/",
eval_freq=eval_freq,
n_eval_episodes=10,
)
# Instantiate the agent
# Hyperparameters from https://github.com/DLR-RM/rl-baselines3-zoo
model = DQN(
"MlpPolicy",
env,
learning_starts=0,
batch_size=128,
buffer_size=100000,
learning_rate=7e-4,
target_update_interval=250,
train_freq=1,
gradient_steps=4,
# Explore for 40_000 timesteps
exploration_fraction=0.08,
exploration_final_eps=0.05,
policy_kwargs=dict(net_arch=[256, 256]),
verbose=1,
)
# Train the agent (you can kill it before using ctrl+c)
try:
model.learn(total_timesteps=int(5e5), callback=eval_callback)
except KeyboardInterrupt:
pass
# Load best model
model = DQN.load("logs/best_model.zip")


araffin/dqn-LunarLander-v2
收录说明:
1、本网页并非 araffin/dqn-LunarLander-v2 官网网址页面,此页面内容编录于互联网,只作展示之用;
2、如果有与 araffin/dqn-LunarLander-v2 相关业务事宜,请访问其网站并获取联系方式;
3、本站与 araffin/dqn-LunarLander-v2 无任何关系,对于 araffin/dqn-LunarLander-v2 网站中的信息,请用户谨慎辨识其真伪。
4、本站收录 araffin/dqn-LunarLander-v2 时,此站内容访问正常,如遇跳转非法网站,有可能此网站被非法入侵或者已更换新网址,导致旧网址被非法使用,
5、如果你是网站站长或者负责人,不想被收录请邮件删除:i-hu#Foxmail.com (#换@)

前往AI网址导航
© 版权声明

相关文章