Downloads · 30 days
3
11% of all-time downloads
FTU/lunarLanderPPO
lunarLanderPPO is a machine learning model from FTU. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for transformers.
!apt install swig cmake !pip install -r https://raw.githubusercontent.com/huggingface/deep-rl-class/main/notebooks/unit1/requirements-unit1.txt !sudo apt-get update !sudo apt-get install -y python3-opengl !apt install…
Downloads · 30 days
3
11% of all-time downloads
All-time downloads
28
Public
Repo size
280 KB
Likes
0
Public
Click a slice to open those files.
.mp4174 KB · 36%
From the Hugging Face model README
!apt install swig cmake !pip install -r https://raw.githubusercontent.com/huggingface/deep-rl-class/main/notebooks/unit1/requirements-unit1.txt !sudo apt-get update !sudo apt-get install -y python3-opengl !apt install ffmpeg !apt install xvfb !pip3 install pyvirtualdisplay
import os from pyvirtualdisplay import Display
virtual_display = Display(visible=0, size=(1400, 900)) virtual_display.start()
import gymnasium as gym from stable_baselines3 import PPO from stable_baselines3.common.env_util import make_vec_env from stable_baselines3.common.monitor import Monitor from stable_baselines3.common.evaluation import evaluate_policy from huggingface_sb3 import package_to_hub, load_from_hub from huggingface_hub import notebook_login
env_id = "LunarLander-v2" env = gym.make(env_id)
model = PPO( policy='MlpPolicy', env=env, n_steps=1024, batch_size=64, n_epochs=4, gamma=0.999, gae_lambda=0.98, ent_coef=0.01, verbose=1 )
model.learn(total_timesteps=1000000)
model_name = "lunarLander1" model.save(model_name)
eval_env = Monitor(gym.make(env_id)) mean_reward, std_reward = evaluate_policy(model, eval_env, n_eval_episodes=10, deterministic=True) print(f"mean_reward={mean_reward:.2f} +/- {std_reward}")
notebook_login() !git config --global credential.helper store
repo_id = "FTU/lunarLanderPPO" commit_message = "The first deep reinforced learning model"
package_to_hub( model=model, model_name=model_name, model_architecture="PPO", env_id=env_id, eval_env=eval_env, repo_id=repo_id, commit_message=commit_message )