Downloads · 30 days
0
0% of all-time downloads
masterdezign/dqn2-SpaceInvadersNoFrameskip-v4
dqn2-SpaceInvadersNoFrameskip-v4 is a reinforcement learning model from masterdezign. Use it for the reinforcement learning task on the model card, and read the license before you ship it in a product. It is set up for stable-baselines3.
This is a trained model of a DQN agent playing SpaceInvadersNoFrameskip-v4 using the stable-baselines3 library.
Downloads · 30 days
0
0% of all-time downloads
All-time downloads
127
Public
Repo size
55.1 MB
Likes
0
Public
Click a slice to open those files.
.zip28.1 MB · 49%
From the Hugging Face model README
This is a trained model of a DQN agent playing SpaceInvadersNoFrameskip-v4 using the stable-baselines3 library.
from stable_baselines3.common.env_util import make_atari_env
from stable_baselines3.common.vec_env import VecFrameStack
from stable_baselines3 import DQN
from stable_baselines3.common.evaluation import evaluate_policy
from huggingface_sb3 import load_from_hub, package_to_hub
from stable_baselines3.common.utils import set_random_seed
env_id = "SpaceInvadersNoFrameskip-v4"
env = make_atari_env(env_id,
n_envs=12,
# Improving reproducibility
seed=1)
env = VecFrameStack(env, n_stack=4) # Stack last four images
# Improving reproducibility
set_random_seed(42)
# Using these parameters as default: https://huggingface.co/micheljperez/dqn-SpaceInvadersNoFrameskip-v4
model = DQN(policy = "CnnPolicy",
env = env,
batch_size = 32,
buffer_size = 100_000,
exploration_final_eps = 0.01,
exploration_fraction = 0.025,
gradient_steps = 1,
learning_rate = 1e-4,
learning_starts = 100_000,
optimize_memory_usage = True,
replay_buffer_kwargs = {"handle_timeout_termination": False},
target_update_interval = 1000,
train_freq = 4,
# normalize = False,
tensorboard_log = "./tensorboard",
verbose=1
)
f = load_from_hub('masterdezign/dqn2-SpaceInvadersNoFrameskip-v4', 'dqn-SpaceInvadersNoFrameskip-v4.zip')
model = model.load(f)
mean_reward, std_reward = evaluate_policy(model, env)
print(f"Mean reward = {mean_reward:.2f} +/- {std_reward:.2f}")