古风汉服美女图集

araffin/ppo-LunarLander-v2

2023-12-28 05:20 0 微浪网
导语: PPO Agent playing LunarLand...,

araffin/ppo-LunarLander-v2


PPO Agent playing LunarLander-v2

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


Usage (with Stable-baselines3)

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


Training code (with SB3)

from stable_baselines3 import PPO<br /> from stable_baselines3.common.env_util import make_vec_env<br /> from stable_baselines3.common.callbacks import EvalCallback<br /> # Create the environment<br /> env_id = "LunarLander-v2"<br /> n_envs = 16<br /> env = make_vec_env(env_id, n_envs=n_envs)<br /> # Create the evaluation envs<br /> eval_envs = make_vec_env(env_id, n_envs=5)<br /> # Adjust evaluation interval depending on the number of envs<br /> eval_freq = int(1e5)<br /> eval_freq = max(eval_freq // n_envs, 1)<br /> # Create evaluation callback to save best model<br /> # and monitor agent performance<br /> eval_callback = EvalCallback(<br /> eval_envs,<br /> best_model_save_path="./logs/",<br /> eval_freq=eval_freq,<br /> n_eval_episodes=10,<br /> )<br /> # Instantiate the agent<br /> # Hyperparameters from https://github.com/DLR-RM/rl-baselines3-zoo<br /> model = PPO(<br /> "MlpPolicy",<br /> env,<br /> n_steps=1024,<br /> batch_size=64,<br /> gae_lambda=0.98,<br /> gamma=0.999,<br /> n_epochs=4,<br /> ent_coef=0.01,<br /> verbose=1,<br /> )<br /> # Train the agent (you can kill it before using ctrl+c)<br /> try:<br /> model.learn(total_timesteps=int(5e6), callback=eval_callback)<br /> except KeyboardInterrupt:<br /> pass<br /> # Load best model<br /> model = PPO.load("logs/best_model.zip")<br />


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

前往AI网址导航
1、本文来自 AIGC网址导航 投稿的内容 araffin/ppo-LunarLander-v2 ,所有言论和图片纯属作者个人意见,版权归原作者所有;不代表 本站 立场;
2、本站所有文章、图片、资源等如果未标明原创,均为收集自互联网公开资源;分享的图片、资源、视频等,出镜模特均为成年女性正常写真内容,版权归原作者所有,仅作为个人学习、研究以及欣赏!如有涉及下载请24小时内删除;
3、如果您发现本站上有侵犯您的权益的作品,请与我们取得联系,我们会及时修改、删除并致以最深的歉意。邮箱: i-hu#(#换@)foxmail.com

2023-12-28

2023-12-28

古风汉服美女图集
扫一扫二维码分享